Debian Codegraph @

mysql-test/suite/binlog/t/binlog_rotate_bgc_sync.test

raw
1 # ==== Purpose ====
2 #
3 # This test tries to sync the binary log in the middle of a rotate,
4 # when the old binlog file has been closed and new binlog file has not yet
5 # opened.
6 #
7 # This cannot happen when the syncing client updates an InnoDB table,
8 # because InnoDB will increment MYSQL_BIN_LOG::m_prep_xids before
9 # flush and decrement it after commit, and rotate will only close the
10 # file when m_prep_xids==0, and the rotate holds LOCK_log to prevent
11 # new threads from entering the flush stage and subsequently the sync
12 # stage while the binlog is closed.
13 #
14 # But if the syncing client only updates a MyISAM table, it does not
15 # increment m_prep_xids. Then we rely on a different mechanism to
16 # avoid calling sync on a closed file descriptor: rotate holds
17 # LOCK_sync while closing the file and setting it to NULL. It is
18 # still possible that INSERT tries to sync while the file is closed:
19 # between the flush and sync stages there is a point in time where it
20 # is has released LOCK_log and not yet acquired LOCK_sync. If the
21 # syncing client is in this stage while the rotating thread closes the
22 # file, then the syncing client can go ahead and try to sync the file
23 # after the rotating client has released LOCK_sync. However, at this
24 # point the file is NULL, and that will make the syncing client skip
25 # the sync.
26 #
27 # We test exactly this scenario, to verify that sync does not crash
28 # even if the file is NULL.
29 #
30 # ==== Related Bugs and Worklogs ====
31 #
32 # BUG#22245619 SERVER ABORT AFTER SYNC STAGE OF THE COMMIT FAILS
33 #
34
35 # This test case is binary log format agnostic
36 --source include/have_binlog_format_row.inc
37 --source include/have_debug_sync.inc
38 --source include/force_myisam_default.inc
39 --source include/have_myisam.inc
40
41 # Create two additional connections
42 # conn1 will do the binary log group commit
43 # conn2 will rotate the binary log
44 # the default connection will coordinate the test case activity
45 --connect(conn1,localhost,root,,test)
46 --connect(conn2,localhost,root,,test)
47
48 --let $rpl_connection_name= conn1
49 --source include/rpl_connection.inc
50 # Create a new table
51 CREATE TABLE t1 (c1 INT) ENGINE = MyISAM;
52
53 # Make INSERT hold between the flush and sync stages
54 SET DEBUG_SYNC= 'bgc_between_flush_and_sync SIGNAL
55 holding_between_flush_and_sync WAIT_FOR continue_between_flush_and_sync';
56 --send INSERT INTO t1 VALUES (1)
57
58 --let $rpl_connection_name= conn2
59 --source include/rpl_connection.inc
60 # Wait until it reached the sync binary log group
61 SET DEBUG_SYNC= 'now WAIT_FOR holding_between_flush_and_sync';
62
63 # Make FLUSH LOGS hold after closing the old file and before opening
64 # the new file.
65 SET DEBUG_SYNC= 'binlog_rotate_between_close_and_open SIGNAL
66 holding_between_close_and_open WAIT_FOR continue_rotate_binlog_file';
67 # Rotate the binary log
68 --send FLUSH LOGS
69
70 # Wait until the server reaches the debug sync point while rotating the
71 # binary log
72 --let $rpl_connection_name= default
73 --source include/rpl_connection.inc
74 SET DEBUG_SYNC= 'now WAIT_FOR holding_between_close_and_open';
75
76 # Let the INSERT sync and continue
77 SET DEBUG_SYNC= 'now SIGNAL continue_between_flush_and_sync';
78 # Clear the binary log rotate debug sync point to avoid it to stop twice
79
80 --let $rpl_connection_name= conn1
81 --source include/rpl_connection.inc
82 --reap # INSERT
83
84 --let $rpl_connection_name= default
85 --source include/rpl_connection.inc
86 # Let the binary log rotate to continue
87 SET DEBUG_SYNC = 'now SIGNAL continue_rotate_binlog_file';
88
89 --let $rpl_connection_name= conn2
90 --source include/rpl_connection.inc
91 --reap # FLUSH LOGS
92
93 --let $rpl_connection_name= default
94 --source include/rpl_connection.inc
95 # Cleanup
96 DROP TABLE t1;
97 SET DEBUG_SYNC= 'RESET';
98
99 # Disconnect the additional connections
100 --disconnect conn1
101 --disconnect conn2