mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-22925 ALTER TABLE s3_table ENGINE=Aria can cause failure on slave
When converting a table (test.s3_table) from S3 to another engine, the following will be logged to the binary log: DROP TABLE IF EXISTS test.t1; CREATE OR REPLACE TABLE test.t1 (...) ENGINE=new_engine INSERT rows to test.t1 in binary-row-log-format The bug is that the above statements are logged one by one to the binary log. This means that a fast slave, configured to use the same S3 storage as the master, would be able to execute the DROP and CREATE from the binary log before the master has finished the ALTER TABLE. In this case the slave would ignore the DROP (as it's on a S3 table) but it will stop on CREATE of the local tale, as the table is still exists in S3. The REPLACE part will be ignored by the slave as it can't touch the S3 table. The fix is to ensure that all the above statements is written to binary log AFTER the table has been deleted from S3.
This commit is contained in:
@ -10711,7 +10711,7 @@ do_continue:;
|
||||
thd->binlog_table_should_be_logged(&new_table->s->db))
|
||||
{
|
||||
/*
|
||||
We new_table is marked as internal temp table, but we want to have
|
||||
'new_table' is marked as internal temp table, but we want to have
|
||||
the logging based on the original table type
|
||||
*/
|
||||
bool res;
|
||||
@ -10720,9 +10720,11 @@ do_continue:;
|
||||
|
||||
/* Force row logging, even if the table was created as 'temporary' */
|
||||
new_table->s->can_do_row_logging= 1;
|
||||
|
||||
thd->binlog_start_trans_and_stmt();
|
||||
res= binlog_drop_table(thd, table) || binlog_create_table(thd, new_table);
|
||||
thd->variables.option_bits|= OPTION_BIN_COMMIT_OFF;
|
||||
res= (binlog_drop_table(thd, table) ||
|
||||
binlog_create_table(thd, new_table, 1));
|
||||
thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF;
|
||||
new_table->s->tmp_table= org_tmp_table;
|
||||
if (res)
|
||||
goto err_new_table_cleanup;
|
||||
|
Reference in New Issue
Block a user