[MDEV-24667] LOAD DATA INFILE/inserted rows not written to binlog Created: 2021-01-24 Updated: 2022-03-29 Resolved: 2022-03-29 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Temporary, Replication |
| Affects Version/s: | 10.0, 10.1, 10.3.27, 10.5.8, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7 |
| Fix Version/s: | 10.2.44, 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4, 10.8.3 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Kfir Itzhak | Assignee: | Andrei Elkin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS 8 |
||
| Description |
|
Hi, I found a bug affecting recent MariaDB versions.
(All with stock settings, e.g. stock binlog_format) We have a master, with multiple slaves.
We run an query on the master to update some table. The query is successfully replicated to slaves #1 and #2. However, slave #1 doesn't write it properly to the binary log, causing the further slaves actually lose rows. The query we run on the master:
The issue seems related to temporary tables, because it doesn't happen with a static table. With this query i can successfully see the rows in the binary log:
What happens is that slave #1 correctly executes this, however it doesn't write it properly to the binary log. The load data infile statement is missing. I guess its ok for it to be missing because of binlog_format=mixed, however the rows aren't replicated either. Binary log emitted by slave #1:
Binary log emitted by slave #2:
Table structure:
Example CSV file for the load data infile:
|
| Comments |
| Comment by Elena Stepanova [ 2021-01-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report. I presume you run the servers with the default values of binlog_format, which would be statement on 5.5 and mixed on 10.3/10.5. Here is a raw MTR test to demonstrate (MTR sets log_slave_updates itself):
In the test case, have_binlog_format_mixed.inc makes the slave run with the mixed format, while for the master we set statement explicitly within the test. It imitates the default combination of binlog formats which happens naturally in 5.5 => 10.3 replication. If both the master and the slave were running with statement format, LOAD DATA would be replicated. But If the master is running in statement format, it writes the statements unchanged (temporary table, load and insert); and the slave running in mixed format writes some, but not all of it. That's the bug. It was introduced long time ago, in 10.0.5, my best guess is by this commit
but I didn't check the guess as I can't build it on my machine. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2021-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After some consideration, I've raised the priority. The reason for this is that 10.1 was the last version having binlog_format=STATEMENT by default, 10.2+ have MIXED; and 10.1 has recently EOL-ed, so people should start upgrading more actively. The replication topology in this bug is a core of upgrade-through-replication, thus it can become a fairly common problem. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kfir Itzhak [ 2021-01-25 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello @Elena Stepanova, thank you for the quick response. Indeed, i noticed the bug after beginning to upgrade production systems running on CentOS 6 (and few CentOS 7) to CentOS 8 with MariaDB 10.3.27 (from OS repo) I have tested what you said, and it looks like you are correct. STATEMENT -> STATEMENT:
STATEMENT -> ROW:
STATEMENT -> MIXED:
MIXED -> MIXED:
Thank you. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sachin Setiya (Inactive) [ 2021-05-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Analysis :- On Master:- We are sent data into stmt format (We are already hitting https://bugs.mysql.com/bug.php?id=34283) On Slave:- We have mixed format so because of https://bugs.mysql.com/bug.php?id=34283 we will shift the binlog format to rows. Possible Solution:- 2. easy solution, Slave anyways follows the master binlog format(for log_slave_updates)
if we are on slave thread we will not change the binlog format. One side effect would be that we have a tmp file to worry about on slave(34283), But master also have the same tmp file. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrei Elkin [ 2021-05-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
My verification confirms nicely structured (thanks, mastertheknife) https://jira.mariadb.org/browse/MDEV-24667?focusedCommentId=178177&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-178177. In M(STATEMENT) -> S(MIXED), slave loses in its binary log LOAD DATA for tmp or its effect to insert into t1 select * from tmp. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sachin Setiya (Inactive) [ 2021-05-26 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Few Observations:- But on slave , temporary table are stored in rgi_slave->rli->save_temporary_tables , not in the thd->temporray_tables I tried Some another case to simulate the same bug , where we get binlog loss on slave , without using infile
And if we look at the result
I am using this statement update tmp set a = 20 limit 1; which is unsafe | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sachin Setiya (Inactive) [ 2021-05-27 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Patch branch bb-10.2-24667 |