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

Add initial support for capabilities #4987

Merged
merged 19 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 18 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
12 changes: 2 additions & 10 deletions config/mycnf/master_mariadb.cnf
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
# This file is auto-included when MariaDB (any version) is detected.

# enable strict mode so it's safe to compare sequence numbers across different server IDs.
gtid_strict_mode = 1
innodb_stats_persistent = 0
innodb_support_xa = 0

# Semi-sync replication is required for automated unplanned failover
# (when the master goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when masters are
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so

# When semi-sync is enabled, don't allow fallback to async
# if you get no ack, or have no slaves. This is necessary to
Expand Down
12 changes: 12 additions & 0 deletions config/mycnf/master_mariadb100.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is auto-included when MariaDB 10.0 is detected.

innodb_support_xa = 0
morgo marked this conversation as resolved.
Show resolved Hide resolved

# Semi-sync replication is required for automated unplanned failover
# (when the master goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when masters are
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
12 changes: 12 additions & 0 deletions config/mycnf/master_mariadb101.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is auto-included when MariaDB 10.1 is detected.

innodb_support_xa = 0

# Semi-sync replication is required for automated unplanned failover
# (when the master goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when masters are
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
12 changes: 12 additions & 0 deletions config/mycnf/master_mariadb102.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This file is auto-included when MariaDB 10.2 is detected.

innodb_support_xa = 0

# Semi-sync replication is required for automated unplanned failover
# (when the master goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when masters are
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
2 changes: 2 additions & 0 deletions config/mycnf/master_mariadb103.cnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file is auto-included when MariaDB 10.3 is detected.

# enable strict mode so it's safe to compare sequence numbers across different server IDs.
gtid_strict_mode = 1
innodb_stats_persistent = 0
Expand Down
2 changes: 2 additions & 0 deletions config/mycnf/master_mysql56.cnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file is auto-included when MySQL 5.6 is detected.

# Options for enabling GTID
# https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html
gtid_mode = ON
Expand Down
32 changes: 32 additions & 0 deletions config/mycnf/master_mysql57.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This file is auto-included when MySQL 5.7 is detected.

# Options for enabling GTID
# https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html
gtid_mode = ON
log_bin
log_slave_updates
enforce_gtid_consistency
innodb_use_native_aio = 0

# Crash-safe replication settings.
master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log_purge = 1
relay_log_recovery = 1

morgo marked this conversation as resolved.
Show resolved Hide resolved
# Semi-sync replication is required for automated unplanned failover
# (when the master goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when masters are
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so

# When semi-sync is enabled, don't allow fallback to async
# if you get no ack, or have no slaves. This is necessary to
# prevent alternate futures when doing a failover in response to
# a master that becomes unresponsive.
rpl_semi_sync_master_timeout = 1000000000000000000
rpl_semi_sync_master_wait_no_slave = 1

2 changes: 2 additions & 0 deletions config/mycnf/master_mysql80.cnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# This file is auto-included when MySQL 8.0 is detected.

# Options for enabling GTID
# https://dev.mysql.com/doc/refman/5.6/en/replication-gtids-howto.html
gtid_mode = ON
Expand Down
10 changes: 0 additions & 10 deletions dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ if [[ "$VT_MYSQL_ROOT" == "" ]]; then
fi
fi

# restore MYSQL_FLAVOR, saved by bootstrap.sh
if [ -r "$VTROOT/dist/MYSQL_FLAVOR" ]; then
MYSQL_FLAVOR=$(cat "$VTROOT/dist/MYSQL_FLAVOR")
export MYSQL_FLAVOR
fi

# mysql cgo library config
if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MariaDB
fi
PKG_CONFIG_PATH=$(prepend_path "$PKG_CONFIG_PATH" "$VTROOT/lib")
export PKG_CONFIG_PATH

Expand Down
11 changes: 2 additions & 9 deletions examples/local/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,8 @@ if [ -z "$VT_MYSQL_ROOT" ]; then
export VT_MYSQL_ROOT=$(dirname `dirname $mysql_path`)
fi

# restore MYSQL_FLAVOR, saved by bootstrap.sh
if [ -r "$VTROOT/dist/MYSQL_FLAVOR" ]; then
MYSQL_FLAVOR=$(cat "$VTROOT/dist/MYSQL_FLAVOR")
export MYSQL_FLAVOR
fi

if [ -z "$MYSQL_FLAVOR" ]; then
export MYSQL_FLAVOR=MySQL56
fi
# Previously the file specified MYSQL_FLAVOR
# it is now autodetected

if [ "${TOPO}" = "etcd2" ]; then
echo "enter etcd2 env"
Expand Down
19 changes: 3 additions & 16 deletions examples/local/vttablet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,10 @@ source $script_root/env.sh

init_db_sql_file="$VTROOT/config/init_db.sql"

export EXTRA_MY_CNF=$VTROOT/config/mycnf/default-fast.cnf:$VTROOT/config/mycnf/rbr.cnf
# Previously this file set EXTRA_MY_CNF based on MYSQL_FLAVOR
morgo marked this conversation as resolved.
Show resolved Hide resolved
# It now relies on mysqlctl to autodetect

case "$MYSQL_FLAVOR" in
"MySQL56")
export EXTRA_MY_CNF=$EXTRA_MY_CNF:$VTROOT/config/mycnf/master_mysql56.cnf
;;
"MariaDB")
export EXTRA_MY_CNF=$EXTRA_MY_CNF:$VTROOT/config/mycnf/master_mariadb.cnf
;;
"MariaDB103")
export EXTRA_MY_CNF=$EXTRA_MY_CNF:$VTROOT/config/mycnf/master_mariadb103.cnf
;;
*)
echo "Please set MYSQL_FLAVOR to MySQL56 or MariaDB."
exit 1
;;
esac
export EXTRA_MY_CNF=$VTROOT/config/mycnf/default-fast.cnf:$VTROOT/config/mycnf/rbr.cnf

mkdir -p $VTDATAROOT/backups

Expand Down
79 changes: 79 additions & 0 deletions go/vt/mysqlctl/capabilityset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2019 The Vitess Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
Detect server flavors and capabilities
*/

package mysqlctl

type mysqlFlavor string

const (
flavorMySQL mysqlFlavor = "mysql"
flavorPercona mysqlFlavor = "percona"
flavorMariaDB mysqlFlavor = "mariadb"
)

// Mysqld is the object that represents a mysqld daemon running on this server.
type CapabilitySet struct {
flavor mysqlFlavor
version serverVersion
}

func NewCapabilitySet(f mysqlFlavor, v serverVersion) (c CapabilitySet) {
c.flavor = f
c.version = v
return
}

func (c *CapabilitySet) HasMySQLUpgradeInServer() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 8, Minor: 0, Patch: 16})
}
func (c *CapabilitySet) HasInitializeInServer() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 5, Minor: 7, Patch: 0})
}
func (c *CapabilitySet) HasMySQLxEnabledByDefault() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 8, Minor: 0, Patch: 11})
}
func (c *CapabilitySet) HasPersistConfig() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 8, Minor: 0, Patch: 0})
}
func (c *CapabilitySet) HasShutdownCommand() bool {
return (c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 5, Minor: 7, Patch: 9})) || (c.IsMariaDB() && c.version.atLeast(serverVersion{Major: 10, Minor: 0, Patch: 4}))
}
func (c *CapabilitySet) HasBackupLocks() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 8, Minor: 0, Patch: 0})
}
func (c *CapabilitySet) HasDefaultUft8mb4() bool {
return c.IsMySQLLike() && c.version.atLeast(serverVersion{Major: 8, Minor: 0, Patch: 0})
}
func (c *CapabilitySet) HasSemiSyncEnabledByDefault() bool {
return c.IsMariaDB() && c.version.atLeast(serverVersion{Major: 10, Minor: 3, Patch: 3})
}

// IsMySQLLike tests if the server is either MySQL
// or Percona Server. At least currently, Vitess doesn't
// make use of any specific Percona Server features.
func (c *CapabilitySet) IsMySQLLike() bool {
return c.flavor == flavorMySQL || c.flavor == flavorPercona
}

// IsMariaDB tests if the server is MariaDB.
// IsMySQLLike() and IsMariaDB() are mutually exclusive
func (c *CapabilitySet) IsMariaDB() bool {
return c.flavor == flavorMariaDB
}
Loading