Debian Codegraph @

mysql-test/suite/binlog_gtid/t/binlog_group_commit_gtid_order.test

raw
1 # ==== Purpose ====
2 #
3 # This test will evaluate if a set of transactions being applied as
4 # a group will apply their GTIDs in order, avoiding temporary creation
5 # of gaps in gtid_executed.
6 #
7 # The test pause two inserts in the same commit group, letting the
8 # second insert (greater GTID number) to finish first.
9 #
10 # The test also assert that the gtid_executed::free_intervals_mutex
11 # is not used as no gap was generated in gtid_executed.
12 #
13 # ==== Related Bugs and Worklogs ====
14 #
15 # BUG#19982543 SERIOUS TPS DECLINE IF GTID IS ENABLED IN 5.7
16 #
17
18 --source include/have_binlog_format_mixed.inc
19 --source include/have_binlog_order_commits.test
20 --source include/have_debug.inc
21 --source include/have_debug_sync.inc
22
23 RESET MASTER;
24 # Disable background GTID task to get uniform result.
25 SET @@GLOBAL.DEBUG= '+d, disable_gtid_background_persister';
26 --let $master_uuid=`SELECT @@GLOBAL.server_uuid`
27
28 # Group commit parameters
29 --let $delay=1000000
30 --let $bgcd_saved=`SELECT @@GLOBAL.binlog_group_commit_sync_delay`
31
32 # Create two tables, one for each connection
33 CREATE TABLE t1 (c1 INT) Engine=InnoDB;
34 CREATE TABLE t2 (c1 INT) Engine=InnoDB;
35
36 # Get the current counter for gtid_executed::free_intervals_mutex
37 SET @free_intervals_mutex_before= (
38 SELECT COUNT_STAR
39 FROM performance_schema.events_waits_summary_global_by_event_name WHERE
40 EVENT_NAME='wait/synch/mutex/sql/Gtid_set::gtid_executed::free_intervals_mutex');
41
42 # Set group commit parameters
43 --eval SET GLOBAL binlog_group_commit_sync_delay=$delay
44
45 --echo # Create two new connections: con1 and con2
46 --connect (con1, localhost, root,,)
47 --connect (con2, localhost, root,,)
48
49 --echo # At con1
50 --connection con1
51 SET DEBUG_SYNC='reached_finish_commit SIGNAL go_con2 WAIT_FOR go_con1';
52
53 # The following INSERT will be the group commit leader.
54 # Once reaching the 'reached_finish_commit' debug sync point, it will
55 # allow con2 to proceed with other INSERT to be part of the commit group
56 # and will wait for a signal to continue with its own finish_commit.
57 --send INSERT INTO t1 VALUES (1)
58 # The above INSERT will be MASTER_UUID:3
59
60 --echo # At con2
61 --connection con2
62 # The following session debug point will tell con2 that it has done with its
63 # finish_commit.
64 --let $debug_point= leaving_finish_commit
65 --let $debug_type= SESSION
66 --source include/add_debug_point.inc
67
68 # Wait for the INSERT at con1 to be the group leader.
69 SET DEBUG_SYNC='now WAIT_FOR go_con2';
70
71 # The following INSERT is not the group commit leader.
72 INSERT INTO t2 VALUES (2);
73 # The above INSERT will be MASTER_UUID:4
74
75 # In a non-fixed server, the GTIDs of transactions committed in group were
76 # added to gtid_executed at finish_commit by each thread.
77 # So, we wait for the current connection to finish its commit before letting
78 # the commit group leader go.
79 SET DEBUG_SYNC='now WAIT_FOR signal_leaving_finish_commit';
80
81 # We collect the gtid_executed now. A non-fixed server would have the GTID
82 # of the con2 INSERT but wouldn't have the GTID of the con1 INSERT.
83 # A fixed server will have both GTIDs in the gtid_executed, as the GTIDs of
84 # a commit group are now added to the gtid_executed set while processing the
85 # commit group queue (in order), and not at finish_commit.
86 --let $gtid_executed_after_second_insert=`SELECT @@GLOBAL.gtid_executed`
87
88 # Let the commit group leader to finish its commit now.
89 SET DEBUG_SYNC='now SIGNAL go_con1';
90 --source include/remove_debug_point.inc
91
92 --echo # At default connection
93 --connection default
94 # Ensure that the GTID of the commit group leader is at gtid_executed
95 # before continuing.
96 --let $wait_succeeded= `SELECT WAIT_FOR_EXECUTED_GTID_SET('$master_uuid:3')`
97
98 # Assert that the WAIT_FOR_EXECUTED_GTID_SET above didn't timed out.
99 --let $assert_text= "The first insert has finished"
100 --let $assert_cond= "$wait_succeeded" = 0
101 --source include/assert.inc
102
103 # Assert that no gaps were found after the second insert finished.
104 --let $current_gtid_executed=`SELECT @@GLOBAL.gtid_executed`
105 --let $assert_text= "No gaps should exist in gtid_executed after the second insert"
106 --let $assert_cond= "$gtid_executed_after_second_insert" = "$current_gtid_executed"
107 --source include/assert.inc
108
109 # Assert that free_intervals_mutex wasn't used (no gaps were produced).
110 SET @free_intervals_mutex_after= (
111 SELECT COUNT_STAR
112 FROM performance_schema.events_waits_summary_global_by_event_name WHERE
113 EVENT_NAME='wait/synch/mutex/sql/Gtid_set::gtid_executed::free_intervals_mutex');
114 --let $assert_text= "gtid_executed::free_intervals_mutex wasn't used"
115 --let $assert_cond= @free_intervals_mutex_before = @free_intervals_mutex_after
116 --source include/assert.inc
117
118 # Cleanup
119 --disconnect con1
120 --disconnect con2
121
122 --connection default
123 --eval SET GLOBAL binlog_group_commit_sync_delay=$bgcd_saved
124 SET @@GLOBAL.DEBUG= '-d, disable_gtid_background_persister';
125
126 DROP TABLE t1, t2;
127 RESET MASTER;