From ef4710c0a0c62d68ec1eb85aef9ce81ae1815e1f Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Wed, 1 Sep 2021 23:59:35 -0400 Subject: [PATCH] clusterversion,kv: remove NonVotingReplicas Partially addresses #66544 by removing a cluster version and its associated dependencies which, for any cluster whose version is at least 21.1, is certain to be active. Release justification: cluster version cleanup --- pkg/clusterversion/cockroach_versions.go | 6 --- pkg/clusterversion/key_string.go | 69 ++++++++++++------------ pkg/kv/kvserver/replicate_queue.go | 6 --- pkg/sql/set_zone_config.go | 20 ------- 4 files changed, 34 insertions(+), 67 deletions(-) diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index a038ec5a1ff3..04fcb942998d 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -210,8 +210,6 @@ const ( // are propagated across RPC boundaries independently of their verbosity setting. // This requires a version gate this violates implicit assumptions in v20.2. TracingVerbosityIndependentSemantics - // NonVotingReplicas enables the creation of non-voting replicas. - NonVotingReplicas // V21_1 is CockroachDB v21.1. It's used for all v21.1.x patch releases. V21_1 @@ -371,10 +369,6 @@ var versionsSingleton = keyedVersions{ Key: TracingVerbosityIndependentSemantics, Version: roachpb.Version{Major: 20, Minor: 2, Internal: 28}, }, - { - Key: NonVotingReplicas, - Version: roachpb.Version{Major: 20, Minor: 2, Internal: 46}, - }, { // V21_1 is CockroachDB v21.1. It's used for all v21.1.x patch releases. Key: V21_1, diff --git a/pkg/clusterversion/key_string.go b/pkg/clusterversion/key_string.go index 0a275a37f795..866500386868 100644 --- a/pkg/clusterversion/key_string.go +++ b/pkg/clusterversion/key_string.go @@ -19,44 +19,43 @@ func _() { _ = x[TruncatedAndRangeAppliedStateMigration-8] _ = x[PostTruncatedAndRangeAppliedStateMigration-9] _ = x[TracingVerbosityIndependentSemantics-10] - _ = x[NonVotingReplicas-11] - _ = x[V21_1-12] - _ = x[Start21_1PLUS-13] - _ = x[Start21_2-14] - _ = x[JoinTokensTable-15] - _ = x[AcquisitionTypeInLeaseHistory-16] - _ = x[SerializeViewUDTs-17] - _ = x[ExpressionIndexes-18] - _ = x[DeleteDeprecatedNamespaceTableDescriptorMigration-19] - _ = x[FixDescriptors-20] - _ = x[SQLStatsTable-21] - _ = x[DatabaseRoleSettings-22] - _ = x[TenantUsageTable-23] - _ = x[SQLInstancesTable-24] - _ = x[NewRetryableRangefeedErrors-25] - _ = x[AlterSystemWebSessionsCreateIndexes-26] - _ = x[SeparatedIntentsMigration-27] - _ = x[PostSeparatedIntentsMigration-28] - _ = x[RetryJobsWithExponentialBackoff-29] - _ = x[RecordsBasedRegistry-30] - _ = x[AutoSpanConfigReconciliationJob-31] - _ = x[PreventNewInterleavedTables-32] - _ = x[EnsureNoInterleavedTables-33] - _ = x[DefaultPrivileges-34] - _ = x[ZonesTableForSecondaryTenants-35] - _ = x[UseKeyEncodeForHashShardedIndexes-36] - _ = x[DatabasePlacementPolicy-37] - _ = x[GeneratedAsIdentity-38] - _ = x[OnUpdateExpressions-39] - _ = x[SpanConfigurationsTable-40] - _ = x[BoundedStaleness-41] - _ = x[SQLStatsCompactionScheduledJob-42] - _ = x[DateAndIntervalStyle-43] + _ = x[V21_1-11] + _ = x[Start21_1PLUS-12] + _ = x[Start21_2-13] + _ = x[JoinTokensTable-14] + _ = x[AcquisitionTypeInLeaseHistory-15] + _ = x[SerializeViewUDTs-16] + _ = x[ExpressionIndexes-17] + _ = x[DeleteDeprecatedNamespaceTableDescriptorMigration-18] + _ = x[FixDescriptors-19] + _ = x[SQLStatsTable-20] + _ = x[DatabaseRoleSettings-21] + _ = x[TenantUsageTable-22] + _ = x[SQLInstancesTable-23] + _ = x[NewRetryableRangefeedErrors-24] + _ = x[AlterSystemWebSessionsCreateIndexes-25] + _ = x[SeparatedIntentsMigration-26] + _ = x[PostSeparatedIntentsMigration-27] + _ = x[RetryJobsWithExponentialBackoff-28] + _ = x[RecordsBasedRegistry-29] + _ = x[AutoSpanConfigReconciliationJob-30] + _ = x[PreventNewInterleavedTables-31] + _ = x[EnsureNoInterleavedTables-32] + _ = x[DefaultPrivileges-33] + _ = x[ZonesTableForSecondaryTenants-34] + _ = x[UseKeyEncodeForHashShardedIndexes-35] + _ = x[DatabasePlacementPolicy-36] + _ = x[GeneratedAsIdentity-37] + _ = x[OnUpdateExpressions-38] + _ = x[SpanConfigurationsTable-39] + _ = x[BoundedStaleness-40] + _ = x[SQLStatsCompactionScheduledJob-41] + _ = x[DateAndIntervalStyle-42] } -const _Key_name = "Start20_2MinPasswordLengthCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1replacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationTracingVerbosityIndependentSemanticsNonVotingReplicasV21_1Start21_1PLUSStart21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTsExpressionIndexesDeleteDeprecatedNamespaceTableDescriptorMigrationFixDescriptorsSQLStatsTableDatabaseRoleSettingsTenantUsageTableSQLInstancesTableNewRetryableRangefeedErrorsAlterSystemWebSessionsCreateIndexesSeparatedIntentsMigrationPostSeparatedIntentsMigrationRetryJobsWithExponentialBackoffRecordsBasedRegistryAutoSpanConfigReconciliationJobPreventNewInterleavedTablesEnsureNoInterleavedTablesDefaultPrivilegesZonesTableForSecondaryTenantsUseKeyEncodeForHashShardedIndexesDatabasePlacementPolicyGeneratedAsIdentityOnUpdateExpressionsSpanConfigurationsTableBoundedStalenessSQLStatsCompactionScheduledJobDateAndIntervalStyle" +const _Key_name = "Start20_2MinPasswordLengthCreateLoginPrivilegeHBAForNonTLSV20_2Start21_1replacedTruncatedAndRangeAppliedStateMigrationreplacedPostTruncatedAndRangeAppliedStateMigrationTruncatedAndRangeAppliedStateMigrationPostTruncatedAndRangeAppliedStateMigrationTracingVerbosityIndependentSemanticsV21_1Start21_1PLUSStart21_2JoinTokensTableAcquisitionTypeInLeaseHistorySerializeViewUDTsExpressionIndexesDeleteDeprecatedNamespaceTableDescriptorMigrationFixDescriptorsSQLStatsTableDatabaseRoleSettingsTenantUsageTableSQLInstancesTableNewRetryableRangefeedErrorsAlterSystemWebSessionsCreateIndexesSeparatedIntentsMigrationPostSeparatedIntentsMigrationRetryJobsWithExponentialBackoffRecordsBasedRegistryAutoSpanConfigReconciliationJobPreventNewInterleavedTablesEnsureNoInterleavedTablesDefaultPrivilegesZonesTableForSecondaryTenantsUseKeyEncodeForHashShardedIndexesDatabasePlacementPolicyGeneratedAsIdentityOnUpdateExpressionsSpanConfigurationsTableBoundedStalenessSQLStatsCompactionScheduledJobDateAndIntervalStyle" -var _Key_index = [...]uint16{0, 9, 26, 46, 58, 63, 72, 118, 168, 206, 248, 284, 301, 306, 319, 328, 343, 372, 389, 406, 455, 469, 482, 502, 518, 535, 562, 597, 622, 651, 682, 702, 733, 760, 785, 802, 831, 864, 887, 906, 925, 948, 964, 994, 1014} +var _Key_index = [...]uint16{0, 9, 26, 46, 58, 63, 72, 118, 168, 206, 248, 284, 289, 302, 311, 326, 355, 372, 389, 438, 452, 465, 485, 501, 518, 545, 580, 605, 634, 665, 685, 716, 743, 768, 785, 814, 847, 870, 889, 908, 931, 947, 977, 997} func (i Key) String() string { if i < 0 || i >= Key(len(_Key_index)-1) { diff --git a/pkg/kv/kvserver/replicate_queue.go b/pkg/kv/kvserver/replicate_queue.go index 976bc0603e8c..2ff157a6e9ac 100644 --- a/pkg/kv/kvserver/replicate_queue.go +++ b/pkg/kv/kvserver/replicate_queue.go @@ -18,7 +18,6 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/base" - "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/gossip" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb" "github.com/cockroachdb/cockroach/pkg/kv/kvserver/liveness/livenesspb" @@ -661,11 +660,6 @@ func (rq *replicateQueue) addOrReplaceNonVoters( removeIdx int, dryRun bool, ) (requeue bool, _ error) { - // Non-voter creation is disabled before 21.1. - if v, st := clusterversion.NonVotingReplicas, repl.ClusterSettings(); !st.Version.IsActive(ctx, v) { - return false, errors.AssertionFailedf("non-voting replicas cannot be created pre-21.1") - } - desc, conf := repl.DescAndSpanConfig() existingNonVoters := desc.Replicas().NonVoterDescriptors() diff --git a/pkg/sql/set_zone_config.go b/pkg/sql/set_zone_config.go index ec08d851055d..c975a84b2941 100644 --- a/pkg/sql/set_zone_config.go +++ b/pkg/sql/set_zone_config.go @@ -17,7 +17,6 @@ import ( "strings" "github.com/cockroachdb/cockroach/pkg/base" - "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/config" "github.com/cockroachdb/cockroach/pkg/config/zonepb" "github.com/cockroachdb/cockroach/pkg/keys" @@ -78,9 +77,6 @@ var supportedZoneConfigOptions = map[tree.Name]struct { requiredType: types.Bool, setter: func(c *zonepb.ZoneConfig, d tree.Datum) { c.GlobalReads = proto.Bool(bool(tree.MustBeDBool(d))) }, checkAllowed: func(ctx context.Context, execCfg *ExecutorConfig, d tree.Datum) error { - if err := checkVersionActive(ctx, execCfg, clusterversion.NonVotingReplicas, "global_reads"); err != nil { - return err - } if !tree.MustBeDBool(d) { // Always allow the value to be unset. return nil @@ -100,9 +96,6 @@ var supportedZoneConfigOptions = map[tree.Name]struct { "num_voters": { requiredType: types.Int, setter: func(c *zonepb.ZoneConfig, d tree.Datum) { c.NumVoters = proto.Int32(int32(tree.MustBeDInt(d))) }, - checkAllowed: func(ctx context.Context, execCfg *ExecutorConfig, _ tree.Datum) error { - return checkVersionActive(ctx, execCfg, clusterversion.NonVotingReplicas, "num_voters") - }, }, "gc.ttlseconds": { requiredType: types.Int, @@ -133,9 +126,6 @@ var supportedZoneConfigOptions = map[tree.Name]struct { c.VoterConstraints = voterConstraintsList.Constraints c.NullVoterConstraintsIsEmpty = true }, - checkAllowed: func(ctx context.Context, execCfg *ExecutorConfig, _ tree.Datum) error { - return checkVersionActive(ctx, execCfg, clusterversion.NonVotingReplicas, "voter_constraints") - }, }, "lease_preferences": { requiredType: types.String, @@ -164,16 +154,6 @@ func loadYAML(dst interface{}, yamlString string) { } } -func checkVersionActive( - ctx context.Context, execCfg *ExecutorConfig, minVersion clusterversion.Key, option string, -) error { - if !execCfg.Settings.Version.IsActive(ctx, minVersion) { - return pgerror.Newf(pgcode.FeatureNotSupported, - "%s cannot be used until cluster version is finalized", option) - } - return nil -} - func (p *planner) SetZoneConfig(ctx context.Context, n *tree.SetZoneConfig) (planNode, error) { if err := checkSchemaChangeEnabled( ctx,