Skip to content

Commit 32ab34c

Browse files
PS-10007 feature: Implemented support for MySQL Server 8.4 series
https://perconadev.atlassian.net/browse/PS-10007 Added support for binary log events generated by MySQL Server 8.4 LTS. In particular: * 'GTID TAGGED' binlog event (which is specific to 8.4 series) is now recognized and handled properly by the parser. * Internal event class representing 'FORMAT DESCRIPTION' binlog event can now handle both 8.0 and 8.4 data. In particular in 8.4, the size of the 'common_header_length' array is increased by 1 because of the additional 'GTID TAGGED'. 'binsrv::event::reader_context' class constructor now takes one more parameter 'encoded_server_version' in order to be aware of 8.0/8.4 differences. The value that is passeed as this 'encoded_server_version' argument is extracted from the 'easymysql::connection' object. Added 'binsrv::event::server_version' class that helps parse / compose MySQL Server version strings in the '<major>.<minor>.<patch>-<extra>' format. Generalized MTR test cases so that they can be run on both 8.0 and 8.4 MySQL Servers. Reference links updated to point to the 'mysql-8.0.43' code. Added reference links to the 'mysql-8.4.6' code.
1 parent 31cac57 commit 32ab34c

27 files changed

Lines changed: 484 additions & 97 deletions

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ set(source_files
143143
src/binsrv/event/rotate_post_header_impl.hpp
144144
src/binsrv/event/rotate_post_header_impl.cpp
145145

146+
src/binsrv/event/server_version_fwd.hpp
147+
src/binsrv/event/server_version.hpp
148+
src/binsrv/event/server_version.cpp
149+
146150
src/binsrv/event/stop_body_impl_fwd.hpp
147151
src/binsrv/event/stop_body_impl.hpp
148152

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--let $lts_series = unknown
2+
if (`SELECT VERSION() LIKE '8.0%'`)
3+
{
4+
--let $lts_series = v80
5+
}
6+
if (`SELECT VERSION() LIKE '8.4%'`)
7+
{
8+
--let $lts_series = v84
9+
}
10+
11+
if ($lts_series == unknown)
12+
{
13+
--die unsupported MySQL Server version
14+
}
15+
if ($lts_series == v80)
16+
{
17+
--let $stmt_reset_binary_logs_and_gtids = RESET MASTER
18+
--let $stmt_show_binary_log_status = SHOW MASTER STATUS
19+
}
20+
if ($lts_series == v84)
21+
{
22+
--let $stmt_reset_binary_logs_and_gtids = RESET BINARY LOGS AND GTIDS
23+
--let $stmt_show_binary_log_status = SHOW BINARY LOG STATUS
24+
}

mtr/binlog_streaming/r/binsrv.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*** Resetting replication at the very beginning of the test.
2-
RESET MASTER;
32

43
*** Determining the first fresh binary log name.
54

mtr/binlog_streaming/r/pull_mode.result

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*** Resetting replication at the very beginning of the test.
2-
RESET MASTER;
32

43
*** Generating a configuration file in JSON format for the Binlog
54
*** Server utility.

mtr/binlog_streaming/t/binsrv.test

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ if (!$BINSRV) {
44
--skip \$BINSRV environment variable must be set
55
}
66

7+
--source ../include/v80_v84_compatibility_defines.inc
8+
79
# in case of --repeat=N, we need to start from a fresh binary log to make
810
# this test deterministic
911
--echo *** Resetting replication at the very beginning of the test.
10-
RESET MASTER;
12+
--disable_query_log
13+
eval $stmt_reset_binary_logs_and_gtids;
14+
--enable_query_log
1115

1216
--echo
1317
--echo *** Determining the first fresh binary log name.
14-
--let $first_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
18+
--let $first_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
1519

1620
--echo
1721
--echo *** Creating a simple table and filling it with some data.
@@ -24,7 +28,7 @@ FLUSH BINARY LOGS;
2428

2529
--echo
2630
--echo *** Determining the second binary log name.
27-
--let $second_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
31+
--let $second_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
2832

2933
--echo
3034
--echo *** Filling the table with some more data.

mtr/binlog_streaming/t/pull_mode.test

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ if (!$BINSRV) {
44
--skip \$BINSRV environment variable must be set
55
}
66

7+
--source ../include/v80_v84_compatibility_defines.inc
8+
79
--source include/count_sessions.inc
810

911
# in case of --repeat=N, we need to start from a fresh binary log to make
1012
# this test deterministic
1113
--echo *** Resetting replication at the very beginning of the test.
12-
RESET MASTER;
14+
--disable_query_log
15+
eval $stmt_reset_binary_logs_and_gtids;
16+
--enable_query_log
1317

1418
# identifying backend storage type ('file' or 's3')
1519
--source ../include/identify_storage_backend.inc
@@ -39,7 +43,7 @@ EOF
3943

4044
--echo
4145
--echo *** Determining the first fresh binary log name.
42-
--let $first_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
46+
--let $first_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
4347

4448
--echo
4549
--echo *** Creating a simple table and filling it with some data.
@@ -57,7 +61,7 @@ INSERT INTO t1 VALUES(DEFAULT);
5761

5862
--echo
5963
--echo *** Determining the second binary log name.
60-
--let $second_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
64+
--let $second_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
6165

6266
--echo
6367
--echo *** Filling the table with some more data.
@@ -74,7 +78,7 @@ INSERT INTO t1 VALUES(DEFAULT);
7478

7579
--echo
7680
--echo *** Determining the third binary log name.
77-
--let $third_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
81+
--let $third_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
7882

7983
--echo
8084
--echo *** Filling the table with some more data again and dropping the table.
@@ -88,7 +92,7 @@ FLUSH BINARY LOGS;
8892

8993
--echo
9094
--echo *** Determining the fourth binary log name.
91-
--let $fourth_binlog = query_get_value(SHOW MASTER STATUS, File, 1)
95+
--let $fourth_binlog = query_get_value($stmt_show_binary_log_status, File, 1)
9296

9397
--echo
9498
--echo *** Waiting till Binlog Server Utility starts processing the fourth

src/app.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ void receive_binlog_events(
302302
// @source_binlog_checksum variable that we set in the
303303
// 'connection::switch_to_replication()'
304304
binsrv::event::reader_context context{
305+
connection.get_server_version(),
305306
binsrv::event::checksum_algorithm_type::off};
306307

307308
// if binlog is still open, there is no sense to close it and re-open

src/binsrv/event/checksum_algorithm_type.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace binsrv::event {
2727

2828
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
2929
// Checksum algorithm type codes copied from
30-
// https://github.com/mysql/mysql-server/blob/mysql-8.0.37/libbinlogevents/include/binlog_event.h#L426
30+
// https://github.com/mysql/mysql-server/blob/mysql-8.0.43/libbinlogevents/include/binlog_event.h#L440
31+
// https://github.com/mysql/mysql-server/blob/mysql-8.4.6/libs/mysql/binlog/event/binlog_event.h#L462
3132
// clang-format off
3233
#define BINSRV_CHECKSUM_ALGORITHM_TYPE_XY_SEQUENCE() \
3334
BINSRV_CHECKSUM_ALGORITHM_TYPE_XY_MACRO(off , 0), \

src/binsrv/event/code_type.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace binsrv::event {
2727

2828
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
2929
// Event type codes copied from
30-
// https://github.com/mysql/mysql-server/blob/mysql-8.0.37/libbinlogevents/include/binlog_event.h#L275
30+
// https://github.com/mysql/mysql-server/blob/mysql-8.0.43/libbinlogevents/include/binlog_event.h#L275
31+
// https://github.com/mysql/mysql-server/blob/mysql-8.4.6/libs/mysql/binlog/event/binlog_event.h#L286
3132
// clang-format off
3233
#define BINSRV_EVENT_CODE_TYPE_XY_SEQUENCE() \
3334
BINSRV_EVENT_CODE_TYPE_XY_MACRO(unknown , 0), \
@@ -36,16 +37,23 @@ namespace binsrv::event {
3637
BINSRV_EVENT_CODE_TYPE_XY_MACRO(stop , 3), \
3738
BINSRV_EVENT_CODE_TYPE_XY_MACRO(rotate , 4), \
3839
BINSRV_EVENT_CODE_TYPE_XY_MACRO(intvar , 5), \
40+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_6 , 6), \
3941
BINSRV_EVENT_CODE_TYPE_XY_MACRO(slave , 7), \
42+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_8 , 8), \
4043
BINSRV_EVENT_CODE_TYPE_XY_MACRO(append_block , 9), \
44+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_10 , 10), \
4145
BINSRV_EVENT_CODE_TYPE_XY_MACRO(delete_file , 11), \
46+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_12 , 12), \
4247
BINSRV_EVENT_CODE_TYPE_XY_MACRO(rand , 13), \
4348
BINSRV_EVENT_CODE_TYPE_XY_MACRO(user_var , 14), \
4449
BINSRV_EVENT_CODE_TYPE_XY_MACRO(format_description , 15), \
4550
BINSRV_EVENT_CODE_TYPE_XY_MACRO(xid , 16), \
4651
BINSRV_EVENT_CODE_TYPE_XY_MACRO(begin_load_query , 17), \
4752
BINSRV_EVENT_CODE_TYPE_XY_MACRO(execute_load_query , 18), \
4853
BINSRV_EVENT_CODE_TYPE_XY_MACRO(table_map , 19), \
54+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_20 , 20), \
55+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_21 , 21), \
56+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(obsolete_22 , 22), \
4957
BINSRV_EVENT_CODE_TYPE_XY_MACRO(write_rows_v1 , 23), \
5058
BINSRV_EVENT_CODE_TYPE_XY_MACRO(update_rows_v1 , 24), \
5159
BINSRV_EVENT_CODE_TYPE_XY_MACRO(delete_rows_v1 , 25), \
@@ -64,7 +72,8 @@ namespace binsrv::event {
6472
BINSRV_EVENT_CODE_TYPE_XY_MACRO(xa_prepare_log , 38), \
6573
BINSRV_EVENT_CODE_TYPE_XY_MACRO(partial_update_rows, 39), \
6674
BINSRV_EVENT_CODE_TYPE_XY_MACRO(transaction_payload, 40), \
67-
BINSRV_EVENT_CODE_TYPE_XY_MACRO(heartbeat_log_v2 , 41)
75+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(heartbeat_log_v2 , 41), \
76+
BINSRV_EVENT_CODE_TYPE_XY_MACRO(gtid_tagged_log , 42)
6877
// clang-format on
6978

7079
#define BINSRV_EVENT_CODE_TYPE_XY_MACRO(X, Y) X = Y

src/binsrv/event/common_header.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ common_header::common_header(util::const_byte_span portion) {
4040
// TODO: rework with direct member initialization
4141

4242
/*
43-
https://github.com/mysql/mysql-server/blob/mysql-8.0.37/libbinlogevents/src/binlog_event.cpp#L198
43+
https://github.com/mysql/mysql-server/blob/mysql-8.0.43/libbinlogevents/src/binlog_event.cpp#L198
44+
https://github.com/mysql/mysql-server/blob/mysql-8.4.6/libs/mysql/binlog/event/binlog_event.cpp#L242
4445
4546
The first 19 bytes in the header is as follows:
4647
+============================================+

0 commit comments

Comments
 (0)