зеркало из https://github.com/github/vitess-gh.git
Deprecate enable-semi-sync in favour of RPC parameter (#10695)
* feat: deprecate enable_semi_sync flag Signed-off-by: Manan Gupta <manan@planetscale.com> * docs: add the deprecation change to the summary Signed-off-by: Manan Gupta <manan@planetscale.com> * test: fix test expectation for vttablet flags Signed-off-by: Manan Gupta <manan@planetscale.com> * feat: fix cnf files to not mention the deprecated flag Signed-off-by: Manan Gupta <manan@planetscale.com> * feat: remove enable_semi_sync from scripts of examples Signed-off-by: Manan Gupta <manan@planetscale.com> * test: remove setting enable_semi_sync flag in testlib tests Signed-off-by: Manan Gupta <manan@planetscale.com> * feat: remove enable_semi_sync from a bunch of tests Signed-off-by: Manan Gupta <manan@planetscale.com> * test: refactor setup to take in durability policy instead of a boolean and add a test for cross cell durability policy Signed-off-by: Manan Gupta <manan@planetscale.com> * feat: add cross cell durability policy to the docs Signed-off-by: Manan Gupta <manan@planetscale.com> * feat: fix flag help output Signed-off-by: Manan Gupta <manan@planetscale.com> * test: we shouldn't remove enable_semi_sync from tests which are testing upgrades Signed-off-by: Manan Gupta <manan@planetscale.com>
This commit is contained in:
Родитель
73b4995518
Коммит
ed9e6e33f2
|
@ -4,9 +4,8 @@
|
|||
# (when the primary 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 a primary is
|
||||
# promoted or demoted.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
slave_net_timeout = 60
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
# (when the primary 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 a primary is
|
||||
# promoted or demoted.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
slave_net_timeout = 60
|
||||
|
|
|
@ -4,9 +4,8 @@
|
|||
# (when the primary 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 a primary is
|
||||
# promoted or demoted.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# enable strict mode so it's safe to compare sequence numbers across different server IDs.
|
||||
|
|
|
@ -21,9 +21,8 @@ collation_server = utf8_general_ci
|
|||
# (when the primary 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 a primary is
|
||||
# promoted or demoted.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# When semi-sync is enabled, don't allow fallback to async
|
||||
|
|
|
@ -18,9 +18,8 @@ default_authentication_plugin = mysql_native_password
|
|||
# (when the primary 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 a primary is
|
||||
# promoted or demoted.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# MySQL 8.0 will not load plugins during --initialize
|
||||
|
|
|
@ -37,6 +37,7 @@ The following VTTablet flags were deprecated in 7.0. They have now been deleted
|
|||
|
||||
#### vttablet startup flag deprecations
|
||||
- --enable-query-plan-field-caching is now deprecated. It will be removed in v16.
|
||||
- --enable_semi_sync is now deprecated. It will be removed in v16. Instead, set the correct durability policy using `SetKeyspaceDurabilityPolicy`
|
||||
|
||||
### New command line flags and behavior
|
||||
|
||||
|
@ -161,3 +162,10 @@ $ curl -s http://127.0.0.1:15100/debug/vars | jq . | grep Throttler
|
|||
|
||||
Added new parameter `multi_shard_autocommit` to lookup vindex definition in vschema, if enabled will send lookup vindex dml query as autocommit to all shards
|
||||
This is slighly different from `autocommit` parameter where the query is sent in its own transaction separate from the ongoing transaction if any i.e. begin -> lookup query execs -> commit/rollback
|
||||
|
||||
### Durability Policy
|
||||
|
||||
#### Cross Cell
|
||||
|
||||
A new durabilty policy `cross_cell` is now supported. `cross_cell` durability policy only allows replica tablets from a different cell than the current primary to
|
||||
send semi sync ACKs. This ensures that any committed write exists in atleast 2 tablets belonging to different cells.
|
|
@ -19,9 +19,8 @@ innodb_use_native_aio = 0
|
|||
# (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.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# When semi-sync is enabled, don't allow fallback to async
|
||||
|
|
|
@ -21,9 +21,8 @@ collation_server = utf8_general_ci
|
|||
# (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.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# When semi-sync is enabled, don't allow fallback to async
|
||||
|
|
|
@ -150,7 +150,6 @@ exec $VTROOT/bin/vttablet \
|
|||
--tablet-path $alias \
|
||||
--tablet_hostname "$vthost" \
|
||||
--health_check_interval 5s \
|
||||
--enable_semi_sync=false \
|
||||
--disable_active_reparents=true \
|
||||
--port $web_port \
|
||||
--grpc_port $grpc_port \
|
||||
|
|
|
@ -46,7 +46,6 @@ vttablet \
|
|||
--init_shard $shard \
|
||||
--init_tablet_type $tablet_type \
|
||||
--health_check_interval 5s \
|
||||
--enable_semi_sync \
|
||||
--enable_replication_reporter \
|
||||
--backup_storage_implementation file \
|
||||
--file_backup_storage_root $VTDATAROOT/backups \
|
||||
|
|
|
@ -74,7 +74,6 @@ spec:
|
|||
extraFlags:
|
||||
db_charset: utf8mb4
|
||||
disable_active_reparents: "true"
|
||||
enable_semi_sync: "false"
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
|
|
|
@ -396,7 +396,7 @@ Usage of vttablet:
|
|||
--enable_replication_reporter
|
||||
Use polling to track replication lag.
|
||||
--enable_semi_sync
|
||||
Enable semi-sync when configuring replication, on primary and replica tablets only (rdonly tablets will not ack).
|
||||
DEPRECATED - Set the correct durability policy on the keyspace instead.
|
||||
--enable_transaction_limit
|
||||
If true, limit on number of transactions open at the same time will be enforced for all users. User trying to open a new transaction after exhausting their limit will receive an error immediately, regardless of whether there are available slots or not.
|
||||
--enable_transaction_limit_dry_run
|
||||
|
|
|
@ -159,7 +159,6 @@ func LaunchCluster(setupType int, streamMode string, stripes int, cDetails *Comp
|
|||
tablet.VttabletProcess.DbPassword = dbPassword
|
||||
tablet.VttabletProcess.ExtraArgs = commonTabletArg
|
||||
tablet.VttabletProcess.SupportsBackup = true
|
||||
tablet.VttabletProcess.EnableSemiSync = true
|
||||
|
||||
if setupType == Mysqlctld {
|
||||
tablet.MysqlctldProcess = *cluster.MysqlCtldProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory)
|
||||
|
|
|
@ -405,7 +405,7 @@ func initializeCluster(t *testing.T) {
|
|||
shard1.Vttablets = []*cluster.Vttablet{shard1Primary, shard1Replica}
|
||||
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, commonTabletArg...)
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--restore_from_backup", "--enable_semi_sync")
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--restore_from_backup")
|
||||
|
||||
err = clusterInstance.SetupCluster(keyspace, []cluster.Shard{*shard, *shard0, *shard1})
|
||||
require.NoError(t, err)
|
||||
|
@ -516,7 +516,6 @@ func launchRecoveryTablet(t *testing.T, tablet *cluster.Vttablet, binlogServer *
|
|||
tablet.Alias = tablet.VttabletProcess.TabletPath
|
||||
tablet.VttabletProcess.SupportsBackup = true
|
||||
tablet.VttabletProcess.Keyspace = restoreKeyspaceName
|
||||
tablet.VttabletProcess.EnableSemiSync = true
|
||||
tablet.VttabletProcess.ExtraArgs = []string{
|
||||
"--disable_active_reparents",
|
||||
"--enable_replication_reporter=false",
|
||||
|
|
|
@ -142,7 +142,7 @@ func initializeCluster(t *testing.T) {
|
|||
shard1.Vttablets = []*cluster.Vttablet{shard1Primary, shard1Replica}
|
||||
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, commonTabletArg...)
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--restore_from_backup", "--enable_semi_sync")
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--restore_from_backup")
|
||||
|
||||
err = clusterInstance.SetupCluster(keyspace, []cluster.Shard{*shard, *shard0, *shard1})
|
||||
require.NoError(t, err)
|
||||
|
@ -495,7 +495,6 @@ func tlsLaunchRecoveryTablet(t *testing.T, tablet *cluster.Vttablet, tabletForBi
|
|||
tablet.Alias = tablet.VttabletProcess.TabletPath
|
||||
tablet.VttabletProcess.SupportsBackup = true
|
||||
tablet.VttabletProcess.Keyspace = restoreKeyspaceName
|
||||
tablet.VttabletProcess.EnableSemiSync = true
|
||||
|
||||
certDir := path.Join(os.Getenv("VTDATAROOT"), fmt.Sprintf("/ssl_%010d", tablet.MysqlctlProcess.TabletUID))
|
||||
tablet.VttabletProcess.ExtraArgs = []string{
|
||||
|
|
|
@ -124,7 +124,6 @@ SET GLOBAL old_alter_table = ON;
|
|||
tablet.VttabletProcess.ExtraArgs = append(tablet.VttabletProcess.ExtraArgs, recovery.XbArgs...)
|
||||
}
|
||||
tablet.VttabletProcess.SupportsBackup = true
|
||||
tablet.VttabletProcess.EnableSemiSync = true
|
||||
|
||||
tablet.MysqlctlProcess = *cluster.MysqlCtlProcessInstance(tablet.TabletUID, tablet.MySQLPort, localCluster.TmpDirectory)
|
||||
tablet.MysqlctlProcess.InitDBFile = newInitDBFile
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
|
||||
func TestTrivialERS(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -56,7 +56,7 @@ func TestTrivialERS(t *testing.T) {
|
|||
|
||||
func TestReparentIgnoreReplicas(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
var err error
|
||||
|
@ -98,7 +98,7 @@ func TestReparentIgnoreReplicas(t *testing.T) {
|
|||
|
||||
func TestReparentDownPrimary(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -134,7 +134,7 @@ func TestReparentDownPrimary(t *testing.T) {
|
|||
|
||||
func TestReparentNoChoiceDownPrimary(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
var err error
|
||||
|
@ -170,7 +170,7 @@ func TestReparentNoChoiceDownPrimary(t *testing.T) {
|
|||
func TestSemiSyncSetupCorrectly(t *testing.T) {
|
||||
t.Run("semi-sync enabled", func(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -198,7 +198,7 @@ func TestSemiSyncSetupCorrectly(t *testing.T) {
|
|||
|
||||
t.Run("semi-sync disabled", func(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, false)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "none")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -228,7 +228,7 @@ func TestSemiSyncSetupCorrectly(t *testing.T) {
|
|||
// TestERSPromoteRdonly tests that we never end up promoting a rdonly instance as the primary
|
||||
func TestERSPromoteRdonly(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
var err error
|
||||
|
@ -256,7 +256,7 @@ func TestERSPromoteRdonly(t *testing.T) {
|
|||
// TestERSPreventCrossCellPromotion tests that we promote a replica in the same cell as the previous primary if prevent cross cell promotion flag is set
|
||||
func TestERSPreventCrossCellPromotion(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
var err error
|
||||
|
@ -279,7 +279,7 @@ func TestERSPreventCrossCellPromotion(t *testing.T) {
|
|||
// caught up to it by pulling transactions from it
|
||||
func TestPullFromRdonly(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
var err error
|
||||
|
@ -344,7 +344,7 @@ func TestPullFromRdonly(t *testing.T) {
|
|||
// is stopped on the primary elect.
|
||||
func TestNoReplicationStatusAndIOThreadStopped(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
@ -443,7 +443,7 @@ func TestERSForInitialization(t *testing.T) {
|
|||
|
||||
func TestRecoverWithMultipleFailures(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
@ -471,7 +471,7 @@ func TestRecoverWithMultipleFailures(t *testing.T) {
|
|||
// a tablet and hanging while inserting a row in the reparent journal on getting semi-sync ACKs
|
||||
func TestERSFailFast(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
@ -503,7 +503,7 @@ func TestERSFailFast(t *testing.T) {
|
|||
// If there are more than 1, we also fail.
|
||||
func TestReplicationStopped(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
|
|
@ -17,5 +17,38 @@ limitations under the License.
|
|||
package newfeaturetest
|
||||
|
||||
import (
|
||||
_ "vitess.io/vitess/go/vt/log"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"vitess.io/vitess/go/test/endtoend/cluster"
|
||||
"vitess.io/vitess/go/test/endtoend/reparent/utils"
|
||||
)
|
||||
|
||||
func TestCrossCellDurability(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "cross_cell")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
||||
// When tablets[0] is the primary, the only tablet in a different cell is tablets[3].
|
||||
// So the other two should have semi-sync turned off
|
||||
utils.CheckSemiSyncSetupCorrectly(t, tablets[0], "ON")
|
||||
utils.CheckSemiSyncSetupCorrectly(t, tablets[3], "ON")
|
||||
utils.CheckSemiSyncSetupCorrectly(t, tablets[1], "OFF")
|
||||
utils.CheckSemiSyncSetupCorrectly(t, tablets[2], "OFF")
|
||||
|
||||
// Run forced reparent operation, this should proceed unimpeded.
|
||||
out, err := utils.Prs(t, clusterInstance, tablets[3])
|
||||
require.NoError(t, err, out)
|
||||
|
||||
utils.ConfirmReplication(t, tablets[3], []*cluster.Vttablet{tablets[0], tablets[1], tablets[2]})
|
||||
|
||||
// All the tablets will have semi-sync setup since tablets[3] is in Cell2 and all
|
||||
// others are in Cell1, so all of them are eligible to send semi-sync ACKs
|
||||
for _, tablet := range tablets {
|
||||
utils.CheckSemiSyncSetupCorrectly(t, tablet, "ON")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import (
|
|||
|
||||
func TestPrimaryToSpareStateChangeImpossible(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -46,7 +46,7 @@ func TestPrimaryToSpareStateChangeImpossible(t *testing.T) {
|
|||
|
||||
func TestReparentCrossCell(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -60,7 +60,7 @@ func TestReparentCrossCell(t *testing.T) {
|
|||
|
||||
func TestReparentGraceful(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -83,7 +83,7 @@ func TestReparentGraceful(t *testing.T) {
|
|||
// TestPRSWithDrainedLaggingTablet tests that PRS succeeds even if we have a lagging drained tablet
|
||||
func TestPRSWithDrainedLaggingTablet(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -110,7 +110,7 @@ func TestPRSWithDrainedLaggingTablet(t *testing.T) {
|
|||
|
||||
func TestReparentReplicaOffline(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -127,7 +127,7 @@ func TestReparentReplicaOffline(t *testing.T) {
|
|||
|
||||
func TestReparentAvoid(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.DeleteTablet(t, clusterInstance, tablets[2])
|
||||
|
@ -159,14 +159,14 @@ func TestReparentAvoid(t *testing.T) {
|
|||
|
||||
func TestReparentFromOutside(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
reparentFromOutside(t, clusterInstance, false)
|
||||
}
|
||||
|
||||
func TestReparentFromOutsideWithNoPrimary(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -255,7 +255,7 @@ func reparentFromOutside(t *testing.T, clusterInstance *cluster.LocalProcessClus
|
|||
|
||||
func TestReparentWithDownReplica(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -298,7 +298,7 @@ func TestReparentWithDownReplica(t *testing.T) {
|
|||
|
||||
func TestChangeTypeSemiSync(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -362,7 +362,7 @@ func TestChangeTypeSemiSync(t *testing.T) {
|
|||
|
||||
func TestReparentDoesntHangIfPrimaryFails(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
|
||||
|
@ -381,7 +381,7 @@ func TestReparentDoesntHangIfPrimaryFails(t *testing.T) {
|
|||
|
||||
func TestReplicationStatus(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
@ -443,7 +443,7 @@ func TestReplicationStatus(t *testing.T) {
|
|||
// TestFullStatus tests that the RPC FullStatus works as intended.
|
||||
func TestFullStatus(t *testing.T) {
|
||||
defer cluster.PanicHandler(t)
|
||||
clusterInstance := utils.SetupReparentCluster(t, true)
|
||||
clusterInstance := utils.SetupReparentCluster(t, "semi_sync")
|
||||
defer utils.TeardownCluster(clusterInstance)
|
||||
tablets := clusterInstance.Keyspaces[0].Shards[0].Vttablets
|
||||
utils.ConfirmReplication(t, tablets[0], []*cluster.Vttablet{tablets[1], tablets[2], tablets[3]})
|
||||
|
|
|
@ -68,13 +68,13 @@ var (
|
|||
//region cluster setup/teardown
|
||||
|
||||
// SetupReparentCluster is used to setup the reparent cluster
|
||||
func SetupReparentCluster(t *testing.T, enableSemiSync bool) *cluster.LocalProcessCluster {
|
||||
return setupCluster(context.Background(), t, ShardName, []string{cell1, cell2}, []int{3, 1}, enableSemiSync)
|
||||
func SetupReparentCluster(t *testing.T, durability string) *cluster.LocalProcessCluster {
|
||||
return setupCluster(context.Background(), t, ShardName, []string{cell1, cell2}, []int{3, 1}, durability)
|
||||
}
|
||||
|
||||
// SetupRangeBasedCluster sets up the range based cluster
|
||||
func SetupRangeBasedCluster(ctx context.Context, t *testing.T) *cluster.LocalProcessCluster {
|
||||
return setupCluster(ctx, t, ShardName, []string{cell1}, []int{2}, true)
|
||||
return setupCluster(ctx, t, ShardName, []string{cell1}, []int{2}, "semi_sync")
|
||||
}
|
||||
|
||||
// TeardownCluster is used to teardown the reparent cluster
|
||||
|
@ -82,15 +82,13 @@ func TeardownCluster(clusterInstance *cluster.LocalProcessCluster) {
|
|||
clusterInstance.Teardown()
|
||||
}
|
||||
|
||||
func setupCluster(ctx context.Context, t *testing.T, shardName string, cells []string, numTablets []int, enableSemiSync bool) *cluster.LocalProcessCluster {
|
||||
func setupCluster(ctx context.Context, t *testing.T, shardName string, cells []string, numTablets []int, durability string) *cluster.LocalProcessCluster {
|
||||
var tablets []*cluster.Vttablet
|
||||
clusterInstance := cluster.NewCluster(cells[0], Hostname)
|
||||
keyspace := &cluster.Keyspace{Name: KeyspaceName}
|
||||
|
||||
durability := "none"
|
||||
if enableSemiSync {
|
||||
if durability == "semi_sync" {
|
||||
clusterInstance.VtTabletExtraArgs = append(clusterInstance.VtTabletExtraArgs, "--enable_semi_sync")
|
||||
durability = "semi_sync"
|
||||
}
|
||||
|
||||
// Start topo server
|
||||
|
|
|
@ -282,7 +282,6 @@ func initializeClusterLate(t *testing.T) {
|
|||
_, err = tablet.VttabletProcess.QueryTablet(query, keyspace.Name, false)
|
||||
require.NoError(t, err)
|
||||
|
||||
tablet.VttabletProcess.EnableSemiSync = true
|
||||
err = tablet.VttabletProcess.Setup()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
|
@ -761,7 +761,6 @@ func SetupNewClusterSemiSync(t *testing.T) *VtOrcClusterInfo {
|
|||
clusterInstance.VtTabletExtraArgs = []string{
|
||||
"--lock_tables_timeout", "5s",
|
||||
"--disable_active_reparents",
|
||||
"--enable_semi_sync",
|
||||
}
|
||||
|
||||
// Initialize Cluster
|
||||
|
@ -840,7 +839,6 @@ func AddSemiSyncKeyspace(t *testing.T, clusterInfo *VtOrcClusterInfo) {
|
|||
clusterInfo.ClusterInstance.VtTabletExtraArgs = []string{
|
||||
"--lock_tables_timeout", "5s",
|
||||
"--disable_active_reparents",
|
||||
"--enable_semi_sync",
|
||||
}
|
||||
|
||||
// Initialize Cluster
|
||||
|
|
|
@ -11,97 +11,97 @@ func init() {
|
|||
// define files
|
||||
file2 := &embedded.EmbeddedFile{
|
||||
Filename: "gomysql.pc.tmpl",
|
||||
FileModTime: time.Unix(1625867173, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("Name: GoMysql\nDescription: Flags for using mysql C client in go\n"),
|
||||
}
|
||||
file3 := &embedded.EmbeddedFile{
|
||||
Filename: "init_db.sql",
|
||||
FileModTime: time.Unix(1656561956, 0),
|
||||
FileModTime: time.Unix(1658125106, 0),
|
||||
|
||||
Content: string("# This file is executed immediately after mysql_install_db,\n# to initialize a fresh data directory.\n\n###############################################################################\n# WARNING: This sql is *NOT* safe for production use,\n# as it contains default well-known users and passwords.\n# Care should be taken to change these users and passwords\n# for production.\n###############################################################################\n\n###############################################################################\n# Equivalent of mysql_secure_installation\n###############################################################################\n\n# Changes during the init db should not make it to the binlog.\n# They could potentially create errant transactions on replicas.\nSET sql_log_bin = 0;\n# Remove anonymous users.\nDELETE FROM mysql.user WHERE User = '';\n\n# Disable remote root access (only allow UNIX socket).\nDELETE FROM mysql.user WHERE User = 'root' AND Host != 'localhost';\n\n# Remove test database.\nDROP DATABASE IF EXISTS test;\n\n###############################################################################\n# Vitess defaults\n###############################################################################\n\n# Vitess-internal database.\nCREATE DATABASE IF NOT EXISTS _vt;\n# Note that definitions of local_metadata and shard_metadata should be the same\n# as in production which is defined in go/vt/mysqlctl/metadata_tables.go.\nCREATE TABLE IF NOT EXISTS _vt.local_metadata (\n name VARCHAR(255) NOT NULL,\n value VARCHAR(255) NOT NULL,\n db_name VARBINARY(255) NOT NULL,\n PRIMARY KEY (db_name, name)\n ) ENGINE=InnoDB;\nCREATE TABLE IF NOT EXISTS _vt.shard_metadata (\n name VARCHAR(255) NOT NULL,\n value MEDIUMBLOB NOT NULL,\n db_name VARBINARY(255) NOT NULL,\n PRIMARY KEY (db_name, name)\n ) ENGINE=InnoDB;\n\n# Admin user with all privileges.\nCREATE USER 'vt_dba'@'localhost';\nGRANT ALL ON *.* TO 'vt_dba'@'localhost';\nGRANT GRANT OPTION ON *.* TO 'vt_dba'@'localhost';\n\n# User for app traffic, with global read-write access.\nCREATE USER 'vt_app'@'localhost';\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,\n REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,\n LOCK TABLES, EXECUTE, REPLICATION CLIENT, CREATE VIEW,\n SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER\n ON *.* TO 'vt_app'@'localhost';\n\n# User for app debug traffic, with global read access.\nCREATE USER 'vt_appdebug'@'localhost';\nGRANT SELECT, SHOW DATABASES, PROCESS ON *.* TO 'vt_appdebug'@'localhost';\n\n# User for administrative operations that need to be executed as non-SUPER.\n# Same permissions as vt_app here.\nCREATE USER 'vt_allprivs'@'localhost';\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,\n REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,\n LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,\n SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER\n ON *.* TO 'vt_allprivs'@'localhost';\n\n# User for slave replication connections.\nCREATE USER 'vt_repl'@'%';\nGRANT REPLICATION SLAVE ON *.* TO 'vt_repl'@'%';\n\n# User for Vitess VReplication (base vstreamers and vplayer).\nCREATE USER 'vt_filtered'@'localhost';\nGRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, FILE,\n REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES,\n LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW,\n SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER\n ON *.* TO 'vt_filtered'@'localhost';\n\n# User for general MySQL monitoring.\nCREATE USER 'vt_monitoring'@'localhost';\nGRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT, RELOAD\n ON *.* TO 'vt_monitoring'@'localhost';\nGRANT SELECT, UPDATE, DELETE, DROP\n ON performance_schema.* TO 'vt_monitoring'@'localhost';\n\n# User for Orchestrator (https://github.com/openark/orchestrator).\nCREATE USER 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_user_password';\nGRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD\n ON *.* TO 'orc_client_user'@'%';\nGRANT SELECT\n ON _vt.* TO 'orc_client_user'@'%';\n\nFLUSH PRIVILEGES;\n\nRESET SLAVE ALL;\nRESET MASTER;\n"),
|
||||
}
|
||||
file5 := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/default.cnf",
|
||||
FileModTime: time.Unix(1656560071, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("# Global configuration that is auto-included for all MySQL/MariaDB versions\n\ndatadir = {{.DataDir}}\ninnodb_data_home_dir = {{.InnodbDataHomeDir}}\ninnodb_log_group_home_dir = {{.InnodbLogGroupHomeDir}}\nlog-error = {{.ErrorLogPath}}\nlog-bin = {{.BinLogPath}}\nrelay-log = {{.RelayLogPath}}\nrelay-log-index = {{.RelayLogIndexPath}}\npid-file = {{.PidFile}}\nport = {{.MysqlPort}}\n\n{{if .SecureFilePriv}}\nsecure-file-priv = {{.SecureFilePriv}}\n{{end}}\n\n# all db instances should start in read-only mode - once the db is started and\n# fully functional, we'll push it into read-write mode\nread-only\nserver-id = {{.ServerID}}\n\n# all db instances should skip starting replication threads - that way we can do any\n# additional configuration (like enabling semi-sync) before we connect to\n# the source.\nskip_slave_start\nsocket = {{.SocketFile}}\ntmpdir = {{.TmpDir}}\n\nslow-query-log-file = {{.SlowLogPath}}\n\n# These are sensible defaults that apply to all MySQL/MariaDB versions\n\nlong_query_time = 2\nslow-query-log\nskip-name-resolve\nconnect_timeout = 30\ninnodb_lock_wait_timeout = 20\nmax_allowed_packet = 64M\nmax_connections = 500\n\n\n"),
|
||||
}
|
||||
file6 := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mariadb100.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1658142704, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MariaDB 10.0 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync\n# at the proper time when replication is set up, or when a primary is\n# promoted or demoted.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\nslave_net_timeout = 60\n\n# MariaDB 10.0 is unstrict by default\nsql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n"),
|
||||
Content: string("# This file is auto-included when MariaDB 10.0 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# VTTablet will enable semi-sync at the proper time when replication is set up,\n# or when a primary is promoted or demoted based on the durability policy configured.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\nslave_net_timeout = 60\n\n# MariaDB 10.0 is unstrict by default\nsql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n"),
|
||||
}
|
||||
file7 := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mariadb101.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1658142704, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MariaDB 10.1 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync\n# at the proper time when replication is set up, or when a primary is\n# promoted or demoted.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\nslave_net_timeout = 60\n\n# MariaDB 10.1 default is only no-engine-substitution and no-auto-create-user\nsql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n"),
|
||||
Content: string("# This file is auto-included when MariaDB 10.1 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# VTTablet will enable semi-sync at the proper time when replication is set up,\n# or when a primary is promoted or demoted based on the durability policy configured.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\nslave_net_timeout = 60\n\n# MariaDB 10.1 default is only no-engine-substitution and no-auto-create-user\nsql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n"),
|
||||
}
|
||||
file8 := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mariadb102.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1658142704, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MariaDB 10.2 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync\n# at the proper time when replication is set up, or when a primary is\n# promoted or demoted.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n"),
|
||||
Content: string("# This file is auto-included when MariaDB 10.2 is detected.\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# VTTablet will enable semi-sync at the proper time when replication is set up,\n# or when a primary is promoted or demoted based on the durability policy configured.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n"),
|
||||
}
|
||||
file9 := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mariadb103.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MariaDB 10.3 is detected.\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n\n"),
|
||||
}
|
||||
filea := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mariadb104.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MariaDB 10.4 is detected.\n\n# enable strict mode so it's safe to compare sequence numbers across different server IDs.\ngtid_strict_mode = 1\ninnodb_stats_persistent = 0\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\nexpire_logs_days = 3\n\nsync_binlog = 1\nbinlog_format = ROW\nlog_slave_updates\nexpire_logs_days = 3\n\n# In MariaDB the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n\n"),
|
||||
}
|
||||
fileb := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mysql57.cnf",
|
||||
FileModTime: time.Unix(1656826694, 0),
|
||||
FileModTime: time.Unix(1658142704, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MySQL 5.7 is detected.\n\n# MySQL 5.7 does not enable the binary log by default, and \n# info repositories default to file\n\ngtid_mode = ON\nlog_slave_updates\nenforce_gtid_consistency\nexpire_logs_days = 3\nmaster_info_repository = TABLE\nrelay_log_info_repository = TABLE\nrelay_log_purge = 1\nrelay_log_recovery = 1\n\n# In MySQL 5.7 the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync\n# at the proper time when replication is set up, or when a primary is\n# promoted or demoted.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n"),
|
||||
Content: string("# This file is auto-included when MySQL 5.7 is detected.\n\n# MySQL 5.7 does not enable the binary log by default, and \n# info repositories default to file\n\ngtid_mode = ON\nlog_slave_updates\nenforce_gtid_consistency\nexpire_logs_days = 3\nmaster_info_repository = TABLE\nrelay_log_info_repository = TABLE\nrelay_log_purge = 1\nrelay_log_recovery = 1\n\n# In MySQL 5.7 the default charset is latin1\n\ncharacter_set_server = utf8\ncollation_server = utf8_general_ci\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# VTTablet will enable semi-sync at the proper time when replication is set up,\n# or when a primary is promoted or demoted based on the durability policy configured.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# When semi-sync is enabled, don't allow fallback to async\n# if you get no ack, or have no replicas. This is necessary to\n# prevent alternate futures when doing a failover in response to\n# a primary that becomes unresponsive.\nrpl_semi_sync_master_timeout = 1000000000000000000\nrpl_semi_sync_master_wait_no_slave = 1\n\n"),
|
||||
}
|
||||
filec := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/mysql80.cnf",
|
||||
FileModTime: time.Unix(1656826694, 0),
|
||||
FileModTime: time.Unix(1658142704, 0),
|
||||
|
||||
Content: string("# This file is auto-included when MySQL 8.0 is detected.\n\n# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories\n# It does not enable GTIDs or enforced GTID consistency\n\ngtid_mode = ON\nenforce_gtid_consistency\nrelay_log_recovery = 1\nbinlog_expire_logs_seconds = 259200\n\n# disable mysqlx\nmysqlx = 0\n\n# 8.0 changes the default auth-plugin to caching_sha2_password\ndefault_authentication_plugin = mysql_native_password\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync\n# at the proper time when replication is set up, or when a primary is\n# promoted or demoted.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# MySQL 8.0 will not load plugins during --initialize\n# which makes these options unknown. Prefixing with --loose\n# tells the server it's fine if they are not understood.\nloose_rpl_semi_sync_master_timeout = 1000000000000000000\nloose_rpl_semi_sync_master_wait_no_slave = 1\n\n"),
|
||||
Content: string("# This file is auto-included when MySQL 8.0 is detected.\n\n# MySQL 8.0 enables binlog by default with sync_binlog and TABLE info repositories\n# It does not enable GTIDs or enforced GTID consistency\n\ngtid_mode = ON\nenforce_gtid_consistency\nrelay_log_recovery = 1\nbinlog_expire_logs_seconds = 259200\n\n# disable mysqlx\nmysqlx = 0\n\n# 8.0 changes the default auth-plugin to caching_sha2_password\ndefault_authentication_plugin = mysql_native_password\n\n# Semi-sync replication is required for automated unplanned failover\n# (when the primary goes away). Here we just load the plugin so it's\n# available if desired, but it's disabled at startup.\n#\n# VTTablet will enable semi-sync at the proper time when replication is set up,\n# or when a primary is promoted or demoted based on the durability policy configured.\nplugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so\n\n# MySQL 8.0 will not load plugins during --initialize\n# which makes these options unknown. Prefixing with --loose\n# tells the server it's fine if they are not understood.\nloose_rpl_semi_sync_master_timeout = 1000000000000000000\nloose_rpl_semi_sync_master_wait_no_slave = 1\n\n"),
|
||||
}
|
||||
filed := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/sbr.cnf",
|
||||
FileModTime: time.Unix(1625867173, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("# This file is used to allow legacy tests to pass\n# In theory it should not be required\nbinlog_format=statement\n"),
|
||||
}
|
||||
filee := &embedded.EmbeddedFile{
|
||||
Filename: "mycnf/test-suite.cnf",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("# This sets some unsafe settings specifically for \n# the test-suite which is currently MySQL 5.7 based\n# In future it should be renamed testsuite.cnf\n\ninnodb_buffer_pool_size = 32M\ninnodb_flush_log_at_trx_commit = 0\ninnodb_log_buffer_size = 1M\ninnodb_log_file_size = 5M\n\n# Native AIO tends to run into aio-max-nr limit during test startup.\ninnodb_use_native_aio = 0\n\nkey_buffer_size = 2M\nsync_binlog=0\ninnodb_doublewrite=0\n\n# These two settings are required for the testsuite to pass, \n# but enabling them does not spark joy. They should be removed\n# in the future. See:\n# https://github.com/vitessio/vitess/issues/5396\n\nsql_mode = STRICT_TRANS_TABLES\n\n# set a short heartbeat interval in order to detect failures quickly\nslave_net_timeout = 4\n"),
|
||||
}
|
||||
fileg := &embedded.EmbeddedFile{
|
||||
Filename: "orchestrator/default.json",
|
||||
FileModTime: time.Unix(1625867173, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("{\n \"Debug\": true,\n \"MySQLTopologyUser\": \"orc_client_user\",\n \"MySQLTopologyPassword\": \"orc_client_user_password\",\n \"MySQLReplicaUser\": \"vt_repl\",\n \"MySQLReplicaPassword\": \"\",\n \"RecoveryPeriodBlockSeconds\": 5\n}\n"),
|
||||
}
|
||||
filei := &embedded.EmbeddedFile{
|
||||
Filename: "tablet/default.yaml",
|
||||
FileModTime: time.Unix(1636429180, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("tabletID: zone-1234\n\ninit:\n dbName: # init_db_name_override\n keyspace: # init_keyspace\n shard: # init_shard\n tabletType: # init_tablet_type\n timeoutSeconds: 60 # init_timeout\n\ndb:\n socket: # db_socket\n host: # db_host\n port: 0 # db_port\n charSet: # db_charset\n flags: 0 # db_flags\n flavor: # db_flavor\n sslCa: # db_ssl_ca\n sslCaPath: # db_ssl_ca_path\n sslCert: # db_ssl_cert\n sslKey: # db_ssl_key\n serverName: # db_server_name\n connectTimeoutMilliseconds: 0 # db_connect_timeout_ms\n app:\n user: vt_app # db_app_user\n password: # db_app_password\n useSsl: true # db_app_use_ssl\n preferTcp: false\n dba:\n user: vt_dba # db_dba_user\n password: # db_dba_password\n useSsl: true # db_dba_use_ssl\n preferTcp: false\n filtered:\n user: vt_filtered # db_filtered_user\n password: # db_filtered_password\n useSsl: true # db_filtered_use_ssl\n preferTcp: false\n repl:\n user: vt_repl # db_repl_user\n password: # db_repl_password\n useSsl: true # db_repl_use_ssl\n preferTcp: false\n appdebug:\n user: vt_appdebug # db_appdebug_user\n password: # db_appdebug_password\n useSsl: true # db_appdebug_use_ssl\n preferTcp: false\n allprivs:\n user: vt_allprivs # db_allprivs_user\n password: # db_allprivs_password\n useSsl: true # db_allprivs_use_ssl\n preferTcp: false\n\noltpReadPool:\n size: 16 # queryserver-config-pool-size\n timeoutSeconds: 0 # queryserver-config-query-pool-timeout\n idleTimeoutSeconds: 1800 # queryserver-config-idle-timeout\n prefillParallelism: 0 # queryserver-config-pool-prefill-parallelism\n maxWaiters: 50000 # queryserver-config-query-pool-waiter-cap\n\nolapReadPool:\n size: 200 # queryserver-config-stream-pool-size\n timeoutSeconds: 0 # queryserver-config-query-pool-timeout\n idleTimeoutSeconds: 1800 # queryserver-config-idle-timeout\n prefillParallelism: 0 # queryserver-config-stream-pool-prefill-parallelism\n maxWaiters: 0\n\ntxPool:\n size: 20 # queryserver-config-transaction-cap\n timeoutSeconds: 1 # queryserver-config-txpool-timeout\n idleTimeoutSeconds: 1800 # queryserver-config-idle-timeout\n prefillParallelism: 0 # queryserver-config-transaction-prefill-parallelism\n maxWaiters: 50000 # queryserver-config-txpool-waiter-cap\n\noltp:\n queryTimeoutSeconds: 30 # queryserver-config-query-timeout\n txTimeoutSeconds: 30 # queryserver-config-transaction-timeout\n maxRows: 10000 # queryserver-config-max-result-size\n warnRows: 0 # queryserver-config-warn-result-size\n\nhealthcheck:\n intervalSeconds: 20 # health_check_interval\n degradedThresholdSeconds: 30 # degraded_threshold\n unhealthyThresholdSeconds: 7200 # unhealthy_threshold\n\ngracePeriods:\n shutdownSeconds: 0 # shutdown_grace_period\n transitionSeconds: 0 # serving_state_grace_period\n\nreplicationTracker:\n mode: disable # enable_replication_reporter\n heartbeatIntervalMilliseconds: 0 # heartbeat_enable, heartbeat_interval\n\nhotRowProtection:\n mode: disable|dryRun|enable # enable_hot_row_protection, enable_hot_row_protection_dry_run\n # Recommended value: same as txPool.size.\n maxQueueSize: 20 # hot_row_protection_max_queue_size\n maxGlobalQueueSize: 1000 # hot_row_protection_max_global_queue_size\n maxConcurrency: 5 # hot_row_protection_concurrent_transactions\n\nconsolidator: enable|disable|notOnPrimary # enable-consolidator, enable-consolidator-replicas\npassthroughDML: false # queryserver-config-passthrough-dmls\nstreamBufferSize: 32768 # queryserver-config-stream-buffer-size\nqueryCacheSize: 5000 # queryserver-config-query-cache-size\nschemaReloadIntervalSeconds: 1800 # queryserver-config-schema-reload-time\nwatchReplication: false # watch_replication_stream\nterseErrors: false # queryserver-config-terse-errors\nmessagePostponeParallelism: 4 # queryserver-config-message-postpone-cap\ncacheResultFields: true # enable-query-plan-field-caching\n\n\n# The following flags are currently not supported.\n# enforce_strict_trans_tables\n# queryserver-config-strict-table-acl\n# queryserver-config-enable-table-acl-dry-run\n# queryserver-config-acl-exempt-acl\n# enable-tx-throttler\n# tx-throttler-config\n# tx-throttler-healthcheck-cells\n# enable_transaction_limit\n# enable_transaction_limit_dry_run\n# transaction_limit_per_user\n# transaction_limit_by_username\n# transaction_limit_by_principal\n# transaction_limit_by_component\n# transaction_limit_by_subcomponent\n"),
|
||||
}
|
||||
filej := &embedded.EmbeddedFile{
|
||||
Filename: "zk-client-dev.json",
|
||||
FileModTime: time.Unix(1625867173, 0),
|
||||
FileModTime: time.Unix(1650035622, 0),
|
||||
|
||||
Content: string("{\n \"local\": \"localhost:3863\",\n \"global\": \"localhost:3963\"\n}\n"),
|
||||
}
|
||||
filel := &embedded.EmbeddedFile{
|
||||
Filename: "zkcfg/zoo.cfg",
|
||||
FileModTime: time.Unix(1653065346, 0),
|
||||
FileModTime: time.Unix(1658125106, 0),
|
||||
|
||||
Content: string("tickTime=2000\ndataDir={{.DataDir}}\nclientPort={{.ClientPort}}\ninitLimit=5\nsyncLimit=2\nmaxClientCnxns=0\n# enable commands like ruok by default\n4lw.commands.whitelist=*\n{{range .Servers}}\nserver.{{.ServerId}}={{.Hostname}}:{{.LeaderPort}}:{{.ElectionPort}}\n{{end}}\n"),
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ func init() {
|
|||
// define dirs
|
||||
dir1 := &embedded.EmbeddedDir{
|
||||
Filename: "",
|
||||
DirModTime: time.Unix(1656561956, 0),
|
||||
DirModTime: time.Unix(1658125106, 0),
|
||||
ChildFiles: []*embedded.EmbeddedFile{
|
||||
file2, // "gomysql.pc.tmpl"
|
||||
file3, // "init_db.sql"
|
||||
|
@ -119,7 +119,7 @@ func init() {
|
|||
}
|
||||
dir4 := &embedded.EmbeddedDir{
|
||||
Filename: "mycnf",
|
||||
DirModTime: time.Unix(1656826694, 0),
|
||||
DirModTime: time.Unix(1658142704, 0),
|
||||
ChildFiles: []*embedded.EmbeddedFile{
|
||||
file5, // "mycnf/default.cnf"
|
||||
file6, // "mycnf/mariadb100.cnf"
|
||||
|
@ -136,7 +136,7 @@ func init() {
|
|||
}
|
||||
dirf := &embedded.EmbeddedDir{
|
||||
Filename: "orchestrator",
|
||||
DirModTime: time.Unix(1625867173, 0),
|
||||
DirModTime: time.Unix(1650035622, 0),
|
||||
ChildFiles: []*embedded.EmbeddedFile{
|
||||
fileg, // "orchestrator/default.json"
|
||||
|
||||
|
@ -144,7 +144,7 @@ func init() {
|
|||
}
|
||||
dirh := &embedded.EmbeddedDir{
|
||||
Filename: "tablet",
|
||||
DirModTime: time.Unix(1636429180, 0),
|
||||
DirModTime: time.Unix(1650035622, 0),
|
||||
ChildFiles: []*embedded.EmbeddedFile{
|
||||
filei, // "tablet/default.yaml"
|
||||
|
||||
|
@ -152,7 +152,7 @@ func init() {
|
|||
}
|
||||
dirk := &embedded.EmbeddedDir{
|
||||
Filename: "zkcfg",
|
||||
DirModTime: time.Unix(1653065346, 0),
|
||||
DirModTime: time.Unix(1658125106, 0),
|
||||
ChildFiles: []*embedded.EmbeddedFile{
|
||||
filel, // "zkcfg/zoo.cfg"
|
||||
|
||||
|
@ -175,7 +175,7 @@ func init() {
|
|||
// register embeddedBox
|
||||
embedded.RegisterEmbeddedBox(`../../../config`, &embedded.EmbeddedBox{
|
||||
Name: `../../../config`,
|
||||
Time: time.Unix(1656561956, 0),
|
||||
Time: time.Unix(1658125106, 0),
|
||||
Dirs: map[string]*embedded.EmbeddedDir{
|
||||
"": dir1,
|
||||
"mycnf": dir4,
|
||||
|
|
|
@ -39,7 +39,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
enableSemiSync = flag.Bool("enable_semi_sync", false, "Enable semi-sync when configuring replication, on primary and replica tablets only (rdonly tablets will not ack).")
|
||||
_ = flag.Bool("enable_semi_sync", false, "DEPRECATED - Set the correct durability policy on the keyspace instead.")
|
||||
setSuperReadOnly = flag.Bool("use_super_read_only", false, "Set super_read_only flag when performing planned failover.")
|
||||
)
|
||||
|
||||
|
@ -985,45 +985,18 @@ func isPrimaryEligible(tabletType topodatapb.TabletType) bool {
|
|||
}
|
||||
|
||||
func (tm *TabletManager) fixSemiSync(tabletType topodatapb.TabletType, semiSync SemiSyncAction) error {
|
||||
if !*enableSemiSync {
|
||||
// Semi-sync handling is not enabled.
|
||||
if semiSync == SemiSyncActionSet {
|
||||
log.Error("invalid configuration - semi-sync should be setup according to durability policies, but enable_semi_sync is not set")
|
||||
}
|
||||
switch semiSync {
|
||||
case SemiSyncActionNone:
|
||||
return nil
|
||||
}
|
||||
|
||||
// Only enable if we're eligible for becoming primary (REPLICA type).
|
||||
// Ineligible tablets (RDONLY) shouldn't ACK because we'll never promote them.
|
||||
if !isPrimaryEligible(tabletType) {
|
||||
if semiSync == SemiSyncActionSet {
|
||||
log.Error("invalid configuration - semi-sync should be setup according to durability policies, but the tablet is not primaryEligible")
|
||||
}
|
||||
case SemiSyncActionSet:
|
||||
// Always enable replica-side since it doesn't hurt to keep it on for a primary.
|
||||
// The primary-side needs to be off for a replica, or else it will get stuck.
|
||||
return tm.MysqlDaemon.SetSemiSyncEnabled(tabletType == topodatapb.TabletType_PRIMARY, true)
|
||||
case SemiSyncActionUnset:
|
||||
return tm.MysqlDaemon.SetSemiSyncEnabled(false, false)
|
||||
default:
|
||||
return vterrors.Errorf(vtrpc.Code_INTERNAL, "Unknown SemiSyncAction - %v", semiSync)
|
||||
}
|
||||
|
||||
if semiSync == SemiSyncActionUnset {
|
||||
log.Error("invalid configuration - enabling semi sync even though not specified by durability policies. Possibly in the process of upgrading.")
|
||||
}
|
||||
// Always enable replica-side since it doesn't hurt to keep it on for a primary.
|
||||
// The primary-side needs to be off for a replica, or else it will get stuck.
|
||||
return tm.MysqlDaemon.SetSemiSyncEnabled(tabletType == topodatapb.TabletType_PRIMARY, true)
|
||||
|
||||
// This following code will be uncommented and the above deleted when we are ready to use the
|
||||
// durability policies for setting the semi_sync information
|
||||
|
||||
//switch semiSync {
|
||||
//case SemiSyncActionNone:
|
||||
// return nil
|
||||
//case SemiSyncActionSet:
|
||||
// // Always enable replica-side since it doesn't hurt to keep it on for a primary.
|
||||
// // The primary-side needs to be off for a replica, or else it will get stuck.
|
||||
// return tm.MysqlDaemon.SetSemiSyncEnabled(tabletType == topodatapb.TabletType_PRIMARY, true)
|
||||
//case SemiSyncActionUnset:
|
||||
// return tm.MysqlDaemon.SetSemiSyncEnabled(false, false)
|
||||
//default:
|
||||
// return vterrors.Errorf(vtrpc.Code_INTERNAL, "Unknown SemiSyncAction - %v", semiSync)
|
||||
//}
|
||||
}
|
||||
|
||||
func (tm *TabletManager) isPrimarySideSemiSyncEnabled() bool {
|
||||
|
@ -1032,14 +1005,10 @@ func (tm *TabletManager) isPrimarySideSemiSyncEnabled() bool {
|
|||
}
|
||||
|
||||
func (tm *TabletManager) fixSemiSyncAndReplication(tabletType topodatapb.TabletType, semiSync SemiSyncAction) error {
|
||||
if !*enableSemiSync {
|
||||
// Semi-sync handling is not enabled.
|
||||
if semiSync == SemiSyncActionNone {
|
||||
// Semi-sync handling is not required.
|
||||
return nil
|
||||
}
|
||||
//if semiSync == SemiSyncActionNone {
|
||||
// // Semi-sync handling is not required.
|
||||
// return nil
|
||||
//}
|
||||
|
||||
if tabletType == topodatapb.TabletType_PRIMARY {
|
||||
// Primary is special. It is always handled at the
|
||||
|
|
|
@ -17,16 +17,11 @@ limitations under the License.
|
|||
package tabletmanager
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"vitess.io/vitess/go/vt/proto/topodata"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"vitess.io/vitess/go/vt/mysqlctl/fakemysqldaemon"
|
||||
|
@ -79,117 +74,3 @@ func TestPromoteReplicaReplicationManagerFailure(t *testing.T) {
|
|||
// At the end we expect the replication manager to be stopped.
|
||||
require.True(t, tm.replManager.ticks.Running())
|
||||
}
|
||||
|
||||
func captureStderr(f func()) (string, error) {
|
||||
old := os.Stderr // keep backup of the real stderr
|
||||
r, w, err := os.Pipe()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
os.Stderr = w
|
||||
|
||||
outC := make(chan string)
|
||||
// copy the output in a separate goroutine so printing can't block indefinitely
|
||||
go func() {
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
outC <- buf.String()
|
||||
}()
|
||||
|
||||
// calling function which stderr we are going to capture:
|
||||
f()
|
||||
|
||||
// back to normal state
|
||||
w.Close()
|
||||
os.Stderr = old // restoring the real stderr
|
||||
return <-outC, nil
|
||||
}
|
||||
|
||||
func TestTabletManager_fixSemiSync(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
tabletType topodata.TabletType
|
||||
semiSync SemiSyncAction
|
||||
logOutput string
|
||||
shouldEnableSemiSync bool
|
||||
}{
|
||||
{
|
||||
name: "enableSemiSync=true(primary eligible),durabilitySemiSync=true",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionSet,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=true(primary eligible),durabilitySemiSync=false",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionUnset,
|
||||
logOutput: "invalid configuration - enabling semi sync even though not specified by durability policies.",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=true(primary eligible),durabilitySemiSync=none",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionNone,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=true(primary not-eligible),durabilitySemiSync=true",
|
||||
tabletType: topodata.TabletType_DRAINED,
|
||||
semiSync: SemiSyncActionSet,
|
||||
logOutput: "invalid configuration - semi-sync should be setup according to durability policies, but the tablet is not primaryEligible",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=true(primary not-eligible),durabilitySemiSync=false",
|
||||
tabletType: topodata.TabletType_DRAINED,
|
||||
semiSync: SemiSyncActionUnset,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=true(primary not-eligible),durabilitySemiSync=none",
|
||||
tabletType: topodata.TabletType_DRAINED,
|
||||
semiSync: SemiSyncActionNone,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: true,
|
||||
}, {
|
||||
name: "enableSemiSync=false,durabilitySemiSync=true",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionSet,
|
||||
logOutput: "invalid configuration - semi-sync should be setup according to durability policies, but enable_semi_sync is not set",
|
||||
shouldEnableSemiSync: false,
|
||||
}, {
|
||||
name: "enableSemiSync=false,durabilitySemiSync=false",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionUnset,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: false,
|
||||
}, {
|
||||
name: "enableSemiSync=false,durabilitySemiSync=none",
|
||||
tabletType: topodata.TabletType_REPLICA,
|
||||
semiSync: SemiSyncActionNone,
|
||||
logOutput: "",
|
||||
shouldEnableSemiSync: false,
|
||||
},
|
||||
}
|
||||
oldEnableSemiSync := *enableSemiSync
|
||||
defer func() {
|
||||
*enableSemiSync = oldEnableSemiSync
|
||||
}()
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
*enableSemiSync = tt.shouldEnableSemiSync
|
||||
fakeMysql := fakemysqldaemon.NewFakeMysqlDaemon(nil)
|
||||
tm := &TabletManager{
|
||||
MysqlDaemon: fakeMysql,
|
||||
}
|
||||
logOutput, err := captureStderr(func() {
|
||||
err := tm.fixSemiSync(tt.tabletType, tt.semiSync)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
if tt.logOutput != "" {
|
||||
require.Contains(t, logOutput, tt.logOutput)
|
||||
} else {
|
||||
require.Equal(t, "", logOutput)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ limitations under the License.
|
|||
package testlib
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -25,11 +24,6 @@ import (
|
|||
"vitess.io/vitess/go/vt/topo/topoproto"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// Enable semi-sync for all testlib tests.
|
||||
flag.Set("enable_semi_sync", "true")
|
||||
}
|
||||
|
||||
func checkSemiSyncEnabled(t *testing.T, primary, replica bool, tablets ...*FakeTablet) {
|
||||
for _, tablet := range tablets {
|
||||
assert.Equal(t, primary, tablet.FakeMysqlDaemon.SemiSyncPrimaryEnabled, "%v: SemiSyncPrimaryEnabled", topoproto.TabletAliasString(tablet.Tablet.Alias))
|
||||
|
|
|
@ -19,9 +19,8 @@ innodb_use_native_aio = 0
|
|||
# (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.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# When semi-sync is enabled, don't allow fallback to async
|
||||
|
|
|
@ -21,9 +21,8 @@ collation_server = utf8_general_ci
|
|||
# (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.
|
||||
# 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_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so
|
||||
|
||||
# When semi-sync is enabled, don't allow fallback to async
|
||||
|
|
|
@ -150,7 +150,6 @@ exec $VTROOT/bin/vttablet \
|
|||
--tablet-path $alias \
|
||||
--tablet_hostname "$vthost" \
|
||||
--health_check_interval 5s \
|
||||
--enable_semi_sync=false \
|
||||
--disable_active_reparents=true \
|
||||
--port $web_port \
|
||||
--grpc_port $grpc_port \
|
||||
|
|
Загрузка…
Ссылка в новой задаче