Skip to content

Commit 8f6cfaa

Browse files
authored
Switch to use semisync source / replica plugins (#15791)
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
1 parent ee6b837 commit 8f6cfaa

File tree

46 files changed

+660
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+660
-293
lines changed

.github/workflows/cluster_endtoend_ers_prs_newfeatures_heavy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF

.github/workflows/cluster_endtoend_onlineddl_vrepl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
137137
set -exo pipefail
138138
139-
cat <<-EOF>>./config/mycnf/mysql80.cnf
139+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
140140
binlog-transaction-compression=ON
141141
EOF
142142

.github/workflows/cluster_endtoend_onlineddl_vrepl_stress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
137137
set -exo pipefail
138138
139-
cat <<-EOF>>./config/mycnf/mysql80.cnf
139+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
140140
binlog-transaction-compression=ON
141141
EOF
142142

.github/workflows/cluster_endtoend_onlineddl_vrepl_stress_suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
137137
set -exo pipefail
138138
139-
cat <<-EOF>>./config/mycnf/mysql80.cnf
139+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
140140
binlog-transaction-compression=ON
141141
EOF
142142

.github/workflows/cluster_endtoend_onlineddl_vrepl_suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
137137
set -exo pipefail
138138
139-
cat <<-EOF>>./config/mycnf/mysql80.cnf
139+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
140140
binlog-transaction-compression=ON
141141
EOF
142142

.github/workflows/cluster_endtoend_schemadiff_vrepl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
137137
set -exo pipefail
138138
139-
cat <<-EOF>>./config/mycnf/mysql80.cnf
139+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
140140
binlog-transaction-compression=ON
141141
EOF
142142

.github/workflows/cluster_endtoend_vreplication_across_db_versions.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_basic.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_cellalias.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_foreign_key_stress.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_migrate_vdiff2_convert_tz.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_multi_tenant.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_partial_movetables_and_materialize.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vreplication_v2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF
@@ -153,7 +153,7 @@ jobs:
153153
slow-query-log=OFF
154154
EOF
155155
156-
cat <<-EOF>>./config/mycnf/mysql80.cnf
156+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
157157
binlog-transaction-compression=ON
158158
EOF
159159

.github/workflows/cluster_endtoend_vtctlbackup_sharded_clustertest_heavy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF

.github/workflows/cluster_endtoend_vtgate_general_heavy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF

.github/workflows/cluster_endtoend_vtgate_vindex_heavy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ jobs:
137137
138138
# Increase our open file descriptor limit as we could hit this
139139
ulimit -n 65536
140-
cat <<-EOF>>./config/mycnf/mysql80.cnf
140+
cat <<-EOF>>./config/mycnf/mysql8026.cnf
141141
innodb_buffer_pool_dump_at_shutdown=OFF
142142
innodb_buffer_pool_in_core_file=OFF
143143
innodb_buffer_pool_load_at_startup=OFF

config/embed.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ var MycnfMySQL57 string
1616

1717
//go:embed mycnf/mysql80.cnf
1818
var MycnfMySQL80 string
19+
20+
//go:embed mycnf/mysql8026.cnf
21+
var MycnfMySQL8026 string
22+
23+
//go:embed mycnf/mysql84.cnf
24+
var MycnfMySQL84 string

config/mycnf/mysql8026.cnf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file is auto-included when MySQL 8.0.26 or later is detected.
2+
3+
# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories
4+
# It does not enable GTIDs or enforced GTID consistency
5+
6+
gtid_mode = ON
7+
enforce_gtid_consistency
8+
relay_log_recovery = 1
9+
binlog_expire_logs_seconds = 259200
10+
11+
# disable mysqlx
12+
mysqlx = 0
13+
14+
# 8.0 changes the default auth-plugin to caching_sha2_password
15+
default_authentication_plugin = mysql_native_password
16+
17+
# Semi-sync replication is required for automated unplanned failover
18+
# (when the primary goes away). Here we just load the plugin so it's
19+
# available if desired, but it's disabled at startup.
20+
#
21+
# VTTablet will enable semi-sync at the proper time when replication is set up,
22+
# or when a primary is promoted or demoted based on the durability policy configured.
23+
plugin-load = rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so
24+
25+
# MySQL 8.0.26 and later will not load plugins during --initialize
26+
# which makes these options unknown. Prefixing with --loose
27+
# tells the server it's fine if they are not understood.
28+
loose_rpl_semi_sync_source_timeout = 1000000000000000000
29+
loose_rpl_semi_sync_source_wait_no_replica = 1
30+
31+
# In order to protect against any errand GTIDs we will start the mysql instance
32+
# in super-read-only mode.
33+
super-read-only
34+
35+
# Replication parameters to ensure reparents are fast.
36+
replica_net_timeout = 8
37+

config/mycnf/mysql84.cnf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This file is auto-included when MySQL 8.4.0 or later is detected.
2+
3+
# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories
4+
# It does not enable GTIDs or enforced GTID consistency
5+
6+
gtid_mode = ON
7+
enforce_gtid_consistency
8+
relay_log_recovery = 1
9+
binlog_expire_logs_seconds = 259200
10+
11+
# disable mysqlx
12+
mysqlx = 0
13+
14+
# 8.4 changes the default auth-plugin to caching_sha2_password and
15+
# disables mysql_native_password by default.
16+
mysql_native_password = ON
17+
default_authentication_plugin = mysql_native_password
18+
19+
# Semi-sync replication is required for automated unplanned failover
20+
# (when the primary goes away). Here we just load the plugin so it's
21+
# available if desired, but it's disabled at startup.
22+
#
23+
# VTTablet will enable semi-sync at the proper time when replication is set up,
24+
# or when a primary is promoted or demoted based on the durability policy configured.
25+
plugin-load = rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so
26+
27+
# MySQL 8.0.26 and later will not load plugins during --initialize
28+
# which makes these options unknown. Prefixing with --loose
29+
# tells the server it's fine if they are not understood.
30+
loose_rpl_semi_sync_source_timeout = 1000000000000000000
31+
loose_rpl_semi_sync_source_wait_no_replica = 1
32+
33+
# In order to protect against any errand GTIDs we will start the mysql instance
34+
# in super-read-only mode.
35+
super-read-only
36+
37+
# Replication parameters to ensure reparents are fast.
38+
replica_net_timeout = 8
39+

go/cmd/vtcombo/cli/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/spf13/cobra"
3232

3333
"vitess.io/vitess/go/acl"
34+
"vitess.io/vitess/go/mysql"
3435
"vitess.io/vitess/go/mysql/replication"
3536
"vitess.io/vitess/go/stats"
3637
"vitess.io/vitess/go/vt/dbconfigs"
@@ -216,7 +217,7 @@ func run(cmd *cobra.Command, args []string) (err error) {
216217
return err
217218
}
218219
servenv.OnClose(func() {
219-
ctx, cancel := context.WithTimeout(context.Background(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
220+
ctx, cancel := context.WithTimeout(cmd.Context(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
220221
defer cancel()
221222
mysqld.Shutdown(ctx, cnf, true, mysqlctl.DefaultShutdownTimeout)
222223
})
@@ -240,7 +241,7 @@ func run(cmd *cobra.Command, args []string) (err error) {
240241
if err != nil {
241242
// ensure we start mysql in the event we fail here
242243
if startMysql {
243-
ctx, cancel := context.WithTimeout(context.Background(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
244+
ctx, cancel := context.WithTimeout(cmd.Context(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
244245
defer cancel()
245246
mysqld.Shutdown(ctx, cnf, true, mysqlctl.DefaultShutdownTimeout)
246247
}
@@ -387,11 +388,11 @@ func (mysqld *vtcomboMysqld) StopReplication(hookExtraEnv map[string]string) err
387388
}
388389

389390
// SetSemiSyncEnabled implements the MysqlDaemon interface
390-
func (mysqld *vtcomboMysqld) SetSemiSyncEnabled(source, replica bool) error {
391+
func (mysqld *vtcomboMysqld) SetSemiSyncEnabled(ctx context.Context, source, replica bool) error {
391392
return nil
392393
}
393394

394395
// SemiSyncExtensionLoaded implements the MysqlDaemon interface
395-
func (mysqld *vtcomboMysqld) SemiSyncExtensionLoaded() (bool, error) {
396-
return true, nil
396+
func (mysqld *vtcomboMysqld) SemiSyncExtensionLoaded(ctx context.Context) (mysql.SemiSyncType, error) {
397+
return mysql.SemiSyncTypeSource, nil
397398
}

go/mysql/flavor_mariadb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ func (mariadbFlavor) resetReplicationCommands(c *Conn) []string {
144144
"RESET MASTER",
145145
"SET GLOBAL gtid_slave_pos = ''",
146146
}
147-
if c.SemiSyncExtensionLoaded() {
147+
semisyncType, _ := c.SemiSyncExtensionLoaded()
148+
if semisyncType == SemiSyncTypeMaster {
148149
resetCommands = append(resetCommands, "SET GLOBAL rpl_semi_sync_master_enabled = false, GLOBAL rpl_semi_sync_slave_enabled = false") // semi-sync will be enabled if needed when replica is started.
149150
}
150151
return resetCommands

go/mysql/flavor_mysql.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,17 @@ func (mysqlFlavor) resetReplicationCommands(c *Conn) []string {
154154
"RESET SLAVE ALL", // "ALL" makes it forget source host:port.
155155
"RESET MASTER", // This will also clear gtid_executed and gtid_purged.
156156
}
157-
if c.SemiSyncExtensionLoaded() {
157+
status, err := c.SemiSyncExtensionLoaded()
158+
if err != nil {
159+
return resetCommands
160+
}
161+
switch status {
162+
case SemiSyncTypeSource:
163+
resetCommands = append(resetCommands, "SET GLOBAL rpl_semi_sync_source_enabled = false, GLOBAL rpl_semi_sync_replica_enabled = false") // semi-sync will be enabled if needed when replica is started.
164+
case SemiSyncTypeMaster:
158165
resetCommands = append(resetCommands, "SET GLOBAL rpl_semi_sync_master_enabled = false, GLOBAL rpl_semi_sync_slave_enabled = false") // semi-sync will be enabled if needed when replica is started.
166+
default:
167+
// Nothing to do.
159168
}
160169
return resetCommands
161170
}

0 commit comments

Comments
 (0)