Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to use semisync source / replica plugins #15791

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_onlineddl_vrepl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

set -exo pipefail

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

set -exo pipefail

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

set -exo pipefail

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

set -exo pipefail

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cluster_endtoend_schemadiff_vrepl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ jobs:

set -exo pipefail

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cluster_endtoend_vreplication_basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cluster_endtoend_vreplication_v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand All @@ -153,7 +153,7 @@ jobs:
slow-query-log=OFF
EOF

cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
binlog-transaction-compression=ON
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ jobs:

# Increase our open file descriptor limit as we could hit this
ulimit -n 65536
cat <<-EOF>>./config/mycnf/mysql80.cnf
cat <<-EOF>>./config/mycnf/mysql8026.cnf
innodb_buffer_pool_dump_at_shutdown=OFF
innodb_buffer_pool_in_core_file=OFF
innodb_buffer_pool_load_at_startup=OFF
Expand Down
6 changes: 6 additions & 0 deletions config/embed.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ var MycnfMySQL57 string

//go:embed mycnf/mysql80.cnf
var MycnfMySQL80 string

//go:embed mycnf/mysql8026.cnf
var MycnfMySQL8026 string

//go:embed mycnf/mysql84.cnf
var MycnfMySQL84 string
37 changes: 37 additions & 0 deletions config/mycnf/mysql8026.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is auto-included when MySQL 8.0.26 or later is detected.

# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories
# It does not enable GTIDs or enforced GTID consistency

gtid_mode = ON
enforce_gtid_consistency
relay_log_recovery = 1
binlog_expire_logs_seconds = 259200

# disable mysqlx
mysqlx = 0

# 8.0 changes the default auth-plugin to caching_sha2_password
default_authentication_plugin = mysql_native_password

# Semi-sync replication is required for automated unplanned failover
# (when the primary goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# VTTablet will enable semi-sync at the proper time when replication is set up,
# or when a primary is promoted or demoted based on the durability policy configured.
plugin-load = rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so

# MySQL 8.0.26 and later will not load plugins during --initialize
# which makes these options unknown. Prefixing with --loose
# tells the server it's fine if they are not understood.
loose_rpl_semi_sync_source_timeout = 1000000000000000000
loose_rpl_semi_sync_source_wait_no_replica = 1

# In order to protect against any errand GTIDs we will start the mysql instance
# in super-read-only mode.
super-read-only

# Replication parameters to ensure reparents are fast.
replica_net_timeout = 8

39 changes: 39 additions & 0 deletions config/mycnf/mysql84.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is auto-included when MySQL 8.4.0 or later is detected.

# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories
# It does not enable GTIDs or enforced GTID consistency

gtid_mode = ON
enforce_gtid_consistency
relay_log_recovery = 1
binlog_expire_logs_seconds = 259200

# disable mysqlx
mysqlx = 0

# 8.4 changes the default auth-plugin to caching_sha2_password and
# disables mysql_native_password by default.
mysql_native_password = ON
default_authentication_plugin = mysql_native_password

# Semi-sync replication is required for automated unplanned failover
# (when the primary goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# VTTablet will enable semi-sync at the proper time when replication is set up,
# or when a primary is promoted or demoted based on the durability policy configured.
plugin-load = rpl_semi_sync_source=semisync_source.so;rpl_semi_sync_replica=semisync_replica.so

# MySQL 8.0.26 and later will not load plugins during --initialize
# which makes these options unknown. Prefixing with --loose
# tells the server it's fine if they are not understood.
loose_rpl_semi_sync_source_timeout = 1000000000000000000
loose_rpl_semi_sync_source_wait_no_replica = 1

# In order to protect against any errand GTIDs we will start the mysql instance
# in super-read-only mode.
super-read-only

# Replication parameters to ensure reparents are fast.
replica_net_timeout = 8

11 changes: 6 additions & 5 deletions go/cmd/vtcombo/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/spf13/cobra"

"vitess.io/vitess/go/acl"
"vitess.io/vitess/go/mysql"
"vitess.io/vitess/go/mysql/replication"
"vitess.io/vitess/go/stats"
"vitess.io/vitess/go/vt/dbconfigs"
Expand Down Expand Up @@ -216,7 +217,7 @@ func run(cmd *cobra.Command, args []string) (err error) {
return err
}
servenv.OnClose(func() {
ctx, cancel := context.WithTimeout(context.Background(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
ctx, cancel := context.WithTimeout(cmd.Context(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
defer cancel()
mysqld.Shutdown(ctx, cnf, true, mysqlctl.DefaultShutdownTimeout)
})
Expand All @@ -240,7 +241,7 @@ func run(cmd *cobra.Command, args []string) (err error) {
if err != nil {
// ensure we start mysql in the event we fail here
if startMysql {
ctx, cancel := context.WithTimeout(context.Background(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
ctx, cancel := context.WithTimeout(cmd.Context(), mysqlctl.DefaultShutdownTimeout+10*time.Second)
defer cancel()
mysqld.Shutdown(ctx, cnf, true, mysqlctl.DefaultShutdownTimeout)
}
Expand Down Expand Up @@ -387,11 +388,11 @@ func (mysqld *vtcomboMysqld) StopReplication(hookExtraEnv map[string]string) err
}

// SetSemiSyncEnabled implements the MysqlDaemon interface
func (mysqld *vtcomboMysqld) SetSemiSyncEnabled(source, replica bool) error {
func (mysqld *vtcomboMysqld) SetSemiSyncEnabled(ctx context.Context, source, replica bool) error {
return nil
}

// SemiSyncExtensionLoaded implements the MysqlDaemon interface
func (mysqld *vtcomboMysqld) SemiSyncExtensionLoaded() (bool, error) {
return true, nil
func (mysqld *vtcomboMysqld) SemiSyncExtensionLoaded(ctx context.Context) (mysql.SemiSyncType, error) {
return mysql.SemiSyncTypeSource, nil
}
3 changes: 2 additions & 1 deletion go/mysql/flavor_mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ func (mariadbFlavor) resetReplicationCommands(c *Conn) []string {
"RESET MASTER",
"SET GLOBAL gtid_slave_pos = ''",
}
if c.SemiSyncExtensionLoaded() {
semisyncType, _ := c.SemiSyncExtensionLoaded()
if semisyncType == SemiSyncTypeMaster {
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.
}
return resetCommands
Expand Down
11 changes: 10 additions & 1 deletion go/mysql/flavor_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,17 @@ func (mysqlFlavor) resetReplicationCommands(c *Conn) []string {
"RESET SLAVE ALL", // "ALL" makes it forget source host:port.
"RESET MASTER", // This will also clear gtid_executed and gtid_purged.
}
if c.SemiSyncExtensionLoaded() {
status, err := c.SemiSyncExtensionLoaded()
if err != nil {
return resetCommands
}
switch status {
case SemiSyncTypeSource:
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.
case SemiSyncTypeMaster:
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.
default:
// Nothing to do.
}
return resetCommands
}
Expand Down
Loading
Loading