Unable to use slave's temporary directory /tmp - Can't create/write to file '/tmp/SQL_LOAD-' (Errcode: 17 "File exists")

Description

The original unmodified description of the problem can be found at the bottom of the field

On SQL thread start, a slave checks permissions for slave_load_tmpdir by creating (and immediately deleting) a dummy file there:

sql/slave.cc:

The resulting file is <slave_load_tmpdir>/SQL_LOAD-. If the file exists, slave fails to start. The draft test case below shows that, it fails for any version.
Usually it's not a problem, since the slave deletes the file immediately. However, with multiple slaves, if they on some reason restart simultaneously, I suppose it's possible to hit a race condition when one slave has created the file but not deleted it yet, and another slave attempts to create it too and fails.

Test case below shows how slave fails to start when the file exists
(it uses $MYSQLTEST_VARDIR/tmp because that's what MTR sets for slave_load_tmpdir):

=================================
Original description

Multi-source replication seems to randomly stop with
Last_SQL_Error: Unable to use slave's temporary directory /tmp - Can't create/write to file '/tmp/SQL_LOAD-' (Errcode: 17 "File exists")

Only see it occassionally on a huge replication volume (100s of GB/day).

Is the master name perhaps missing off the end of that file name?
Is there any data that would be useful to capture when this happens to help debugging?

Environment

Linux (RHEL6)

Status

Assignee

Michael Widenius

Reporter

Gordan Bobic

Labels

None

External issue ID

None

External issue ID

None

Fix versions

Affects versions

Priority

Major
Configure