|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# This test will try to rotate the binary log of the server while binary log |
| 4 | +# group commit sync stage tries to sync the recently flushed binary log group. |
| 5 | +# |
| 6 | +# As binary log group commit releases the binary log's LOCK_log right after |
| 7 | +# finishing the flush stage and entering the sync stage, the rotate procedure |
| 8 | +# (executed by MYSQL_BIN_LOG::new_file_impl) will be able take LOCK_log, but |
| 9 | +# it will delay the binary log rotation until the amount of prepared |
| 10 | +# transactions not yet committed be zero or the binary log group commit sync |
| 11 | +# stage has finished. |
| 12 | +# |
| 13 | +# ==== Related Bugs and Worklogs ==== |
| 14 | +# |
| 15 | +# BUG#22245619 SERVER ABORT AFTER SYNC STAGE OF THE COMMIT FAILS |
| 16 | +# |
| 17 | + |
| 18 | +# This test case is binary log format agnostic |
| 19 | +--source include/have_binlog_format_row.inc |
| 20 | +--source include/have_debug_sync.inc |
| 21 | + |
| 22 | +# Set the options to hit the issue |
| 23 | +SET @saved_binlog_error_action= @@GLOBAL.binlog_error_action; |
| 24 | +SET GLOBAL binlog_error_action= ABORT_SERVER; |
| 25 | +SET @saved_sync_binlog= @@GLOBAL.sync_binlog; |
| 26 | +SET GLOBAL sync_binlog= 2; |
| 27 | + |
| 28 | +# Create two additional connections |
| 29 | +# conn1 will do the binary log group commit |
| 30 | +# conn2 will rotate the binary log |
| 31 | +# the default connection will coordinate the test case activity |
| 32 | +--connect(conn1,localhost,root,,test) |
| 33 | +--connect(conn2,localhost,root,,test) |
| 34 | + |
| 35 | +--let $engine= MyISAM |
| 36 | + |
| 37 | +while ($engine) |
| 38 | +{ |
| 39 | + --let $rpl_connection_name= conn1 |
| 40 | + --source include/rpl_connection.inc |
| 41 | + # Create a new table |
| 42 | + --eval CREATE TABLE t1 (c1 INT) ENGINE=$engine |
| 43 | + |
| 44 | + # Make the server to hold before syncing the binary log group |
| 45 | + SET DEBUG_SYNC= 'before_sync_binlog_file SIGNAL holding_before_bgc_sync_binlog_file WAIT_FOR continue_bgc_sync_binlog_file'; |
| 46 | + --send INSERT INTO t1 VALUES (1) |
| 47 | + |
| 48 | + --let $rpl_connection_name= conn2 |
| 49 | + --source include/rpl_connection.inc |
| 50 | + # Wait until it reached the sync binary log group |
| 51 | + SET DEBUG_SYNC= 'NOW WAIT_FOR holding_before_bgc_sync_binlog_file'; |
| 52 | + |
| 53 | + # Make the server to hold while rotating the binary log |
| 54 | + # It can hold in two places: |
| 55 | + # a) waiting before all flushed transactions with Xid to be committed; |
| 56 | + # b) after closing the old and before opening the new binary log file; |
| 57 | + # |
| 58 | + # The debug sync will happen at (a) if there are transactions for a |
| 59 | + # transactional storage engine or at (b) if there are no transactions |
| 60 | + # for a transactional storage engine in the group to be committed. |
| 61 | + SET DEBUG_SYNC= 'before_rotate_binlog_file SIGNAL holding_before_rotate_binlog_file WAIT_FOR continue_rotate_binlog_file'; |
| 62 | + # Rotate the binary log |
| 63 | + --send FLUSH LOGS |
| 64 | + |
| 65 | + # Wait until the server reaches the debug sync point while rotating the |
| 66 | + # binary log |
| 67 | + --let $rpl_connection_name= default |
| 68 | + --source include/rpl_connection.inc |
| 69 | + --disable_warnings |
| 70 | + SET DEBUG_SYNC= 'now WAIT_FOR holding_before_rotate_binlog_file TIMEOUT 3'; |
| 71 | + --enable_warnings |
| 72 | + |
| 73 | + # Let the binary log group commit to sync and continue |
| 74 | + SET DEBUG_SYNC= 'now SIGNAL continue_bgc_sync_binlog_file'; |
| 75 | + # Clear the binary log rotate debug sync point to avoid it to stop twice |
| 76 | + SET DEBUG_SYNC= 'before_rotate_binlog_file CLEAR'; |
| 77 | + # Let the binary log rotate to continue |
| 78 | + SET DEBUG_SYNC = 'now SIGNAL continue_rotate_binlog_file'; |
| 79 | + |
| 80 | + --let $rpl_connection_name= conn1 |
| 81 | + --source include/rpl_connection.inc |
| 82 | + --reap |
| 83 | + |
| 84 | + --let $rpl_connection_name= conn2 |
| 85 | + --source include/rpl_connection.inc |
| 86 | + --reap |
| 87 | + |
| 88 | + --let $rpl_connection_name= default |
| 89 | + --source include/rpl_connection.inc |
| 90 | + |
| 91 | + # Cleanup |
| 92 | + DROP TABLE t1; |
| 93 | + SET DEBUG_SYNC= 'RESET'; |
| 94 | + |
| 95 | + if ($engine == InnoDB) |
| 96 | + { |
| 97 | + --let $engine= |
| 98 | + } |
| 99 | + if ($engine == MyISAM) |
| 100 | + { |
| 101 | + --let $engine= InnoDB |
| 102 | + } |
| 103 | +} |
| 104 | + |
| 105 | +# Disconnect the additional connections |
| 106 | +--disconnect conn1 |
| 107 | +--disconnect conn2 |
| 108 | + |
| 109 | +SET GLOBAL binlog_error_action= @saved_binlog_error_action; |
| 110 | +SET GLOBAL sync_binlog= @saved_sync_binlog; |
0 commit comments