| 1 |
# Initialize new data directory... |
| 2 |
# Restart MySQL using the new data directory... |
| 3 |
# restart: --datadir=tmp/log_corruption --log-error=my_restart.err |
| 4 |
# Prepare schema used in the tests. |
| 5 |
# Ensure there is a lot of free space in the redo log. |
| 6 |
SET GLOBAL innodb_log_checkpoint_now = ON; |
| 7 |
# Disable checkpointing. |
| 8 |
SET GLOBAL innodb_checkpoint_disabled = ON; |
| 9 |
# Create connection which generates spam to the redo log. |
| 10 |
CALL log_spammer(); |
| 11 |
# Create at least few redo records... |
| 12 |
CREATE TABLE t (a INT) ENGINE=InnoDB; |
| 13 |
INSERT INTO t(a) VALUES(42); |
| 14 |
# Kill MySQL... |
| 15 |
# Kill the server |
| 16 |
# Remove unused redo files and prepare saved_datadir... |
| 17 |
############################################################################################ |
| 18 |
# Case 1. Corrupt a mini-transaction after the checkpoint by changing type of redo record. |
| 19 |
# Start recovery and observe information about the corrupted redo record (invalid |
| 20 |
# type of redo record, equal to 0). |
| 21 |
############################################################################################ |
| 22 |
# Start MySQL... |
| 23 |
# Verify... |
| 24 |
Pattern "CORRUPT LOG RECORD FOUND" found |
| 25 |
Pattern "Log record type 0, page .*:.*. Log parsing proceeded successfully up to RECOVERED_LSN" found |
| 26 |
Pattern "Apply batch completed" not found |
| 27 |
Pattern "innodb-unknown-compound-v" not found |
| 28 |
############################################################################################ |
| 29 |
# Case 2. Verify that recovery could be re-executed from previous checkpoint and go further |
| 30 |
# after the corrupted log block is fixed. |
| 31 |
############################################################################################ |
| 32 |
# Fix the corrupted log record type... |
| 33 |
# Start MySQL... |
| 34 |
# Verify... |
| 35 |
Pattern "Database was not shutdown normally" found |
| 36 |
Pattern "Starting crash recovery" found |
| 37 |
Pattern "Applying a batch of.*redo log records" found |
| 38 |
Pattern "Apply batch completed" found |
| 39 |
Pattern "innodb-unknown-compound-v" found |
| 40 |
# Remove the data directory... |
| 41 |
############################################################################################ |
| 42 |
# Case 3. Check how recovery stops on log block with invalid checksum. |
| 43 |
############################################################################################ |
| 44 |
# Restore the data directory from before recovery... |
| 45 |
# Corrupt checksum... |
| 46 |
# Start MySQL... |
| 47 |
# Verify... |
| 48 |
Pattern "Log block CORRUPTED_LOG_BLOCK at lsn SCANNED_LSN has valid header, but checksum field contains .*, should be .*" found |
| 49 |
Pattern "Doing recovery: scanned up to log sequence number SCANNED_LSN" found |
| 50 |
Pattern "innodb-unknown-compound-v" not found |
| 51 |
############################################################################################ |
| 52 |
# Case 4. Check how recovery stops on log block with invalid block_no. |
| 53 |
############################################################################################ |
| 54 |
# Restore the data directory from before recovery... |
| 55 |
# Corrupt the block_no... |
| 56 |
# Start MySQL... |
| 57 |
# Verify... |
| 58 |
Pattern "Database was not shutdown normally" found |
| 59 |
Pattern "Starting crash recovery" found |
| 60 |
Pattern "Doing recovery: scanned up to log sequence number SCANNED_LSN" found |
| 61 |
Pattern "Applying a batch of.*redo log records" found |
| 62 |
Pattern "Apply batch completed" found |
| 63 |
Pattern "innodb-unknown-compound-v" not found |
| 64 |
############################################################################################ |
| 65 |
# Cleanup... |
| 66 |
# Start MySQL... |
| 67 |
# restart: |