| 1 |
SELECT @@innodb_redo_log_capacity INTO @orig_redo_log_capacity; |
| 2 |
SELECT @@innodb_flush_log_at_trx_commit INTO @orig_flush_log_at_trx_commit; |
| 3 |
SET GLOBAL innodb_flush_log_at_trx_commit = 0; |
| 4 |
# Prepare schema used in the tests. |
| 5 |
CREATE TABLE t (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 6 |
INSERT INTO t(a,b) VALUES (1,0); |
| 7 |
# Disable page cleaners and prevent page flushing/checkpointing. |
| 8 |
SET GLOBAL innodb_dict_stats_disabled_debug = 1; |
| 9 |
SET GLOBAL innodb_master_thread_disabled_debug = 1; |
| 10 |
SET GLOBAL debug = "+d,disable_se_persists_gtid"; |
| 11 |
FLUSH ENGINE LOGS; |
| 12 |
SET GLOBAL debug = "+d,gtid_persist_flush_disable"; |
| 13 |
SET GLOBAL innodb_log_checkpoint_now = 1; |
| 14 |
SET GLOBAL innodb_page_cleaner_disabled_debug = 1; |
| 15 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 16 |
SET GLOBAL innodb_purge_stop_now = 1; |
| 17 |
# Skip log free checks to fill redo log up to its very end. |
| 18 |
SET GLOBAL DEBUG = '+d,log_free_check_skip'; |
| 19 |
# Request the log writer to generate a signal when it enters the extra_margin. |
| 20 |
SET GLOBAL DEBUG = '+d,syncpoint_log_writer_entered_extra_margin'; |
| 21 |
# Fill redo log until the log writer enters the extra_margin... |
| 22 |
CALL log_spammer(); |
| 23 |
# Redo log data is being generated... |
| 24 |
# Wait until the log_writer signaled that it entered the extra margin. |
| 25 |
SET DEBUG_SYNC = 'now WAIT_FOR reached_log_writer_entered_extra_margin'; |
| 26 |
# Log writer entered the extra margin ! |
| 27 |
Pattern "\[Warning\] \[[^]]*\] \[[^]]*\] Redo log is running out of free space, pausing user threads" found |
| 28 |
SET GLOBAL innodb_flush_log_at_trx_commit = 2; |
| 29 |
# Request the log_writer to generate a signal when it runs out of free space in the extra_margin. |
| 30 |
SET GLOBAL DEBUG = '+d,syncpoint_log_writer_ran_out_space'; |
| 31 |
# Let the log writer continue, and wait until it runs out of free space in the extra_margin. |
| 32 |
SET GLOBAL DEBUG = '-d,syncpoint_log_writer_entered_extra_margin'; |
| 33 |
SET DEBUG_SYNC = 'now SIGNAL continue_log_writer_entered_extra_margin WAIT_FOR reached_log_writer_ran_out_space'; |
| 34 |
# Log writer ran out of free space ! |
| 35 |
Pattern "\[ERROR\] \[[^]]*\] \[[^]]*\] Out of space in the redo log. Checkpoint LSN:" found |
| 36 |
# Let log writer continue to try... It cannot succeed without checkpoint being advanced. |
| 37 |
SET GLOBAL DEBUG = '-d,syncpoint_log_writer_ran_out_space'; |
| 38 |
SET DEBUG_SYNC = 'now SIGNAL continue_log_writer_ran_out_space'; |
| 39 |
SET GLOBAL innodb_flush_log_at_trx_commit = 1; |
| 40 |
# Start a DML query which should be hanging on trx_commit_complete_for_mysql... |
| 41 |
UPDATE t SET b=1 WHERE a=1; |
| 42 |
# Wait until UPDATE becomes visible in information_schema.processlist... |
| 43 |
# Sleep for 1s to validate it is still there (not yet completed). |
| 44 |
# Ensure the DML has not been completed (no redo space)... |
| 45 |
include/assert.inc ['The UPDATE is still not finished'] |
| 46 |
# Assume that after resizing up we will be more lucky, not to hit the same issue again |
| 47 |
# but at higher redo log size, so let's resume log_free_check() (else: we could quickly |
| 48 |
# eat the whole extended space and remain in deadlock) |
| 49 |
SET GLOBAL DEBUG = '-d,log_free_check_skip'; |
| 50 |
# Resize-up redo log a little bit to ensure it will be filled again. |
| 51 |
SET GLOBAL innodb_redo_log_capacity = @@innodb_redo_log_capacity + 1048576; |
| 52 |
# Ensure the log writer has still NOT exited the extra margin. |
| 53 |
Pattern "\[Note\] \[[^]]*\] \[[^]]*\] Redo log reclaimed some free space, resuming user threads" not found |
| 54 |
# Request the log writer to generate a signal when it exits the extra_margin. |
| 55 |
SET GLOBAL DEBUG = '+d,syncpoint_log_writer_exited_extra_margin'; |
| 56 |
############################### |
| 57 |
# Enable page cleaners. |
| 58 |
############################### |
| 59 |
SET GLOBAL debug = "-d,gtid_persist_flush_disable"; |
| 60 |
SET GLOBAL debug = "-d,disable_se_persists_gtid"; |
| 61 |
SET GLOBAL innodb_dict_stats_disabled_debug = 0; |
| 62 |
SET GLOBAL innodb_master_thread_disabled_debug = 0; |
| 63 |
SET GLOBAL innodb_page_cleaner_disabled_debug = 0; |
| 64 |
SET GLOBAL innodb_checkpoint_disabled = 0; |
| 65 |
SET GLOBAL innodb_purge_stop_now = 0; |
| 66 |
SET GLOBAL innodb_purge_run_now = 1; |
| 67 |
# Ensure the started DML becomes completed eventually. |
| 68 |
include/assert.inc ['The UPDATE has been completed'] |
| 69 |
# Request the spammer to stop, but do not wait because earlier the log_writer/log_checkpointer |
| 70 |
# can be trapped at log_writer_exited_extra_margin |
| 71 |
UPDATE log_spam_controller SET status = 'Stopping' WHERE id = 1; |
| 72 |
# Wait until the log_writer signaled that it exited the extra margin. |
| 73 |
SET DEBUG_SYNC = 'now WAIT_FOR reached_log_writer_exited_extra_margin'; |
| 74 |
SET GLOBAL DEBUG = '-d,syncpoint_log_writer_exited_extra_margin'; |
| 75 |
SET DEBUG_SYNC = 'now SIGNAL continue_log_writer_exited_extra_margin'; |
| 76 |
# Ensure the log writer has exited the extra margin. |
| 77 |
Pattern "\[Note\] \[[^]]*\] \[[^]]*\] Redo log reclaimed some free space, resuming user threads" found |
| 78 |
# Wait until the request to stop spammer is completed. |
| 79 |
# Wait until the spammer is stopped. |
| 80 |
include/assert.inc ['The log spammer is stopped'] |
| 81 |
# Ensure new changes can be done quickly too. |
| 82 |
UPDATE t SET b=2 WHERE a=1; |
| 83 |
SELECT * FROM t; |
| 84 |
a b |
| 85 |
1 2 |
| 86 |
# Resize the redo log to its original capacity. |
| 87 |
SET GLOBAL innodb_redo_log_capacity = @orig_redo_log_capacity; |
| 88 |
# Waiting for status = OK.... |
| 89 |
# Cleanup |
| 90 |
DROP TABLE t; |
| 91 |
SET GLOBAL innodb_flush_log_at_trx_commit = @orig_flush_log_at_trx_commit; |
| 92 |
SET DEBUG_SYNC = 'RESET'; |