[MDEV-3951] CREATE TABLE is not written in binary log if connection is killed in the process Created: 2012-12-18  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.0.0, 5.5.28a
Fix Version/s: 5.5

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: upstream-fixed

Issue Links:
Relates

 Description   

The problem is also reproducible on MySQL 5.5, 5.6 and filed as http://bugs.mysql.com/bug.php?id=67942

If a connection running CREATE TABLE .. LIKE is killed at a certain moment, it might happen that the table is created, but the corresponding record is not written to the binary log. Naturally, further actions on the table cause replication failure.

I'm not sure whether it can be reproduced with plain CREATE TABLE rather than CREATE TABLE .. LIKE. With CREATE TABLE .. LIKE, I could only reproduce it when the existing table (the one under LIKE) is a temporary table, and only with RBR.

Please note that the test case uses debug sync points. There is no need to add anything to the code, the sync point "create_table_like_before_binlog" already exists in MariaDB 5.5 and 10.0.

Test case:

--source include/master-slave.inc
--source include/have_binlog_format_row.inc
 
--connect (con1,localhost,root,,)
--let $con1 = `SELECT CONNECTION_ID()`
 
CREATE TEMPORARY TABLE t1 (j INT);
 
SET DEBUG_SYNC='create_table_like_before_binlog SIGNAL want_to_binlog WAIT_FOR killed';
 
send CREATE TABLE IF NOT EXISTS t2 LIKE t1;
 
--connection master
 
SET DEBUG_SYNC='now WAIT_FOR want_to_binlog';
eval KILL $con1;
SET DEBUG_SYNC='now SIGNAL killed';
 
SHOW TABLES;
SHOW BINLOG EVENTS;
INSERT INTO t2 VALUES (1);
 
--sync_slave_with_master
 

Partial output:

SHOW TABLES;
Tables_in_test
t2
SHOW BINLOG EVENTS;
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
master-bin.000001       4       Format_desc     1       245     Server ver: 5.5.28a-MariaDB-valgrind-max-debug-log, Binlog ver: 4
master-bin.000001       245     Query   1       355     use `test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `t1`
INSERT INTO t2 VALUES (1);
...
=== SHOW SLAVE STATUS ===
...
Last_Errno      1146
Last_Error      Error executing row event: 'Table 'test.t2' doesn't exist'


Generated at Thu Feb 08 06:52:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.