Skip to content

Commit

Permalink
clusterversion: rename pre-23.1 version gates
Browse files Browse the repository at this point in the history
This commit renames all pre-23.1 version keys (except those associated permanent
upgrades) to start with `TODO_Delete_`. These keys will be removed by
relevant teams.

Informs: cockroachdb#111760
Release note: None
  • Loading branch information
RaduBerinde committed Oct 16, 2023
1 parent b05bf3e commit 50210ba
Show file tree
Hide file tree
Showing 68 changed files with 403 additions and 395 deletions.
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/backup_planning_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FROM
LEFT JOIN system.tenant_usage ON
tenants.id = tenant_usage.tenant_id AND tenant_usage.instance_id = 0
`
if !settings.Version.IsActive(ctx, clusterversion.V23_1TenantNamesStateAndServiceMode) {
if !settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1TenantNamesStateAndServiceMode) {
q = `
SELECT
tenants.id, /* 0 */
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/backupccl/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ var localityCfgs = map[string]roachpb.Locality{
}

var clusterVersionKeys = map[string]clusterversion.Key{
"23_1_Start": clusterversion.V23_1Start,
"23_1_MVCCTombstones": clusterversion.V23_1_MVCCRangeTombstonesUnconditionallyEnabled,
"23_1_Start": clusterversion.TODO_Delete_V23_1Start,
"23_1_MVCCTombstones": clusterversion.TODO_Delete_V23_1_MVCCRangeTombstonesUnconditionallyEnabled,
"23_2_Start": clusterversion.V23_2Start,
"23_2": clusterversion.V23_2,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ func (r *restoreResumer) restoreSystemUsers(
return err
}

roleMembersHasIDColumns := r.execCfg.Settings.Version.IsActive(ctx, clusterversion.V23_1RoleMembersTableHasIDColumns)
roleMembersHasIDColumns := r.execCfg.Settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1RoleMembersTableHasIDColumns)
insertRoleMember := `
INSERT INTO system.role_members ("role", "member", "isAdmin", role_id, member_id)
VALUES ($1, $2, $3, (SELECT user_id FROM system.users WHERE username = $1), (SELECT user_id FROM system.users WHERE username = $2))`
Expand Down
8 changes: 4 additions & 4 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func roleMembersRestoreFunc(
txn isql.Txn,
systemTableName, tempTableName string,
) error {
if !deps.settings.Version.IsActive(ctx, clusterversion.V23_1RoleMembersTableHasIDColumns) {
if !deps.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1RoleMembersTableHasIDColumns) {
return defaultSystemTableRestoreFunc(ctx, deps, txn, systemTableName, tempTableName)
}

Expand Down Expand Up @@ -370,7 +370,7 @@ func systemPrivilegesRestoreFunc(
txn isql.Txn,
systemTableName, tempTableName string,
) error {
if !deps.settings.Version.IsActive(ctx, clusterversion.V23_1SystemPrivilegesTableHasUserIDColumn) {
if !deps.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1SystemPrivilegesTableHasUserIDColumn) {
return defaultSystemTableRestoreFunc(ctx, deps, txn, systemTableName, tempTableName)
}

Expand Down Expand Up @@ -425,7 +425,7 @@ func systemDatabaseRoleSettingsRestoreFunc(
txn isql.Txn,
systemTableName, tempTableName string,
) error {
if !deps.settings.Version.IsActive(ctx, clusterversion.V23_1DatabaseRoleSettingsHasRoleIDColumn) {
if !deps.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1DatabaseRoleSettingsHasRoleIDColumn) {
return defaultSystemTableRestoreFunc(ctx, deps, txn, systemTableName, tempTableName)
}

Expand Down Expand Up @@ -480,7 +480,7 @@ func systemExternalConnectionsRestoreFunc(
txn isql.Txn,
systemTableName, tempTableName string,
) error {
if !deps.settings.Version.IsActive(ctx, clusterversion.V23_1ExternalConnectionsTableHasOwnerIDColumn) {
if !deps.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1ExternalConnectionsTableHasOwnerIDColumn) {
return defaultSystemTableRestoreFunc(ctx, deps, txn, systemTableName, tempTableName)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/ccl/changefeedccl/changefeed_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,14 @@ func createChangefeedJobRecord(
return nil, err
}
if withDiff {
if !p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.V23_1_ChangefeedExpressionProductionReady) {
if !p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady) {
return nil,
pgerror.Newf(
pgcode.FeatureNotSupported,
"cannot create new changefeed with CDC expression <%s>, "+
"which requires access to cdc_prev until cluster upgrade to %s finalized.",
tree.AsString(normalized),
clusterversion.V23_1_ChangefeedExpressionProductionReady.String,
clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady.String,
)
}
opts.ForceDiff()
Expand Down Expand Up @@ -1620,7 +1620,7 @@ func failureTypeForStartupError(err error) changefeedbase.FailureType {

// maybeUpgradePreProductionReadyExpression updates job record for the
// changefeed using CDC transformation, created prior to
// clusterversion.V23_1_ChangefeedExpressionProductionReady. The update happens
// clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady. The update happens
// once cluster version finalized.
// Returns nil when nothing needs to be done.
// Returns fatal error message, causing changefeed to fail, if automatic upgrade
Expand All @@ -1643,14 +1643,14 @@ func maybeUpgradePreProductionReadyExpression(
}

if !jobExec.ExecCfg().Settings.Version.IsActive(
ctx, clusterversion.V23_1_ChangefeedExpressionProductionReady,
ctx, clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady,
) {
// Can't upgrade job record yet -- wait until upgrade finalized.
return nil
}

// Expressions prior to
// clusterversion.V23_1_ChangefeedExpressionProductionReady were rewritten to
// clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady were rewritten to
// fully qualify all columns/types. Furthermore, those expressions couldn't
// use any functions that depend on session data. Thus, it is safe to use
// minimal session data.
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/changefeedccl/event_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func newEvaluator(
sd := sql.NewInternalSessionData(ctx, cfg.Settings, "changefeed-evaluator")
if spec.Feed.SessionData == nil {
// This changefeed was created prior to
// clusterversion.V23_1_ChangefeedExpressionProductionReady; thus we must
// clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady; thus we must
// rewrite expression to comply with current cluster version.
newExpr, err := cdceval.RewritePreviewExpression(sc)
if err != nil {
Expand All @@ -288,7 +288,7 @@ func newEvaluator(
log.Warningf(ctx,
"changefeed expression %s (job %d) created prior to %s rewritten as %s",
tree.AsString(sc), spec.JobID,
clusterversion.V23_1_ChangefeedExpressionProductionReady.String(),
clusterversion.TODO_Delete_V23_1_ChangefeedExpressionProductionReady.String(),
tree.AsString(newExpr))
sc = newExpr
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ccl/changefeedccl/scheduled_changefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,12 @@ func createChangefeedScheduleTypeCheck(
return false, nil, nil
}

if !p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.V23_1ScheduledChangefeeds) {
if !p.ExecCfg().Settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1ScheduledChangefeeds) {
return false, nil,
pgerror.Newf(
pgcode.FeatureNotSupported,
"cannot use scheduled changefeeds until cluster is upgraded to %s",
clusterversion.V23_1ScheduledChangefeeds.String,
clusterversion.TODO_Delete_V23_1ScheduledChangefeeds.String,
)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func createAuthSessionToken(
err = sqlConn.ExecTxn(ctx, func(ctx context.Context, conn clisqlclient.TxBoundConn) error {
rows, err := conn.Query(ctx,
"SELECT crdb_internal.is_at_least_version($1)",
clusterversion.ByKey(clusterversion.V23_1WebSessionsTableHasUserIDColumn))
clusterversion.ByKey(clusterversion.TODO_Delete_V23_1WebSessionsTableHasUserIDColumn))
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 50210ba

Please sign in to comment.