From 62b05c231c8605092994a0605443e325942d5452 Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Mon, 1 Jan 2024 01:52:34 +0530 Subject: [PATCH 1/9] Add unmanaged flag at vttablet level Signed-off-by: Noble Mittal --- .../vttablet/tabletserver/tabletenv/config.go | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 25352aba91b..35b0d96d32e 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -17,6 +17,7 @@ limitations under the License. package tabletenv import ( + "context" "encoding/json" "errors" "fmt" @@ -27,6 +28,7 @@ import ( "google.golang.org/protobuf/encoding/prototext" "vitess.io/vitess/go/flagutil" + "vitess.io/vitess/go/mysql" "vitess.io/vitess/go/streamlog" "vitess.io/vitess/go/vt/dbconfigs" "vitess.io/vitess/go/vt/log" @@ -207,6 +209,8 @@ func registerTabletEnvFlags(fs *pflag.FlagSet) { fs.BoolVar(¤tConfig.EnableViews, "queryserver-enable-views", false, "Enable views support in vttablet.") fs.BoolVar(¤tConfig.EnablePerWorkloadTableMetrics, "enable-per-workload-table-metrics", defaultConfig.EnablePerWorkloadTableMetrics, "If true, query counts and query error metrics include a label that identifies the workload") + + fs.BoolVar(¤tConfig.UnmanagedTablet, "unmanaged", false, "Indicates an unmanaged tablet, i.e. using an external mysql-compatible database") } var ( @@ -292,6 +296,8 @@ func Init() { type TabletConfig struct { DB *dbconfigs.DBConfigs `json:"db,omitempty"` + UnmanagedTablet bool `json:"-"` + OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"` OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"` TxPool ConnPoolConfig `json:"txPool,omitempty"` @@ -858,6 +864,9 @@ func (c *TabletConfig) TxTimeoutForWorkload(workload querypb.ExecuteOptions_Work // Verify checks for contradicting flags. func (c *TabletConfig) Verify() error { + if err := c.verifyUnmanagedTabletConfig(); err != nil { + return err + } if err := c.verifyTransactionLimitConfig(); err != nil { return err } @@ -879,6 +888,51 @@ func (c *TabletConfig) Verify() error { return nil } +// verifyUnmanagedTabletConfig checks unmanaged tablet related config for sanity +func (c *TabletConfig) verifyUnmanagedTabletConfig() error { + isUnmanaged := c.UnmanagedTablet + + // Skip checks if tablet is not unmanaged + if !isUnmanaged { + return nil + } + + // Throw error if both host and socket are null + if !c.DB.HasGlobalSettings() { + return errors.New("no connection parameters specified but unmanaged mode specified") + } + if c.DB.App.User == "" { + return errors.New("database app user not specified") + } + if c.DB.App.Password == "" { + return errors.New("database app user password not specified") + } + + err := c.checkConnectionForExternalMysql() + + return err +} + +// Test connectivity of external mysql +func (c *TabletConfig) checkConnectionForExternalMysql() error { + params := mysql.ConnParams{ + Host: c.DB.Host, + Port: c.DB.Port, + DbName: c.DB.DBName, + Uname: c.DB.App.User, + Pass: c.DB.App.Password, + UnixSocket: c.DB.Socket, + } + + conn, err := mysql.Connect(context.Background(), ¶ms) + if err != nil { + return err + } + + err = conn.Ping() + return err +} + // verifyTransactionLimitConfig checks TransactionLimitConfig for sanity func (c *TabletConfig) verifyTransactionLimitConfig() error { actual, dryRun := c.EnableTransactionLimit, c.EnableTransactionLimitDryRun From b4fb838158afca025ff8b8244bbf7ebd137f6e79 Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Wed, 3 Jan 2024 22:51:01 +0530 Subject: [PATCH 2/9] Add unmanaged flag to vttablet.txt and vtcombo.txt for e2e tests Signed-off-by: Noble Mittal --- go/flags/endtoend/vtcombo.txt | 1 + go/flags/endtoend/vttablet.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index 72771f18973..cb891172b70 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -396,6 +396,7 @@ Flags: --tx_throttler_config string The configuration of the transaction throttler as a text-formatted throttlerdata.Configuration protocol buffer message. (default "target_replication_lag_sec:2 max_replication_lag_sec:10 initial_rate:100 max_increase:1 emergency_decrease:0.5 min_duration_between_increases_sec:40 max_duration_between_increases_sec:62 min_duration_between_decreases_sec:20 spread_backlog_across_sec:20 age_bad_rate_after_sec:180 bad_rate_increase:0.1 max_rate_approach_threshold:0.9") --tx_throttler_healthcheck_cells strings A comma-separated list of cells. Only tabletservers running in these cells will be monitored for replication lag by the transaction throttler. --unhealthy_threshold duration replication lag after which a replica is considered unhealthy (default 2h0m0s) + --unmanaged Indicates an unmanaged tablet, i.e. using an external mysql-compatible database --v Level log level for V logs -v, --version print binary version --vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index e7432a9151b..a7c63dbf38e 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -400,6 +400,7 @@ Flags: --tx_throttler_config string The configuration of the transaction throttler as a text-formatted throttlerdata.Configuration protocol buffer message. (default "target_replication_lag_sec:2 max_replication_lag_sec:10 initial_rate:100 max_increase:1 emergency_decrease:0.5 min_duration_between_increases_sec:40 max_duration_between_increases_sec:62 min_duration_between_decreases_sec:20 spread_backlog_across_sec:20 age_bad_rate_after_sec:180 bad_rate_increase:0.1 max_rate_approach_threshold:0.9") --tx_throttler_healthcheck_cells strings A comma-separated list of cells. Only tabletservers running in these cells will be monitored for replication lag by the transaction throttler. --unhealthy_threshold duration replication lag after which a replica is considered unhealthy (default 2h0m0s) + --unmanaged Indicates an unmanaged tablet, i.e. using an external mysql-compatible database --v Level log level for V logs -v, --version print binary version --vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging From 42a745094ad960f92fd56d03fe4f551fdb5cec81 Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Wed, 10 Jan 2024 00:32:25 +0530 Subject: [PATCH 3/9] Remove unnecessary variable declarations and assignments Signed-off-by: Noble Mittal --- go/vt/vttablet/tabletserver/tabletenv/config.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 35b0d96d32e..4ae9eae0a09 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -908,9 +908,7 @@ func (c *TabletConfig) verifyUnmanagedTabletConfig() error { return errors.New("database app user password not specified") } - err := c.checkConnectionForExternalMysql() - - return err + return c.checkConnectionForExternalMysql() } // Test connectivity of external mysql @@ -929,8 +927,7 @@ func (c *TabletConfig) checkConnectionForExternalMysql() error { return err } - err = conn.Ping() - return err + return conn.Ping() } // verifyTransactionLimitConfig checks TransactionLimitConfig for sanity From e7a2e6c161e0ec997d9681ebdad1c106d926a6b5 Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Tue, 13 Feb 2024 02:46:57 +0530 Subject: [PATCH 4/9] Add fixing replication validation in unmanaged tablets Signed-off-by: Noble Mittal --- go/vt/vttablet/tabletserver/tabletenv/config.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 4ae9eae0a09..e6f401cbc2c 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -32,6 +32,7 @@ import ( "vitess.io/vitess/go/streamlog" "vitess.io/vitess/go/vt/dbconfigs" "vitess.io/vitess/go/vt/log" + "vitess.io/vitess/go/vt/mysqlctl" "vitess.io/vitess/go/vt/servenv" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/throttler" @@ -296,7 +297,7 @@ func Init() { type TabletConfig struct { DB *dbconfigs.DBConfigs `json:"db,omitempty"` - UnmanagedTablet bool `json:"-"` + UnmanagedTablet bool `json:"unmanaged,omitempty"` OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"` OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"` @@ -890,10 +891,8 @@ func (c *TabletConfig) Verify() error { // verifyUnmanagedTabletConfig checks unmanaged tablet related config for sanity func (c *TabletConfig) verifyUnmanagedTabletConfig() error { - isUnmanaged := c.UnmanagedTablet - // Skip checks if tablet is not unmanaged - if !isUnmanaged { + if !c.UnmanagedTablet { return nil } @@ -907,6 +906,9 @@ func (c *TabletConfig) verifyUnmanagedTabletConfig() error { if c.DB.App.Password == "" { return errors.New("database app user password not specified") } + if !mysqlctl.DisableActiveReparents { + return errors.New("fixing replication should be disabled on unmanaged tablets") + } return c.checkConnectionForExternalMysql() } @@ -927,6 +929,8 @@ func (c *TabletConfig) checkConnectionForExternalMysql() error { return err } + defer conn.Close() + return conn.Ping() } From 97cbe8260f81e039531b0a455a03090b33a34570 Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Mon, 26 Feb 2024 00:34:19 +0530 Subject: [PATCH 5/9] Add verifyUnmanagedTabletConfig tests for unmanaged mode Signed-off-by: Noble Mittal --- .../tabletserver/tabletenv/config_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config_test.go b/go/vt/vttablet/tabletserver/tabletenv/config_test.go index 1cf1559ba6e..5358353146b 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config_test.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config_test.go @@ -24,8 +24,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "vitess.io/vitess/go/mysql/fakesqldb" "vitess.io/vitess/go/test/utils" "vitess.io/vitess/go/vt/dbconfigs" + "vitess.io/vitess/go/vt/mysqlctl" "vitess.io/vitess/go/vt/throttler" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vterrors" @@ -450,3 +452,42 @@ func TestVerifyTxThrottlerConfig(t *testing.T) { }) } } + +func TestVerifyUnmanagedTabletConfig(t *testing.T) { + oldDisableActiveReparents := mysqlctl.DisableActiveReparents + defer func() { + mysqlctl.DisableActiveReparents = oldDisableActiveReparents + }() + + config := defaultConfig + + db := fakesqldb.New(t) + defer db.Close() + + params := db.ConnParams() + config.DB = dbconfigs.NewTestDBConfigs(*params, *params, "") + + // By default, unmanaged mode should be false + err := config.verifyUnmanagedTabletConfig() + assert.Nil(t, err) + + config.UnmanagedTablet = true + err = config.verifyUnmanagedTabletConfig() + assert.EqualError(t, err, "no connection parameters specified but unmanaged mode specified") + + config.DB.Socket = db.ConnParams().UnixSocket + err = config.verifyUnmanagedTabletConfig() + assert.EqualError(t, err, "database app user not specified") + + config.DB.App.User = "testUser" + err = config.verifyUnmanagedTabletConfig() + assert.EqualError(t, err, "database app user password not specified") + + config.DB.App.Password = "testPassword" + err = config.verifyUnmanagedTabletConfig() + assert.EqualError(t, err, "fixing replication should be disabled on unmanaged tablets") + + mysqlctl.DisableActiveReparents = true + err = config.verifyUnmanagedTabletConfig() + assert.Nil(t, err) +} From 5292b06467ca3466dbba6105cd9e8971c0f7ebec Mon Sep 17 00:00:00 2001 From: Noble Mittal Date: Mon, 26 Feb 2024 00:36:31 +0530 Subject: [PATCH 6/9] Set DisableActiveReparents to false before checking Signed-off-by: Noble Mittal --- go/vt/vttablet/tabletserver/tabletenv/config_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config_test.go b/go/vt/vttablet/tabletserver/tabletenv/config_test.go index 5358353146b..58f55994c96 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config_test.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config_test.go @@ -484,6 +484,7 @@ func TestVerifyUnmanagedTabletConfig(t *testing.T) { assert.EqualError(t, err, "database app user password not specified") config.DB.App.Password = "testPassword" + mysqlctl.DisableActiveReparents = false err = config.verifyUnmanagedTabletConfig() assert.EqualError(t, err, "fixing replication should be disabled on unmanaged tablets") From 5c5840a76019addeec8982c706a8237387535061 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 6 Mar 2024 14:21:09 +0530 Subject: [PATCH 7/9] feat: add summary changes Signed-off-by: Manan Gupta --- changelog/20.0/20.0.0/summary.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog/20.0/20.0.0/summary.md b/changelog/20.0/20.0.0/summary.md index 863de8aefec..75bfb3b0a5d 100644 --- a/changelog/20.0/20.0.0/summary.md +++ b/changelog/20.0/20.0.0/summary.md @@ -5,6 +5,7 @@ - **[Major Changes](#major-changes)** - **[Breaking changes](#breaking-changes)** - [`shutdown_grace_period` Default Change](#shutdown-grace-period-default) + - [New `unmanaged` Flag](#unmanaged-flag) - **[Query Compatibility](#query-compatibility)** - [Vindex Hints](#vindex-hints) - [Update with Limit Support](#update-limit) @@ -28,6 +29,12 @@ This makes reparenting in Vitess resilient to client errors, and prevents Planne In order to preserve the old behaviour, the users can set the flag back to `0 seconds` causing open transactions to never be shutdown, but in that case, they run the risk of PlannedReparentShard calls timing out. +#### New `unmanaged` Flag + +New flag `--unmanaged` has been introduced in this release to make it easier to flag unmanaged tablets. It also runs validations to make sure the unmanaged tablets are configured properly. + +Starting this release, all unmanaged tablets should specify this flag. + ### Query Compatibility #### Vindex Hints From 0623446de4c0fd740784a87e257eed08a3a2c6c7 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Mon, 11 Mar 2024 17:19:59 +0530 Subject: [PATCH 8/9] refactor: rename variable Signed-off-by: Manan Gupta --- go/vt/vttablet/tabletserver/tabletenv/config.go | 6 +++--- go/vt/vttablet/tabletserver/tabletenv/config_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 4491c91c60a..5e7d6860c0e 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -217,7 +217,7 @@ func registerTabletEnvFlags(fs *pflag.FlagSet) { fs.BoolVar(¤tConfig.EnablePerWorkloadTableMetrics, "enable-per-workload-table-metrics", defaultConfig.EnablePerWorkloadTableMetrics, "If true, query counts and query error metrics include a label that identifies the workload") - fs.BoolVar(¤tConfig.UnmanagedTablet, "unmanaged", false, "Indicates an unmanaged tablet, i.e. using an external mysql-compatible database") + fs.BoolVar(¤tConfig.Unmanaged, "unmanaged", false, "Indicates an unmanaged tablet, i.e. using an external mysql-compatible database") } var ( @@ -303,7 +303,7 @@ func Init() { type TabletConfig struct { DB *dbconfigs.DBConfigs `json:"db,omitempty"` - UnmanagedTablet bool `json:"unmanaged,omitempty"` + Unmanaged bool `json:"unmanaged,omitempty"` OltpReadPool ConnPoolConfig `json:"oltpReadPool,omitempty"` OlapReadPool ConnPoolConfig `json:"olapReadPool,omitempty"` @@ -895,7 +895,7 @@ func (c *TabletConfig) Verify() error { // verifyUnmanagedTabletConfig checks unmanaged tablet related config for sanity func (c *TabletConfig) verifyUnmanagedTabletConfig() error { // Skip checks if tablet is not unmanaged - if !c.UnmanagedTablet { + if !c.Unmanaged { return nil } diff --git a/go/vt/vttablet/tabletserver/tabletenv/config_test.go b/go/vt/vttablet/tabletserver/tabletenv/config_test.go index 18574eb67d3..4cc7b02281e 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config_test.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config_test.go @@ -465,7 +465,7 @@ func TestVerifyUnmanagedTabletConfig(t *testing.T) { err := config.verifyUnmanagedTabletConfig() assert.Nil(t, err) - config.UnmanagedTablet = true + config.Unmanaged = true err = config.verifyUnmanagedTabletConfig() assert.EqualError(t, err, "no connection parameters specified but unmanaged mode specified") From e957a3bf7feca1009aa304975f119e0866d092e2 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 13 Mar 2024 16:59:38 +0530 Subject: [PATCH 9/9] feat: address review comments Signed-off-by: Manan Gupta --- changelog/20.0/20.0.0/summary.md | 6 +++--- go/cmd/vttablet/cli/cli.go | 2 +- go/flags/endtoend/vtcombo.txt | 1 - go/flags/endtoend/vttablet.txt | 3 +-- go/flags/endtoend/vttestserver.txt | 1 - go/vt/mysqlctl/mysqld.go | 10 +++++++++- go/vt/vttablet/tabletserver/tabletenv/config.go | 5 ++--- go/vt/vttablet/tabletserver/tabletenv/config_test.go | 5 ----- 8 files changed, 16 insertions(+), 17 deletions(-) diff --git a/changelog/20.0/20.0.0/summary.md b/changelog/20.0/20.0.0/summary.md index 53d023c7c35..15455ef502c 100644 --- a/changelog/20.0/20.0.0/summary.md +++ b/changelog/20.0/20.0.0/summary.md @@ -5,7 +5,7 @@ - **[Major Changes](#major-changes)** - **[Breaking changes](#breaking-changes)** - [`shutdown_grace_period` Default Change](#shutdown-grace-period-default) - - [New `unmanaged` Flag](#unmanaged-flag) + - [New `unmanaged` Flag and `disable_active_reparents` deprecation](#unmanaged-flag) - **[Query Compatibility](#query-compatibility)** - [Vindex Hints](#vindex-hints) - [Update with Limit Support](#update-limit) @@ -32,9 +32,9 @@ This makes reparenting in Vitess resilient to client errors, and prevents Planne In order to preserve the old behaviour, the users can set the flag back to `0 seconds` causing open transactions to never be shutdown, but in that case, they run the risk of PlannedReparentShard calls timing out. -#### New `unmanaged` Flag +#### New `unmanaged` Flag and `disable_active_reparents` deprecation -New flag `--unmanaged` has been introduced in this release to make it easier to flag unmanaged tablets. It also runs validations to make sure the unmanaged tablets are configured properly. +New flag `--unmanaged` has been introduced in this release to make it easier to flag unmanaged tablets. It also runs validations to make sure the unmanaged tablets are configured properly. `--disable_active_reparents` flag has been deprecated for `vttablet`, `vtcombo` and `vttestserver` binaries and will be removed in future releases. Specifying the `--unmanaged` flag will also block replication commands and replication repairs. Starting this release, all unmanaged tablets should specify this flag. diff --git a/go/cmd/vttablet/cli/cli.go b/go/cmd/vttablet/cli/cli.go index 4e97b7f6fa0..b64c5d92b62 100644 --- a/go/cmd/vttablet/cli/cli.go +++ b/go/cmd/vttablet/cli/cli.go @@ -82,7 +82,7 @@ See "Unmanaged Tablet" for the full guide. Even if a MySQL is external, you can still make vttablet perform some management functions. They are as follows: ` + - "* `--disable_active_reparents`: If this flag is set, then any reparent or replica commands will not be allowed. These are InitShardPrimary, PlannedReparentShard, EmergencyReparentShard, and ReparentTablet. In this mode, you should use the TabletExternallyReparented command to inform vitess of the current primary.\n" + + "* `--unmanaged`: This flag indicates that this tablet is running in unmanaged mode. In this mode, any reparent or replica commands are not allowed. These are InitShardPrimary, PlannedReparentShard, EmergencyReparentShard, and ReparentTablet. You should use the TabletExternallyReparented command to inform vitess of the current primary.\n" + "* `--replication_connect_retry`: This value is give to mysql when it connects a replica to the primary as the retry duration parameter.\n" + "* `--heartbeat_enable` and `--heartbeat_interval duration`: cause vttablet to write heartbeats to the sidecar database. This information is also used by the replication reporter to assess replica lag.\n", Example: ` diff --git a/go/flags/endtoend/vtcombo.txt b/go/flags/endtoend/vtcombo.txt index c7a28c779be..ee759218d9c 100644 --- a/go/flags/endtoend/vtcombo.txt +++ b/go/flags/endtoend/vtcombo.txt @@ -108,7 +108,6 @@ Flags: --ddl_strategy string Set default strategy for DDL statements. Override with @@ddl_strategy session variable (default "direct") --default_tablet_type topodatapb.TabletType The default tablet type to set for queries, when one is not explicitly selected. (default PRIMARY) --degraded_threshold duration replication lag after which a replica is considered degraded (default 30s) - --disable_active_reparents if set, do not allow active reparents. Use this to protect a cluster using external reparents. --emit_stats If set, emit stats to push-based monitoring and stats backends --enable-consolidator Synonym to -enable_consolidator (default true) --enable-consolidator-replicas Synonym to -enable_consolidator_replicas diff --git a/go/flags/endtoend/vttablet.txt b/go/flags/endtoend/vttablet.txt index bf1d0fefadf..9f089275aba 100644 --- a/go/flags/endtoend/vttablet.txt +++ b/go/flags/endtoend/vttablet.txt @@ -17,7 +17,7 @@ See "Unmanaged Tablet" for the full guide. Even if a MySQL is external, you can still make vttablet perform some management functions. They are as follows: -* `--disable_active_reparents`: If this flag is set, then any reparent or replica commands will not be allowed. These are InitShardPrimary, PlannedReparentShard, EmergencyReparentShard, and ReparentTablet. In this mode, you should use the TabletExternallyReparented command to inform vitess of the current primary. +* `--unmanaged`: This flag indicates that this tablet is running in unmanaged mode. In this mode, any reparent or replica commands are not allowed. These are InitShardPrimary, PlannedReparentShard, EmergencyReparentShard, and ReparentTablet. You should use the TabletExternallyReparented command to inform vitess of the current primary. * `--replication_connect_retry`: This value is give to mysql when it connects a replica to the primary as the retry duration parameter. * `--heartbeat_enable` and `--heartbeat_interval duration`: cause vttablet to write heartbeats to the sidecar database. This information is also used by the replication reporter to assess replica lag. @@ -139,7 +139,6 @@ Flags: --dba_idle_timeout duration Idle timeout for dba connections (default 1m0s) --dba_pool_size int Size of the connection pool for dba connections (default 20) --degraded_threshold duration replication lag after which a replica is considered degraded (default 30s) - --disable_active_reparents if set, do not allow active reparents. Use this to protect a cluster using external reparents. --emit_stats If set, emit stats to push-based monitoring and stats backends --enable-consolidator Synonym to -enable_consolidator (default true) --enable-consolidator-replicas Synonym to -enable_consolidator_replicas diff --git a/go/flags/endtoend/vttestserver.txt b/go/flags/endtoend/vttestserver.txt index e650ef536f7..7c0df363c15 100644 --- a/go/flags/endtoend/vttestserver.txt +++ b/go/flags/endtoend/vttestserver.txt @@ -31,7 +31,6 @@ Flags: --dba_idle_timeout duration Idle timeout for dba connections (default 1m0s) --dba_pool_size int Size of the connection pool for dba connections (default 20) --default_schema_dir string Default directory for initial schema files. If no schema is found in schema_dir, default to this location. - --disable_active_reparents if set, do not allow active reparents. Use this to protect a cluster using external reparents. --enable_direct_ddl Allow users to submit direct DDL statements (default true) --enable_online_ddl Allow users to submit, review and control Online DDL (default true) --enable_system_settings This will enable the system settings to be changed per session at the database connection level (default true) diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index 63971339f13..d866aa70f65 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -122,9 +122,12 @@ func init() { for _, cmd := range []string{"mysqlctl", "mysqlctld", "vtcombo", "vttablet", "vttestserver"} { servenv.OnParseFor(cmd, registerMySQLDFlags) } - for _, cmd := range []string{"vtcombo", "vttablet", "vttestserver", "vtctld", "vtctldclient"} { + for _, cmd := range []string{"vtctld", "vtctldclient"} { servenv.OnParseFor(cmd, registerReparentFlags) } + for _, cmd := range []string{"vtcombo", "vttablet", "vttestserver"} { + servenv.OnParseFor(cmd, registerDeprecatedReparentFlags) + } for _, cmd := range []string{"mysqlctl", "mysqlctld", "vtcombo", "vttablet", "vttestserver"} { servenv.OnParseFor(cmd, registerPoolFlags) } @@ -141,6 +144,11 @@ func registerReparentFlags(fs *pflag.FlagSet) { fs.BoolVar(&DisableActiveReparents, "disable_active_reparents", DisableActiveReparents, "if set, do not allow active reparents. Use this to protect a cluster using external reparents.") } +func registerDeprecatedReparentFlags(fs *pflag.FlagSet) { + fs.BoolVar(&DisableActiveReparents, "disable_active_reparents", DisableActiveReparents, "if set, do not allow active reparents. Use this to protect a cluster using external reparents.") + fs.MarkDeprecated("disable_active_reparents", "Use --unmanaged flag instead for unmanaged tablets.") +} + func registerPoolFlags(fs *pflag.FlagSet) { fs.IntVar(&dbaPoolSize, "dba_pool_size", dbaPoolSize, "Size of the connection pool for dba connections") fs.DurationVar(&DbaIdleTimeout, "dba_idle_timeout", DbaIdleTimeout, "Idle timeout for dba connections") diff --git a/go/vt/vttablet/tabletserver/tabletenv/config.go b/go/vt/vttablet/tabletserver/tabletenv/config.go index 5e7d6860c0e..7df97400acd 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config.go @@ -909,9 +909,8 @@ func (c *TabletConfig) verifyUnmanagedTabletConfig() error { if c.DB.App.Password == "" { return errors.New("database app user password not specified") } - if !mysqlctl.DisableActiveReparents { - return errors.New("fixing replication should be disabled on unmanaged tablets") - } + // Replication fixes should be disabled for Unmanaged tablets. + mysqlctl.DisableActiveReparents = true return c.checkConnectionForExternalMysql() } diff --git a/go/vt/vttablet/tabletserver/tabletenv/config_test.go b/go/vt/vttablet/tabletserver/tabletenv/config_test.go index 4cc7b02281e..a51a3c599e8 100644 --- a/go/vt/vttablet/tabletserver/tabletenv/config_test.go +++ b/go/vt/vttablet/tabletserver/tabletenv/config_test.go @@ -478,11 +478,6 @@ func TestVerifyUnmanagedTabletConfig(t *testing.T) { assert.EqualError(t, err, "database app user password not specified") config.DB.App.Password = "testPassword" - mysqlctl.DisableActiveReparents = false - err = config.verifyUnmanagedTabletConfig() - assert.EqualError(t, err, "fixing replication should be disabled on unmanaged tablets") - - mysqlctl.DisableActiveReparents = true err = config.verifyUnmanagedTabletConfig() assert.Nil(t, err) }