Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-24.3: sql: Check for concurrent DSC job in legacy schema changer #137889

Open
wants to merge 1 commit into
base: release-24.3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pkg/sql/schema_changer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/regionliveness"
"github.com/cockroachdb/cockroach/pkg/sql/regions"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scerrors"
"github.com/cockroachdb/cockroach/pkg/sql/sem/catid"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -793,6 +794,13 @@ func (sc *SchemaChanger) exec(ctx context.Context) (retErr error) {
if err := sc.checkForMVCCCompliantAddIndexMutations(ctx, desc); err != nil {
return err
}
// Check that the DSC is not active for this descriptor.
if catalog.HasConcurrentDeclarativeSchemaChange(desc) {
log.Infof(ctx,
"aborting legacy schema change job execution because DSC was already active for %q (%d)",
desc.GetName(), desc.GetID())
return scerrors.ConcurrentSchemaChangeError(desc)
}

log.Infof(ctx,
"schema change on %q (v%d) starting execution...",
Expand Down Expand Up @@ -3157,7 +3165,8 @@ func (sc *SchemaChanger) applyZoneConfigChangeForMutation(
func DeleteTableDescAndZoneConfig(
ctx context.Context, execCfg *ExecutorConfig, tableDesc catalog.TableDescriptor,
) error {
log.Infof(ctx, "removing table descriptor and zone config for table %d", tableDesc.GetID())
log.Infof(ctx, "removing table descriptor and zone config for table %d (has active dsc=%t)",
tableDesc.GetID(), catalog.HasConcurrentDeclarativeSchemaChange(tableDesc))
const kvTrace = false
return DescsTxn(ctx, execCfg, func(ctx context.Context, txn isql.Txn, col *descs.Collection) error {
b := txn.KV().NewBatch()
Expand Down