multi_source replication: conflict between rli->slave_patternload_file files of different connections

Description

When using multiple connections to different masters in a slave server, there
is nothing done to guard against conflicts on the file name constructed in
rli->slave_patternload_file.

I found this from random failures in a test case where I start two slave
connections at once:

This results sometimes in this error:

This happens because both SQL threads call
check_temp_dir(rli->slave_patternload_file) on the same file name created in
init_relay_log_info().

I think there are more problems with this. For example, it looks like
cleanup_load_tmpdir() could easily wrongly remove files from a different
connection. There seems nothing done to handle temporary files correctly
between different connections to multiple masters.

This seems like something that could easily cause silent (or not so silent)
corruption of replication.

Environment

None

Status

Assignee

Michael Widenius

Reporter

Kristian Nielsen

Labels

External issue ID

None

External issue ID

None

Fix versions

Affects versions

Priority

Major
Configure