| 1 |
SET GLOBAL max_binlog_size= 4096; |
| 2 |
SET GLOBAL innodb_flush_log_at_trx_commit= 1; |
| 3 |
RESET MASTER; |
| 4 |
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb; |
| 5 |
INSERT INTO t1 VALUES (100, REPEAT("x", 4100)); |
| 6 |
INSERT INTO t1 VALUES (101, REPEAT("x", 4100)); |
| 7 |
INSERT INTO t1 VALUES (102, REPEAT("x", 4100)); |
| 8 |
connect con1,localhost,root,,; |
| 9 |
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con1_wait WAIT_FOR con1_cont"; |
| 10 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con1_ready WAIT_FOR _ever"; |
| 11 |
INSERT INTO t1 VALUES (1, REPEAT("x", 4100)); |
| 12 |
connection default; |
| 13 |
SET DEBUG_SYNC= "now WAIT_FOR con1_wait"; |
| 14 |
connect con2,localhost,root,,; |
| 15 |
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con2_wait WAIT_FOR con2_cont"; |
| 16 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con2_ready WAIT_FOR _ever"; |
| 17 |
INSERT INTO t1 VALUES (2, NULL); |
| 18 |
connection default; |
| 19 |
SET DEBUG_SYNC= "now WAIT_FOR con2_wait"; |
| 20 |
connect con3,localhost,root,,; |
| 21 |
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con3_wait WAIT_FOR con3_cont"; |
| 22 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con3_ready WAIT_FOR _ever"; |
| 23 |
INSERT INTO t1 VALUES (3, REPEAT("x", 4100)); |
| 24 |
connection default; |
| 25 |
SET DEBUG_SYNC= "now WAIT_FOR con3_wait"; |
| 26 |
connect con4,localhost,root,,; |
| 27 |
SET DEBUG_SYNC= "ha_commit_trans_before_log_and_order SIGNAL con4_wait WAIT_FOR con4_cont"; |
| 28 |
SET SESSION debug_dbug="+d,crash_commit_after_log"; |
| 29 |
INSERT INTO t1 VALUES (4, NULL); |
| 30 |
connection default; |
| 31 |
SET DEBUG_SYNC= "now WAIT_FOR con4_wait"; |
| 32 |
SET DEBUG_SYNC= "now SIGNAL con1_cont"; |
| 33 |
SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; |
| 34 |
SET DEBUG_SYNC= "now SIGNAL con2_cont"; |
| 35 |
SET DEBUG_SYNC= "now WAIT_FOR con2_ready"; |
| 36 |
SET DEBUG_SYNC= "now SIGNAL con3_cont"; |
| 37 |
SET DEBUG_SYNC= "now WAIT_FOR con3_ready"; |
| 38 |
show binary logs; |
| 39 |
Log_name File_size |
| 40 |
master-bin.000001 # |
| 41 |
master-bin.000002 # |
| 42 |
master-bin.000003 # |
| 43 |
master-bin.000004 # |
| 44 |
master-bin.000005 # |
| 45 |
master-bin.000006 # |
| 46 |
include/show_binlog_events.inc |
| 47 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 48 |
master-bin.000003 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 49 |
master-bin.000003 # Gtid_list # # [#-#-#] |
| 50 |
master-bin.000003 # Binlog_checkpoint # # master-bin.000002 |
| 51 |
master-bin.000003 # Binlog_checkpoint # # master-bin.000003 |
| 52 |
master-bin.000003 # Gtid # # BEGIN GTID #-#-# |
| 53 |
master-bin.000003 # Annotate_rows # # INSERT INTO t1 VALUES (102, REPEAT("x", 4100)) |
| 54 |
master-bin.000003 # Table_map # # table_id: # (test.t1) |
| 55 |
master-bin.000003 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 56 |
master-bin.000003 # Xid # # COMMIT /* XID */ |
| 57 |
master-bin.000003 # Rotate # # master-bin.000004;pos=POS |
| 58 |
include/show_binlog_events.inc |
| 59 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 60 |
master-bin.000004 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 61 |
master-bin.000004 # Gtid_list # # [#-#-#] |
| 62 |
master-bin.000004 # Binlog_checkpoint # # master-bin.000003 |
| 63 |
master-bin.000004 # Binlog_checkpoint # # master-bin.000004 |
| 64 |
master-bin.000004 # Gtid # # BEGIN GTID #-#-# |
| 65 |
master-bin.000004 # Annotate_rows # # INSERT INTO t1 VALUES (1, REPEAT("x", 4100)) |
| 66 |
master-bin.000004 # Table_map # # table_id: # (test.t1) |
| 67 |
master-bin.000004 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 68 |
master-bin.000004 # Xid # # COMMIT /* XID */ |
| 69 |
master-bin.000004 # Rotate # # master-bin.000005;pos=POS |
| 70 |
include/show_binlog_events.inc |
| 71 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 72 |
master-bin.000005 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 73 |
master-bin.000005 # Gtid_list # # [#-#-#] |
| 74 |
master-bin.000005 # Binlog_checkpoint # # master-bin.000004 |
| 75 |
master-bin.000005 # Gtid # # BEGIN GTID #-#-# |
| 76 |
master-bin.000005 # Annotate_rows # # INSERT INTO t1 VALUES (2, NULL) |
| 77 |
master-bin.000005 # Table_map # # table_id: # (test.t1) |
| 78 |
master-bin.000005 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 79 |
master-bin.000005 # Xid # # COMMIT /* XID */ |
| 80 |
master-bin.000005 # Gtid # # BEGIN GTID #-#-# |
| 81 |
master-bin.000005 # Annotate_rows # # INSERT INTO t1 VALUES (3, REPEAT("x", 4100)) |
| 82 |
master-bin.000005 # Table_map # # table_id: # (test.t1) |
| 83 |
master-bin.000005 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 84 |
master-bin.000005 # Xid # # COMMIT /* XID */ |
| 85 |
master-bin.000005 # Rotate # # master-bin.000006;pos=POS |
| 86 |
include/show_binlog_events.inc |
| 87 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 88 |
master-bin.000006 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 89 |
master-bin.000006 # Gtid_list # # [#-#-#] |
| 90 |
master-bin.000006 # Binlog_checkpoint # # master-bin.000004 |
| 91 |
PURGE BINARY LOGS TO "master-bin.000006"; |
| 92 |
Warnings: |
| 93 |
Note 1375 Binary log 'master-bin.000004' is not purged because it may be needed for crash recovery (XID) |
| 94 |
show binary logs; |
| 95 |
Log_name File_size |
| 96 |
master-bin.000004 # |
| 97 |
master-bin.000005 # |
| 98 |
master-bin.000006 # |
| 99 |
SET DEBUG_SYNC= "now SIGNAL con4_cont"; |
| 100 |
connection con4; |
| 101 |
Got one of the listed errors |
| 102 |
connection default; |
| 103 |
SELECT a FROM t1 ORDER BY a; |
| 104 |
a |
| 105 |
1 |
| 106 |
2 |
| 107 |
3 |
| 108 |
4 |
| 109 |
100 |
| 110 |
101 |
| 111 |
102 |
| 112 |
Test that with multiple binlog checkpoints, recovery starts from the last one. |
| 113 |
SET GLOBAL max_binlog_size= 4096; |
| 114 |
SET GLOBAL innodb_flush_log_at_trx_commit= 1; |
| 115 |
RESET MASTER; |
| 116 |
connect con10,localhost,root,,; |
| 117 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con10_ready WAIT_FOR con10_cont"; |
| 118 |
INSERT INTO t1 VALUES (10, REPEAT("x", 4100)); |
| 119 |
connection default; |
| 120 |
SET DEBUG_SYNC= "now WAIT_FOR con10_ready"; |
| 121 |
connect con11,localhost,root,,; |
| 122 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con11_ready WAIT_FOR con11_cont"; |
| 123 |
INSERT INTO t1 VALUES (11, REPEAT("x", 4100)); |
| 124 |
connection default; |
| 125 |
SET DEBUG_SYNC= "now WAIT_FOR con11_ready"; |
| 126 |
connect con12,localhost,root,,; |
| 127 |
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con12_ready WAIT_FOR con12_cont"; |
| 128 |
INSERT INTO t1 VALUES (12, REPEAT("x", 4100)); |
| 129 |
connection default; |
| 130 |
SET DEBUG_SYNC= "now WAIT_FOR con12_ready"; |
| 131 |
INSERT INTO t1 VALUES (13, NULL); |
| 132 |
show binary logs; |
| 133 |
Log_name File_size |
| 134 |
master-bin.000001 # |
| 135 |
master-bin.000002 # |
| 136 |
master-bin.000003 # |
| 137 |
master-bin.000004 # |
| 138 |
include/show_binlog_events.inc |
| 139 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 140 |
master-bin.000004 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 141 |
master-bin.000004 # Gtid_list # # [#-#-#] |
| 142 |
master-bin.000004 # Binlog_checkpoint # # master-bin.000001 |
| 143 |
master-bin.000004 # Gtid # # BEGIN GTID #-#-# |
| 144 |
master-bin.000004 # Annotate_rows # # INSERT INTO t1 VALUES (13, NULL) |
| 145 |
master-bin.000004 # Table_map # # table_id: # (test.t1) |
| 146 |
master-bin.000004 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 147 |
master-bin.000004 # Xid # # COMMIT /* XID */ |
| 148 |
SET DEBUG_SYNC= "now SIGNAL con10_cont"; |
| 149 |
connection con10; |
| 150 |
connection default; |
| 151 |
SET DEBUG_SYNC= "now SIGNAL con12_cont"; |
| 152 |
connection con12; |
| 153 |
connection default; |
| 154 |
SET DEBUG_SYNC= "now SIGNAL con11_cont"; |
| 155 |
connection con11; |
| 156 |
connection default; |
| 157 |
Now crash the server |
| 158 |
SET SESSION debug_dbug="+d,crash_commit_after_log"; |
| 159 |
INSERT INTO t1 VALUES (14, NULL); |
| 160 |
Got one of the listed errors |
| 161 |
connection default; |
| 162 |
SELECT a FROM t1 ORDER BY a; |
| 163 |
a |
| 164 |
1 |
| 165 |
2 |
| 166 |
3 |
| 167 |
4 |
| 168 |
10 |
| 169 |
11 |
| 170 |
12 |
| 171 |
13 |
| 172 |
14 |
| 173 |
100 |
| 174 |
101 |
| 175 |
102 |
| 176 |
*** Check that recovery works if we crashed early during rotate, before |
| 177 |
*** binlog checkpoint event could be written. |
| 178 |
SET GLOBAL max_binlog_size= 4096; |
| 179 |
SET GLOBAL innodb_flush_log_at_trx_commit= 1; |
| 180 |
RESET MASTER; |
| 181 |
INSERT INTO t1 VALUES (21, REPEAT("x", 4100)); |
| 182 |
INSERT INTO t1 VALUES (22, REPEAT("x", 4100)); |
| 183 |
INSERT INTO t1 VALUES (23, REPEAT("x", 4100)); |
| 184 |
SET SESSION debug_dbug="+d,crash_before_write_checkpoint_event"; |
| 185 |
INSERT INTO t1 VALUES (24, REPEAT("x", 4100)); |
| 186 |
Got one of the listed errors |
| 187 |
SELECT a FROM t1 ORDER BY a; |
| 188 |
a |
| 189 |
1 |
| 190 |
2 |
| 191 |
3 |
| 192 |
4 |
| 193 |
10 |
| 194 |
11 |
| 195 |
12 |
| 196 |
13 |
| 197 |
14 |
| 198 |
21 |
| 199 |
22 |
| 200 |
23 |
| 201 |
24 |
| 202 |
100 |
| 203 |
101 |
| 204 |
102 |
| 205 |
show binary logs; |
| 206 |
Log_name File_size |
| 207 |
master-bin.000001 # |
| 208 |
master-bin.000002 # |
| 209 |
master-bin.000003 # |
| 210 |
master-bin.000004 # |
| 211 |
master-bin.000005 # |
| 212 |
include/show_binlog_events.inc |
| 213 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 214 |
master-bin.000004 # Format_desc # # SERVER_VERSION, BINLOG_VERSION |
| 215 |
master-bin.000004 # Gtid_list # # [#-#-#] |
| 216 |
master-bin.000004 # Binlog_checkpoint # # master-bin.000003 |
| 217 |
master-bin.000004 # Binlog_checkpoint # # master-bin.000004 |
| 218 |
master-bin.000004 # Gtid # # BEGIN GTID #-#-# |
| 219 |
master-bin.000004 # Annotate_rows # # INSERT INTO t1 VALUES (24, REPEAT("x", 4100)) |
| 220 |
master-bin.000004 # Table_map # # table_id: # (test.t1) |
| 221 |
master-bin.000004 # Write_rows_v1 # # table_id: # flags: STMT_END_F |
| 222 |
master-bin.000004 # Xid # # COMMIT /* XID */ |
| 223 |
master-bin.000004 # Rotate # # master-bin.000005;pos=POS |
| 224 |
connection default; |
| 225 |
DROP TABLE t1; |