Skip to content

RDS MariaDB: what is the './tmp' directory inside the data directory?

0

On RDS MariaDB, SHOW DATABASES lists an entry named 'tmp' that cannot be dropped:

DROP DATABASE tmp; ERROR 1010 (HY000): Error dropping database (can't rmdir './tmp', errno: 39 "Directory not empty")

I see this on two separate instances, running 10.5.29 and 10.11.18.

WHAT I HAVE ALREADY CHECKED

Every metadata source reports it as completely empty. All of these return zero, on both instances:

  • information_schema.tables WHERE table_schema = 'tmp'
  • information_schema.views
  • information_schema.triggers
  • information_schema.routines
  • grants referencing it in mysql.db
  • active connections in information_schema.processlist
  • information_schema.innodb_sys_tables and .innodb_sys_tablespaces

So the server reports the schema as empty while the underlying directory is not.

WHAT I ALREADY RULED OUT

I understand SHOW DATABASES reflects the directories present in the data directory. That explained a second entry I was also seeing, 'innodb': it is simply @@innodb_data_home_dir (/rdsdbdata/db/innodb), which sits inside @@datadir (/rdsdbdata/db/). Confirmed on both instances, so that one is settled.

'tmp' is not explained the same way: @@tmpdir is /rdsdbdata/tmp, which is OUTSIDE the data directory on both instances. So /rdsdbdata/db/tmp is something else.

I have no filesystem access on RDS, and secure_file_priv is restricted, so I cannot inspect it myself.

QUESTION

What is /rdsdbdata/db/tmp used for on RDS MariaDB? Specifically:

  1. Is it an internal directory created and used by the engine or by the RDS platform, such that its presence in SHOW DATABASES is expected and no action is required?
  2. If it is not internal, and it contains orphaned files, what is the supported path to have them removed so that DROP DATABASE succeeds?

WHY I AM ASKING

I am completing an ISO 27001 hardening checklist. One control requires that no unused or example schemas exist on the instance. I need either a supported removal path or confirmation that this is an expected internal directory, so the control can be closed with evidence rather than an unexplained exception.

  • If my answer was helpful, I would appreciate it if you could mark it as the accepted answer.

asked 25 days ago75 views

2 Answers
1

The './tmp' directory you're seeing in SHOW DATABASES on RDS MariaDB is an internal directory used by the database engine for temporary tablespace operations. This is expected behavior and no action is required.

In MariaDB, the temporary tablespace stores temporary tables created during query execution. When these temporary tables are dropped, the space is not automatically reclaimed from the global temporary tablespace, which can cause the directory to appear non-empty even when no user-created objects exist within it.

This explains why all your metadata queries return zero results - there are no user-created tables, views, triggers, or routines in that schema. The directory contains internal temporary tablespace files managed by the InnoDB storage engine, not user objects that would appear in information_schema.

For your ISO 27001 hardening checklist, you can document this as an expected internal directory created and maintained by the MariaDB engine itself. It is not an unused or example schema - it serves an active operational purpose for the database's temporary table management. The fact that it cannot be dropped (errno 39 "Directory not empty") is by design, as the engine maintains control over this directory.

If you need to manage the size of the temporary tablespace for operational reasons, MariaDB 11.8 and higher versions on RDS support temporary file size limits through system variables like max_tmp_session_space_usage and max_tmp_total_space_usage. Additionally, you can use the mysql.rds_execute_operation procedure to shrink the temporary tablespace and reclaim disk space when needed. However, the directory itself should remain in place as part of normal database operations.
Sources
MariaDB feature support on Amazon RDS - Amazon Relational Database Service
mysql.rds_execute_operation - Amazon Relational Database Service

answered 25 days ago

EXPERT

reviewed 22 days ago

1

My understanding is differenziert from the re:Post Agent’s answer … for the OS-level error you are encountering and the path forward for your audit.

Errno 39 "Directory not empty" is a standard POSIX operating system error (ENOTEMPTY).

-> https://repost.aws/questions/QUp9Ga07WQR7KXA6TzNkYADw/drop-database-errno-39

When you execute DROP DATABASE, MariaDB deletes all recognized database files (like .frm, .ibd) and then attempts to remove the directory using the OS rmdir() command. If the directory contains files that MariaDB did not create and does not recognize (such as hidden files, logs, or artifacts left by internal RDS automation agents), MariaDB leaves them untouched. Consequently, the OS prevents the directory from being deleted.

This also explains why your information_schema queries return zero results: there are no valid database objects in that folder, only unrecognized file remnants. Resolution for your ISO 27001 Audit: Because RDS is a managed service, you do not have the underlying shell access required to inspect or delete these foreign files manually.

To satisfy your ISO 27001 control, I guess the only supported path is to open an AWS Support Case.

I would ask AWS Support to either:

  • Manually clear the unrecognized files from the underlying host so your DROP DATABASE command can succeed.
  • Provide a formal, written confirmation in the ticket stating that this directory and its contents are internal, AWS-managed artifacts.

You can then use the AWS Support ticket resolution as direct, official evidence for your auditor to close the control or document a valid exception.

EXPERT

answered 25 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.