Skip to content

Commit a543141

Browse files
author
Sven Sandberg
committed
WL#7083 step 5.2. Anonymous transactions: User-visible changes and tests for ANONYMOUS_TRANSACTION_COUNT.
@sql/mysqld.cc - Introduce status variable ANONYMOUS_TRANSACTION_COUNT. @sql/rpl_gtid_execution.cc - Assert that global counter is positive when thread holds anonymous ownership. @sql/sys_vars.h - Make @@SESSION.GTID_OWNED contain "ANONYMOUS" when thread holds anonymous ownership. - Generate error when changing gtid_mode to ON if there are ongoing anonymous transactions. - Generate error when changing gtid_mode to OFF if there are ongoing GTID-transactions. @mysql-test/include/execute_at_sync_point.inc - Split this into two files: execute_to_sync_point.inc and execute_from_sync_point.inc @mysql-test/suite/binlog/t/binlog_anonymous_ownership.test - New test case to test anonymous ownership. @sql/sql_parse.cc - New sync point used by binlog_anonymous_ownership.test. @mysql-test/suite/binlog/t/binlog_gtid_next_anonymous_implicit_commit.test - This tiny test is now one of the cases tested in binlog_anonymous_ownership.test, hence we can remove this file.
1 parent 780c635 commit a543141

12 files changed

+973
-130
lines changed

mysql-test/include/execute_at_sync_point.inc

Lines changed: 45 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -4,123 +4,84 @@
44
# point: pause, execute another statement on another connection, and
55
# unpause.
66
#
7+
# See also: execute_to_sync_point.inc, execute_from_sync_point.inc
8+
#
79
# ==== Usage ====
810
#
9-
# [--let $main_connection= CONNECTION_NAME]
10-
# --let $main_statement= STATEMENT
11-
# --let $middle_connection= CONNECTION_NAME
12-
# --let $middle_statement= STATEMENT
11+
# --let $statement_connection= CONNECTION_NAME
12+
# --let $statement= STATEMENT
13+
# --let $other_statement= STATEMENT
1314
# --let $sync_point= SYNC_POINT_NAME
15+
# [--let $auxiliary_connection= CONNECTION_NAME]
1416
# [--let $quiet= [0|1|2]]
1517
# [--let $sync_point_timeout= N]
1618
# --source include/execute_statement_at_sync_point.inc
1719
#
1820
# Parameters:
1921
#
20-
# $main_connection
21-
# The connection on which the "main" statement is to be executed.
22-
# If this is not specified, uses the current connection.
22+
# $statement_connection
23+
# The connection on which $statement is to be executed.
24+
# This must be different from $auxiliary_connection.
2325
#
24-
# $main_statement
26+
# $statement
2527
# The statement that will be paused on the sync point.
2628
#
27-
# $middle_connection
28-
# The connection on which the "interluding" statement is to be
29-
# executed while the main statement is paused on the sync point.
30-
#
31-
# $middle_statement
32-
# The statement that will be executed on $middle_connection while
33-
# $main_statement is paused on the sync point.
29+
# $auxiliary_statement
30+
# The statement that will be executed on the current connection while
31+
# $statement is paused on the sync point.
3432
#
3533
# $sync_point
3634
# The name of the sync point (not quoted).
3735
#
36+
# $auxiliary_connection
37+
# By default, $auxiliary_statement, as well as some SET DEBUG
38+
# statements, are executed on the current connection. If this
39+
# variable is not empty, uses $auxiliary_connection instead.
40+
#
3841
# $quiet
3942
# By default (or if $quiet==0), the following is echoed to the log:
40-
# START $main_statement;
41-
# $middle_statement;
42-
# END $main_statement;
43+
# START $statement;
44+
# $other_statement;
45+
# result of other statement
46+
# END $statement;
4347
# If you set $quiet=1, the START and END lines are still there,
44-
# but from the middle statement only the result is echoed.
48+
# but from the other statement only the result is echoed.
4549
# If you set $quiet=2, all output is suppressed.
4650
#
4751
# $sync_point_timeout
48-
# Both the main connection and the middle connection will be
49-
# waiting for a signal. By default, the wait has a timeout
52+
# Both the $statement_connection and the current connection will
53+
# be waiting for a signal. By default, the wait has a timeout
5054
# specified by --debug-sync-timeout=N. You can set
5155
# $sync_point_timeout to use a different timeout. The unit is
5256
# seconds.
57+
#
58+
# $skip_reap
59+
# By default, the script will wait for $statement to ACK to the
60+
# client (reap). Set $skip_reap to prevent that from happening.
61+
# The caller then has the execute reap manually.
5362

54-
--let $_easp_query_log_enabled= $ENABLED_QUERY_LOG
55-
--disable_query_log
63+
--let $include_silent= 1
64+
--let $include_filename= execute_at_sync_point.inc
65+
--source include/begin_include_file.inc
66+
--let $include_silent= 0
5667

57-
# Configure.
58-
--let $_easp_previous_connection = $CURRENT_CONNECTION
5968

60-
--let $_easp_main_connection= $main_connection
61-
if ($main_connection == '')
62-
{
63-
--let $_easp_main_connection= $CURRENT_CONNECTION
64-
}
69+
--source include/execute_to_sync_point.inc
6570

66-
--let $_easp_timeout=
67-
if ($sync_point_timeout)
71+
# execute other statement
72+
if (!$quiet)
6873
{
69-
--let $_easp_timeout= TIMEOUT $sync_point_timeout
74+
--echo $other_statement
7075
}
71-
72-
--let $_easp_quiet= $quiet
73-
if ($quiet == '')
74-
{
75-
--let $_easp_quiet= 0
76-
}
77-
78-
# Begin waiting for signal on middle connection.
79-
--connection $middle_connection
80-
--send
81-
eval SET @@SESSION.DEBUG_SYNC = 'now WAIT_FOR _easp_parked $_easp_timeout';
82-
83-
# Setup sync point and begin execute main statement.
84-
--connection $_easp_main_connection
85-
eval SET @@SESSION.DEBUG_SYNC = '$sync_point SIGNAL _easp_parked WAIT_FOR _easp_go $_easp_timeout';
86-
87-
if ($_easp_quiet < 2)
76+
--connection $_esp_auxiliary_connection
77+
--let $result= `$other_statement`
78+
if ($quiet != 2)
8879
{
89-
--echo [START] $main_statement;
80+
--echo $result
9081
}
91-
--send
92-
eval $main_statement;
9382

94-
# Finish waiting for signal on middle connection, execute middle
95-
# statement, tell main statement to continue.
96-
--connection $middle_connection
97-
reap;
98-
if ($_easp_quiet == 0)
99-
{
100-
--echo $middle_statement;
101-
}
102-
if ($_easp_quiet == 1)
103-
{
104-
--let $_easp_result= `$middle_statement`
105-
--echo $_easp_result
106-
}
107-
if ($_easp_quiet != 1)
108-
{
109-
eval $middle_statement;
110-
}
111-
SET @@SESSION.DEBUG_SYNC = 'now SIGNAL _easp_go';
83+
--source include/execute_from_sync_point.inc
11284

113-
# Wait for main statement to finish.
114-
if ($_easp_quiet < 2)
115-
{
116-
--echo [END] $main_statement;
117-
}
118-
--connection $_easp_main_connection
119-
reap;
12085

121-
# Restore state
122-
--connection $_easp_previous_connection
123-
if ($_easp_query_log_enabled)
124-
{
125-
--enable_query_log
126-
}
86+
--let $include_filename= execute_at_sync_point.inc
87+
--source include/end_include_file.inc
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# ==== Purpose ====
2+
#
3+
# Finish a sync-point wait that was previously started by
4+
# execute_to_sync_point.inc
5+
#
6+
# See also: execute_to_sync_point.inc, execute_at_sync_point.inc
7+
#
8+
# ==== Usage ====
9+
#
10+
# --let $statement_connection= CONNECTION_NAME
11+
# --let $statement= STATEMENT
12+
# --let $sync_point= SYNC_POINT_NAME
13+
# [--let $quiet= [0|2]]
14+
# --source include/execute_statement_at_sync_point.inc
15+
#
16+
# Parameters:
17+
# See execute_at_sync_point.inc
18+
19+
20+
--let $include_silent= 1
21+
--let $include_filename= execute_at_sync_point.inc
22+
--source include/begin_include_file.inc
23+
--let $include_silent= 0
24+
25+
# Sanity check.
26+
if ($statement_connection == '')
27+
{
28+
--die !!!ERROR IN TEST: set $statement_connection
29+
}
30+
--let $_esp_auxiliary_connection= $CURRENT_CONNECTION
31+
if ($auxiliary_connection != '')
32+
{
33+
--let $_esp_auxiliary_connection= $auxiliary_connection
34+
}
35+
if ($statement_connection == $_esp_auxiliary_connection)
36+
{
37+
--die !!!ERROR IN TEST: set $statement_connection to something else than $auxiliary_connection
38+
}
39+
if ($statement == '')
40+
{
41+
--die !!!ERROR IN TEST: set $statement
42+
}
43+
if ($sync_point == '')
44+
{
45+
--die !!!ERROR IN TEST: set $sync_point
46+
}
47+
48+
if (!$rpl_debug)
49+
{
50+
--disable_query_log
51+
}
52+
53+
# Tell statement to continue on auxiliary connection.
54+
--connection $auxiliary_connection
55+
eval SET @@SESSION.DEBUG_SYNC = 'now SIGNAL _esp_go_$sync_point$underscore$statement_connection';
56+
57+
# Wait for statement to finish.
58+
if ($_esp_quiet != 2)
59+
{
60+
--echo [END] $statement;
61+
}
62+
--connection $statement_connection
63+
if (!$skip_reap)
64+
{
65+
reap;
66+
}
67+
--connection $auxiliary_connection
68+
69+
--let $include_filename= execute_at_sync_point.inc
70+
--source include/end_include_file.inc
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# ==== Purpose ====
2+
#
3+
# Begin to execute a statement, stop at a given sync point.
4+
#
5+
# See also: execute_from_sync_point.inc, execute_at_sync_point.inc
6+
#
7+
# ==== Usage ====
8+
#
9+
# --let $statement_connection= CONNECTION_NAME
10+
# --let $statement= STATEMENT
11+
# --let $sync_point= SYNC_POINT_NAME
12+
# [--let $quiet= [0|2]]
13+
# [--let $sync_point_timeout= N]
14+
# --source include/execute_statement_at_sync_point.inc
15+
#
16+
# Parameters:
17+
# See execute_at_sync_point.inc.
18+
19+
--let $include_silent= 1
20+
--let $include_filename= execute_at_sync_point.inc
21+
--source include/begin_include_file.inc
22+
--let $include_silent= 0
23+
24+
if (!$rpl_debug)
25+
{
26+
--disable_query_log
27+
}
28+
29+
# Sanity check.
30+
if ($statement_connection == '')
31+
{
32+
--die !!!ERROR IN TEST: set $statement_connection
33+
}
34+
--let $_esp_auxiliary_connection= $CURRENT_CONNECTION
35+
if ($auxiliary_connection != '')
36+
{
37+
--let $_esp_auxiliary_connection= $auxiliary_connection
38+
}
39+
if ($statement_connection == $_esp_auxiliary_connection)
40+
{
41+
--echo statement_connection=$statement_connection
42+
--echo auxiliary_connection=$_esp_auxiliary_connection
43+
--die !!!ERROR IN TEST: set $statement_connection to something else than $auxiliary_connection
44+
}
45+
if ($statement == '')
46+
{
47+
--die !!!ERROR IN TEST: set $statement
48+
}
49+
if ($sync_point == '')
50+
{
51+
--die !!!ERROR IN TEST: set $sync_point
52+
}
53+
54+
--let $_esp_timeout=
55+
if ($sync_point_timeout)
56+
{
57+
--let $_esp_timeout= TIMEOUT $sync_point_timeout
58+
}
59+
60+
# On $statement_connection, setup sync point and begin execute statement.
61+
--connection $statement_connection
62+
eval SET @@SESSION.DEBUG_SYNC = '$sync_point SIGNAL _esp_parked_$sync_point$underscore$statement_connection WAIT_FOR _esp_go_$sync_point$underscore$statement_connection $_esp_timeout';
63+
64+
if ($quiet != 2)
65+
{
66+
--echo [START] $statement;
67+
}
68+
69+
--send
70+
eval $statement;
71+
72+
# On auxiliary connection, begin waiting for statement to reach the sync point.
73+
--connection $_esp_auxiliary_connection
74+
eval SET @@SESSION.DEBUG_SYNC = 'now WAIT_FOR _esp_parked_$sync_point$underscore$statement_connection $_esp_timeout';
75+
76+
--let $skip_restore_connection= 1
77+
--let $include_filename= execute_at_sync_point.inc
78+
--source include/end_include_file.inc

0 commit comments

Comments
 (0)