| 1 |
# WL#7742: test case that checks that the option |
| 2 |
# binlog_group_commit_sync_delay introduces a |
| 3 |
# delay in the group commit |
| 4 |
|
| 5 |
--source include/have_binlog_format_mixed.inc |
| 6 |
--source include/have_debug.inc |
| 7 |
|
| 8 |
--let $delay=1000000 |
| 9 |
--let $count=2 |
| 10 |
--let $delay_as_secs= `SELECT $delay / 1000000.0` |
| 11 |
|
| 12 |
--let $bgcd_saved=`SELECT @@GLOBAL.binlog_group_commit_sync_delay` |
| 13 |
--let $bgcc_saved=`SELECT @@GLOBAL.binlog_group_commit_sync_no_delay_count` |
| 14 |
|
| 15 |
CREATE TABLE t1 (c1 INT) Engine=InnoDB; |
| 16 |
CREATE TABLE t2 (c1 INT) Engine=InnoDB; |
| 17 |
|
| 18 |
--eval SET GLOBAL binlog_group_commit_sync_delay=$delay |
| 19 |
--eval SET GLOBAL binlog_group_commit_sync_no_delay_count=$count |
| 20 |
|
| 21 |
connect (con1, localhost, root,,); |
| 22 |
connect (con2, localhost, root,,); |
| 23 |
|
| 24 |
-- echo ######################## ASSERTION #1 ##################################### |
| 25 |
# assertion #1 : Make sure that even if group commit count is |
| 26 |
# set, if the timeout elapses the session gets |
| 27 |
# released. |
| 28 |
--connection con1 |
| 29 |
SET DEBUG_SYNC='bgc_after_flush_stage_before_sync_stage SIGNAL go_con2_to_flush WAIT_FOR go_con1_to_sync'; |
| 30 |
--echo ============== CON1: FLUSHed and REAPed the QUEUE Waiting for CON2 to get to the FLUSH stage ============ |
| 31 |
SET @clock_in = SYSDATE(); |
| 32 |
--send INSERT INTO t1 VALUES (1) |
| 33 |
|
| 34 |
--connection con2 |
| 35 |
SET DEBUG_SYNC='bgc_before_flush_stage SIGNAL go_con1_to_sync WAIT_FOR go_con2_to_flush'; |
| 36 |
SET DEBUG_SYNC='bgc_after_flush_stage_before_sync_stage WAIT_FOR go_con2_to_sync'; |
| 37 |
--echo ============== CON2: WILL FLUSH and REAP the QUEUE but only after CON1 has waited and signaled CON2 ============ |
| 38 |
SET @clock_in = SYSDATE(); |
| 39 |
--send INSERT INTO t2 VALUES (2) |
| 40 |
|
| 41 |
--connection con1 |
| 42 |
--reap |
| 43 |
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE()); |
| 44 |
|
| 45 |
--echo ============== CON1: signal CON2 to resume and go into SYNC stage ============ |
| 46 |
SET DEBUG_SYNC = "now SIGNAL go_con2_to_sync"; |
| 47 |
|
| 48 |
--let $assert_text="Assert that con1 statement took more than the delay set." |
| 49 |
--let $assert_cond= [SELECT @elapsed >= @@GLOBAL.binlog_group_commit_sync_delay] |
| 50 |
--source include/assert.inc |
| 51 |
|
| 52 |
--connection con2 |
| 53 |
--reap |
| 54 |
--echo ============== CON2: RESUMES ============ |
| 55 |
SET @elapsed = TIMESTAMPDIFF(MICROSECOND, @clock_in, SYSDATE()); |
| 56 |
|
| 57 |
--let $assert_text="Assert that con2 statement took more than the delay set." |
| 58 |
--let $assert_cond= [SELECT @elapsed >= @@GLOBAL.binlog_group_commit_sync_delay] |
| 59 |
--source include/assert.inc |
| 60 |
|
| 61 |
-- echo ######################## ASSERTION #2 ##################################### |
| 62 |
# assertion #2: Assert that if count is reached before the timeout elapses |
| 63 |
# then we get execution times lower than binlog_group_commit_sync_delay |
| 64 |
|
| 65 |
--connection con1 |
| 66 |
--let $saved_debug=`SELECT @@GLOBAL.DEBUG` |
| 67 |
SET GLOBAL DEBUG="d,bgc_set_infinite_delay"; |
| 68 |
--echo ============== CON1: enters wait_count_or_timeout waits for CON2 to enroll for the SYNC stage ============ |
| 69 |
SET DEBUG_SYNC='bgc_after_flush_stage_before_sync_stage WAIT_FOR go_con1_to_wait'; |
| 70 |
SET DEBUG_SYNC='bgc_wait_count_or_timeout SIGNAL go_con2_to_flush WAIT_FOR go_con1_resume_wait'; |
| 71 |
SET @clock_in = SYSDATE(); |
| 72 |
--send INSERT INTO t1 VALUES (1) |
| 73 |
|
| 74 |
--connection con2 |
| 75 |
--echo ============== CON2: signals CON1 that it has enrolled for the SYNC stage ============ |
| 76 |
SET DEBUG_SYNC='bgc_before_flush_stage SIGNAL go_con1_to_wait WAIT_FOR go_con2_to_flush'; |
| 77 |
SET DEBUG_SYNC='bgc_after_enrolling_for_sync_stage SIGNAL go_con1_resume_wait'; |
| 78 |
--send INSERT INTO t2 VALUES (2) |
| 79 |
|
| 80 |
--connection con1 |
| 81 |
--reap |
| 82 |
--eval SET GLOBAL DEBUG="$saved_debug"; |
| 83 |
# if we have reached this point, the server did not wait ad eternum |
| 84 |
# thus the test succeeds |
| 85 |
|
| 86 |
--connection con2 |
| 87 |
--reap |
| 88 |
|
| 89 |
--connection con1 |
| 90 |
--disconnect con1 |
| 91 |
--disconnect con2 |
| 92 |
|
| 93 |
--connection default |
| 94 |
|
| 95 |
--eval SET GLOBAL binlog_group_commit_sync_no_delay_count=$bgcc_saved |
| 96 |
--eval SET GLOBAL binlog_group_commit_sync_delay=$bgcd_saved |
| 97 |
|
| 98 |
DROP TABLE t1, t2; |