| 1 |
# Initialize new data directory and restart MySQL on that data directory. |
| 2 |
# The new data directory will be initialized by instance which has: |
| 3 |
# --debug="d,trx_sys_low_trx_id_write_margin" so it will do reservations |
| 4 |
# of trx_id values every 8 trx_id values (instead of every 256 values). |
| 5 |
# This way we could collect enough connections in mtr test runner to fill |
| 6 |
# concurrently the reservation interval (limit for mtr connections is 128). |
| 7 |
# Restart MySQL using the new data directory. |
| 8 |
# restart: --datadir=tmp/max_trx_id --log-error=my_restart.err --debug=d,trx_sys_low_trx_id_write_margin --innodb-redo-log-capacity=8M --innodb_page_size=INNODB_PAGE_SIZE |
| 9 |
# Create 7 connections which keep creating and comitting transactions. |
| 10 |
# Pause the created connections before trx_sys_mutex_enter() is called |
| 11 |
# before assigning trx->id. |
| 12 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting1 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 13 |
SET @id = 1; |
| 14 |
START TRANSACTION; |
| 15 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 16 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting2 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 17 |
SET @id = 2; |
| 18 |
START TRANSACTION; |
| 19 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 20 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting3 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 21 |
SET @id = 3; |
| 22 |
START TRANSACTION; |
| 23 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 24 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting4 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 25 |
SET @id = 4; |
| 26 |
START TRANSACTION; |
| 27 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 28 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting5 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 29 |
SET @id = 5; |
| 30 |
START TRANSACTION; |
| 31 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 32 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting6 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 33 |
SET @id = 6; |
| 34 |
START TRANSACTION; |
| 35 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 36 |
SET DEBUG_SYNC = "trx_sys_before_assign_id SIGNAL con_id_waiting7 WAIT_FOR con_go NO_CLEAR_EVENT"; |
| 37 |
SET @id = 7; |
| 38 |
START TRANSACTION; |
| 39 |
UPDATE t SET c = c+1 WHERE a = @id; |
| 40 |
# Wait. |
| 41 |
# Wait for 1.... |
| 42 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting1"; |
| 43 |
# Wait for 2.... |
| 44 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting2"; |
| 45 |
# Wait for 3.... |
| 46 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting3"; |
| 47 |
# Wait for 4.... |
| 48 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting4"; |
| 49 |
# Wait for 5.... |
| 50 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting5"; |
| 51 |
# Wait for 6.... |
| 52 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting6"; |
| 53 |
# Wait for 7.... |
| 54 |
SET DEBUG_SYNC = "now WAIT_FOR con_id_waiting7"; |
| 55 |
# Create a connection which will hang inside trx_sys_write_max_trx_id() |
| 56 |
# when holding the trx_sys_serialisation_mutex. |
| 57 |
SET DEBUG_SYNC = "trx_sys_write_max_trx_id__ser SIGNAL write_waiting WAIT_FOR write_go"; |
| 58 |
CALL trx_loop(-1); |
| 59 |
# Wait until the created connection is hanging. |
| 60 |
SET DEBUG_SYNC = "now WAIT_FOR write_waiting"; |
| 61 |
# Let the paused connections go, to check if they could corrupt the database. |
| 62 |
# Do not allow them to write max_trx_id to the transaction system header page. |
| 63 |
SET GLOBAL DEBUG = "+d,trx_sys_write_max_trx_id__all_blocked"; |
| 64 |
SET DEBUG_SYNC = "now SIGNAL con_go"; |
| 65 |
# Wait a little bit, giving a chance to corrupt the database to the resumed |
| 66 |
# connections (by writing down too high trx_id to some page / row). |
| 67 |
# Kill and restart MySQL to see if the database is not corrupted. |
| 68 |
# Kill and restart: --datadir=tmp/max_trx_id --log-error=my_restart.err --debug=d,trx_sys_low_trx_id_write_margin --innodb-redo-log-capacity=8M --innodb_page_size=INNODB_PAGE_SIZE |
| 69 |
# Update rows using a new transaction. It would crash if the transaction |
| 70 |
# received a trx->id which had been assigned to some other transaction |
| 71 |
# and written to some page/row before MySQL crashed. |
| 72 |
UPDATE t SET c = c + 1; |
| 73 |
# Check if there is no corruption if MySQL instantly crashed after using |
| 74 |
# the new transaction (after restart). |
| 75 |
# Kill and restart: --datadir=tmp/max_trx_id --log-error=my_restart.err --debug=d,trx_sys_low_trx_id_write_margin --innodb-redo-log-capacity=8M --innodb_page_size=INNODB_PAGE_SIZE |
| 76 |
# Update all rows using a new transaction to see if there is no assertion |
| 77 |
# failure on trx_id for any of the related pages. |
| 78 |
UPDATE t SET c = c + 1; |
| 79 |
# Turn off MySQL and remove its data directory. |
| 80 |
# Kill the server |
| 81 |
# Restart usual instance of MySQL which is used for mtr tests. |
| 82 |
# restart: |