Skip to content

Commit 6bfc35d

Browse files
author
Karolina Szczepankiewicz
committed
Bug#36312880 Gtid_tagged_log_event encodes incorrect value of original commit timestamp
Problem ------- When original commit timestamp is equal to immediate commit timestamp, Gtid_tagged_log_event will encode a correct value. Otherwise, Gtid_tagged_log_event will encode the value of immediate commit timestamp as original commit timestamp. Encoding condition is inverted. Solution -------- Fixed encoding condition. Change-Id: Icfe226913e75f3d75da394d24d6b33bc2188655b
1 parent 2bb7af1 commit 6bfc35d

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

libs/mysql/binlog/event/control_events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ class Gtid_event : public Binary_log_event,
11601160
mysql::serialization::define_field(immediate_commit_timestamp),
11611161
mysql::serialization::define_field(
11621162
original_commit_timestamp, Field_encode_predicate([this]() -> bool {
1163-
return this->original_commit_timestamp ==
1163+
return this->original_commit_timestamp !=
11641164
this->immediate_commit_timestamp;
11651165
})),
11661166
mysql::serialization::define_field(transaction_length),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
RESET BINARY LOGS AND GTIDS;
2+
3+
# T1.1 - T1.2
4+
5+
SET SESSION original_commit_timestamp = 1;
6+
SET GTID_NEXT= "11111111-1111-1111-1111-111111111111:tag:1";
7+
CREATE TABLE t1 (a INT);
8+
9+
# T1.3
10+
11+
include/rpl/save_binlog_file_position.inc
12+
include/assert_grep.inc [Check that original commit timestamp value equals 1]
13+
include/assert_grep.inc [Check that immediate commit timestamp differs from original commit timestamp]
14+
15+
# Clean up
16+
17+
SET SESSION original_commit_timestamp = DEFAULT;
18+
SET GTID_NEXT='AUTOMATIC';
19+
DROP TABLE t1;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# ==== PURPOSE ====
2+
#
3+
# This test validates encoding and decoding of the GTID_TAGGED_LOG_EVENT, in
4+
# particular, encoded value of original commit timestamp
5+
#
6+
# ==== REQUIREMENTS ====
7+
#
8+
# When original commit timestamp value differs from immediate commit timestamp,
9+
# the server shall encode original commit timestamp in the GTID_TAGGED_LOG_EVENT
10+
#
11+
# ==== IMPLEMENTATION ====
12+
#
13+
# T1.
14+
# Test steps:
15+
#
16+
# 1. Set up a custom original commit timestamp
17+
# 2. Execute transaction with a tagged GTID
18+
# 3. Check with mysqlbinlog that event has the required original commit
19+
# timestamp value
20+
#
21+
# Test pass conditions:
22+
# - Step 3
23+
#
24+
# ==== REFERENCES ====
25+
#
26+
# Bug#36312880 Gtid_tagged_log_event encodes incorrect value of original commit
27+
# timestamp
28+
#
29+
30+
# This test is independent from binlog format
31+
--source include/have_binlog_format_row.inc
32+
33+
RESET BINARY LOGS AND GTIDS;
34+
35+
--echo
36+
--echo # T1.1 - T1.2
37+
--echo
38+
39+
SET SESSION original_commit_timestamp = 1;
40+
41+
SET GTID_NEXT= "11111111-1111-1111-1111-111111111111:tag:1";
42+
CREATE TABLE t1 (a INT);
43+
44+
--echo
45+
--echo # T1.3
46+
--echo
47+
48+
--source include/rpl/save_binlog_file_position.inc
49+
--let $output_file=$MYSQLTEST_VARDIR/tmp/binlog_gtid_tagged_log_event_encoding.output
50+
--exec $MYSQL_BINLOG --force-if-open $binlog_fullpath > $output_file
51+
52+
--let $assert_text= Check that original commit timestamp value equals 1
53+
--let $assert_file = $output_file
54+
--let $assert_select = session.original_commit_timestamp=1\*
55+
--let $assert_count = 1
56+
--source include/assert_grep.inc
57+
58+
--let $assert_text= Check that immediate commit timestamp differs from original commit timestamp
59+
--let $assert_file = $output_file
60+
--let $assert_select = session.immediate_commit_timestamp=1\*
61+
--let $assert_count = 0
62+
--source include/assert_grep.inc
63+
64+
--echo
65+
--echo # Clean up
66+
--echo
67+
68+
SET SESSION original_commit_timestamp = DEFAULT;
69+
SET GTID_NEXT='AUTOMATIC';
70+
DROP TABLE t1;
71+
--remove_file $output_file

0 commit comments

Comments
 (0)