Skip to content

Commit bc7e697

Browse files
author
Joao Gramacho
committed
Bug#22102456 ENABLING GTID AT STARTUP RESULTS IN UNNECESSARY GTID SETS
Problem: When a server is initialized with GTID enabled, it creates a large and unnecessary GTID set. Fix: Disabled binary logging session option when applying compiled bootstrap statements.
1 parent fc02ad2 commit bc7e697

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

mysql-test/r/initialize_gtid.result

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CALL mtr.add_suppression("InnoDB:");
2+
USE mysql;
3+
# Shut server down
4+
# Server is down
5+
# Run the server with:
6+
# --initialize-insecure
7+
# --explicit_defaults_for_timestamp --gtid-mode=on --enforce-gtid-consistency=on --log-bin=mysql-bin --server-id=1
8+
# Restart the server against DDIR
9+
# Connect as root
10+
include/assert.inc [GTID_EXECUTED should be empty after initialization]
11+
# Clean up
12+
# Restarting the server after cleaning it up

mysql-test/t/initialize_gtid.test

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# ==== Purpose ====
2+
#
3+
# This test will initialize a new instance of a mysql server enabling binary
4+
# logging and GTID features. After the server initialization, the test case
5+
# will connect to the new server and no GTIDs are expected to be generated
6+
# during the initialization (GTID_EXECUTED should be empty).
7+
#
8+
# ==== Related Bugs and Worklogs ====
9+
#
10+
# Bug#22102456 ENABLING GTID AT STARTUP RESULTS IN UNNECESSARY GTID SETS
11+
#
12+
13+
--source include/not_embedded.inc
14+
--source include/have_no_undo_tablespaces.inc
15+
16+
--let BASEDIR= `select @@basedir`
17+
--let DDIR=$MYSQL_TMP_DIR/installdb_test
18+
--let MYSQLD_LOG=$MYSQL_TMP_DIR/server.log
19+
--let extra_args=--no-defaults --console --log-syslog=0 --loose-skip-auto_generate_certs --loose-skip-sha256_password_auto_generate_rsa_keys --skip-ssl --basedir=$BASEDIR --lc-messages-dir=$MYSQL_SHAREDIR
20+
--let init_args=--explicit_defaults_for_timestamp --gtid-mode=on --enforce-gtid-consistency=on --log-bin=mysql-bin --server-id=1
21+
--let BOOTSTRAP_SQL=$MYSQL_TMP_DIR/tiny_bootstrap.sql
22+
#--let PASSWD_FILE=$MYSQL_TMP_DIR/password_file.txt
23+
24+
# We don't care about innodb warnings at this point
25+
CALL mtr.add_suppression("InnoDB:");
26+
USE mysql;
27+
28+
--echo # Shut server down
29+
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
30+
--shutdown_server
31+
--source include/wait_until_disconnected.inc
32+
--echo # Server is down
33+
34+
--echo # Run the server with:
35+
--echo # --initialize-insecure
36+
--echo # $init_args
37+
--exec $MYSQLD $extra_args --initialize-insecure --datadir=$DDIR $init_args > $MYSQLD_LOG 2>&1
38+
39+
--echo # Restart the server against DDIR
40+
--exec echo "restart:--datadir=$DDIR $init_args" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
41+
--enable_reconnect
42+
--source include/wait_until_connected_again.inc
43+
44+
--echo # Connect as root
45+
connect(root_con,localhost,root,,mysql);
46+
47+
--let $assert_text= GTID_EXECUTED should be empty after initialization
48+
--let $assert_cond= @@GLOBAL.GTID_EXECUTED = ""
49+
--source include/assert.inc
50+
51+
--echo # Clean up
52+
# Shut server down
53+
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
54+
--shutdown_server
55+
--source include/wait_until_disconnected.inc
56+
57+
# Delete mysqld log
58+
remove_file $MYSQLD_LOG;
59+
# Delete datadir
60+
--perl
61+
use File::Path 'rmtree';
62+
$DDIR=$ENV{"DDIR"};
63+
rmtree([ "$DDIR" ]);
64+
EOF
65+
66+
--echo # Restarting the server after cleaning it up
67+
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
68+
--enable_reconnect
69+
--source include/wait_until_connected_again.inc

sql/bootstrap.cc

+8
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,17 @@ static void handle_bootstrap_impl(THD *thd)
101101
thd->init_for_queries();
102102

103103
if (opt_initialize)
104+
{
104105
Command_iterator::current_iterator= &comp_iter;
106+
/* Disable binary logging during compiled statements */
107+
thd->variables.option_bits&= ~OPTION_BIN_LOG;
108+
}
105109
else
110+
{
106111
Command_iterator::current_iterator= &file_iter;
112+
/* Re-enable binary logging during init-file statements */
113+
thd->variables.option_bits|= OPTION_BIN_LOG;
114+
}
107115

108116
Command_iterator::current_iterator->begin();
109117
for ( ; ; )

0 commit comments

Comments
 (0)