We have started getting the below error on our MariaDB instance as of this morning.

Error on delete of '/tmp/#sql-temptable-e931-bc-5.MAI' (Errcode: 2 "No such file or directory")

This happens on any DML command.

Does anyone encountered such scenario?

  • Please provide an example of DDL that created that error.
    – Rick James
    Commented Aug 23, 2022 at 18:00

2 Answers 2


I can't think how that could ever happen. Here are some notes on what is going on.

  • File names like that are for internally-generated temp table.
  • Such files are for complex SELECTs, etc when it needs build a temp table as the easiest/fastest way to perform the query.
  • Such tables are [normally] deleted (unlinked) when the query is finished.
  • If the server crashes before the query ends, such a "delete" fails to occur, so it survives.
  • If tmpdir points specifically to "/tmp", then the OS will toss the table after reboot.
  • If tmpdir points to anywhere other than "/tmp", such files could survive and clutter the disk. They can be safely removed. (In *nix, rm can safely be used even if the query is not finished with it. This is OS magic.)
  • The permissions on /tmp are such that there should never be a problem, so I cannot explain your situation.

After a lot of research managed to solve the issue.

We have been using federated tables for our exports (inserts etc), however at one point one of the mariadb replications went offline (the system was trying to recover it so it was going on and off), but our scheduled procedures were querying a federated table from the offline machine which caused such error.

So it was definitely a connection issue with the source tables.

Thank you for Rick for suggestions. I have already tried few of them before posting here, since I was a bit lost, but yes it turned out to be a server crash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.