Skip to content

Commit

Permalink
*: remove last remaining pre-23.1 gates
Browse files Browse the repository at this point in the history
Epic: none
Release note: None
  • Loading branch information
RaduBerinde committed Nov 15, 2023
1 parent 2280082 commit cb332a8
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 89 deletions.
2 changes: 1 addition & 1 deletion pkg/cli/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,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.TODO_Delete_V23_1WebSessionsTableHasUserIDColumn))
clusterversion.MinSupported.Version())
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ go_library(
importpath = "github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities/tenantcapabilitiesauthorizer",
visibility = ["//visibility:public"],
deps = [
"//pkg/clusterversion",
"//pkg/kv/kvpb",
"//pkg/multitenant/tenantcapabilities",
"//pkg/multitenant/tenantcapabilities/tenantcapabilitiespb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ package tenantcapabilitiesauthorizer
import (
"context"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities"
"github.com/cockroachdb/cockroach/pkg/multitenant/tenantcapabilities/tenantcapabilitiespb"
Expand Down Expand Up @@ -355,14 +354,6 @@ func (a *Authorizer) getMode(
) (cp *tenantcapabilitiespb.TenantCapabilities, selectedMode authorizerModeType) {
// We prioritize what the cluster setting tells us.
selectedMode = authorizerModeType(authorizerMode.Get(&a.settings.SV))
if selectedMode == authorizerModeOn {
if !a.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1TenantCapabilities) {
// If the cluster hasn't been upgraded to v23.1 with
// capabilities yet, the capabilities won't be ready for use. In
// that case, fall back to the previous behavior.
selectedMode = authorizerModeV222
}
}

// If the mode is "on", we need to check the capabilities. Are they
// available?
Expand Down
20 changes: 1 addition & 19 deletions pkg/upgrade/upgrademanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,19 +785,6 @@ func (m *Manager) getOrCreateMigrationJob(
}

const (
preJobInfoTableQuery = `
SELECT id, status
FROM (
SELECT id, status,
crdb_internal.pb_to_json(
'cockroach.sql.jobs.jobspb.Payload',
payload,
false -- emit_defaults
) AS pl
FROM system.jobs
WHERE status IN ` + jobs.NonTerminalStatusTupleString + `
)
WHERE ((pl->'migration')->'clusterVersion') = $1::JSONB`
// PostJobInfoQuery avoids the crdb_internal.system_jobs table
// to avoid expensive full scans.
// Exported for testing.
Expand Down Expand Up @@ -829,12 +816,7 @@ func (m *Manager) getRunningMigrationJob(
// Wrap the version into a ClusterVersion so that the JSON looks like what the
// Payload proto has inside.
cv := clusterversion.ClusterVersion{Version: version}
var query string
if m.settings.Version.IsActive(ctx, clusterversion.TODO_Delete_V23_1JobInfoTableIsBackfilled) {
query = PostJobInfoTableQuery
} else {
query = preJobInfoTableQuery
}
query := PostJobInfoTableQuery
jsonMsg, err := protoreflect.MessageToJSON(&cv, protoreflect.FmtFlags{EmitDefaults: false})
if err != nil {
return false, 0, errors.Wrap(err, "failed to marshal version to JSON")
Expand Down
59 changes: 0 additions & 59 deletions pkg/workload/schemachange/operation_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,15 +1024,6 @@ func (og *operationGenerator) createSequence(ctx context.Context, tx pgx.Tx) (*o
{code: pgcode.UndefinedSchema, condition: !schemaExists},
{code: pgcode.DuplicateRelation, condition: sequenceExists && !ifNotExists},
})
// Descriptor ID generator may be temporarily unavailable, so
// allow this to be detected.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
stmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})

var seqOptions tree.SequenceOptions
// Decide if the sequence should be owned by a column. If so, it can
Expand Down Expand Up @@ -1263,15 +1254,6 @@ func (og *operationGenerator) createTable(ctx context.Context, tx pgx.Tx) (*opSt
{code: pgcode.FeatureNotSupported, condition: hasUnsupportedIdxQueries},
{code: pgcode.InvalidTableDefinition, condition: hasUnsupportedIdxQueries},
})
// Descriptor ID generator may be temporarily unavailable, so
// allow uncategorized errors temporarily.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})
opStmt.sql = tree.Serialize(stmt)
return opStmt, nil
}
Expand All @@ -1290,15 +1272,6 @@ func (og *operationGenerator) createEnum(ctx context.Context, tx pgx.Tx) (*opStm
{code: pgcode.DuplicateObject, condition: typeExists},
{code: pgcode.InvalidSchemaName, condition: !schemaExists},
})
// Descriptor ID generator may be temporarily unavailable, so
// allow uncategorized errors temporarily.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})
stmt := randgen.RandCreateType(og.params.rng, typName.Object(), "asdf")
stmt.(*tree.CreateType).TypeName = typName.ToUnresolvedObjectName()
opStmt.sql = tree.Serialize(stmt)
Expand Down Expand Up @@ -1421,15 +1394,6 @@ func (og *operationGenerator) createTableAs(ctx context.Context, tx pgx.Tx) (*op
{code: pgcode.DuplicateAlias, condition: duplicateSourceTables},
{code: pgcode.DuplicateColumn, condition: duplicateColumns},
})
// Descriptor ID generator may be temporarily unavailable, so
// allow uncategorized errors temporarily.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})
// Confirm the select itself doesn't run into any column generation errors,
// by executing it independently first until we add validation when adding
// generated columns. See issue: #81698?, which will allow us to remove this
Expand Down Expand Up @@ -1561,13 +1525,6 @@ func (og *operationGenerator) createView(ctx context.Context, tx pgx.Tx) (*opStm
})
// Descriptor ID generator may be temporarily unavailable, so
// allow uncategorized errors temporarily.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})
opStmt.sql = fmt.Sprintf(`CREATE VIEW %s AS %s`,
destViewName, selectStatement.String())
return opStmt, nil
Expand Down Expand Up @@ -3512,15 +3469,6 @@ func (og *operationGenerator) createSchema(ctx context.Context, tx pgx.Tx) (*opS
// TODO(jayshrivastava): Support authorization
stmt := randgen.MakeSchemaName(ifNotExists, schemaName, tree.MakeRoleSpecWithRoleName(username.RootUserName().Normalized()))
opStmt.sql = tree.Serialize(stmt)
// Descriptor ID generator may be temporarily unavailable, so
// allow uncategorized errors temporarily.
potentialDescIDGeneratorError, err := maybeExpectPotentialDescIDGenerationError(ctx, tx)
if err != nil {
return nil, err
}
opStmt.potentialExecErrors.addAll(codesWithConditions{
{code: pgcode.Uncategorized, condition: potentialDescIDGeneratorError},
})
return opStmt, nil
}

Expand Down Expand Up @@ -3784,10 +3732,3 @@ func isClusterVersionLessThan(
}
return clusterVersion.LessEq(targetVersion), nil
}

func maybeExpectPotentialDescIDGenerationError(ctx context.Context, tx pgx.Tx) (bool, error) {
descIDGenerationVersion := clusterversion.ByKey(clusterversion.TODO_Delete_V23_1DescIDSequenceForSystemTenant)
descIDGenerationErrorPossible, err := isClusterVersionLessThan(ctx,
tx, descIDGenerationVersion)
return descIDGenerationErrorPossible, err
}

0 comments on commit cb332a8

Please sign in to comment.