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

Atomic Transactions handling with Online DDL #16585

Merged
merged 14 commits into from
Aug 28, 2024
Merged
Changes from 1 commit
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
16 changes: 14 additions & 2 deletions go/vt/vttablet/onlineddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,8 @@ func (e *Executor) cutOverVReplMigration(ctx context.Context, s *VReplStream, sh
if shouldForceCutOver {
// We should only proceed with forceful cut over if there is no pending atomic transaction for the table.
// This will help in keeping the atomicity guarantee of a prepared transaction.
if !e.IsPreparedPoolEmpty(onlineDDL.Table) {
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot force cut-over on non-empty prepared pool for table: %s", onlineDDL.Table)
if err := e.checkOnPreparedPool(onlineDDL.Table, 100*time.Millisecond, 1); err != nil {
return err
}
if err := e.killTableLockHoldersAndAccessors(ctx, onlineDDL.Table); err != nil {
return err
Expand Down Expand Up @@ -5355,3 +5355,15 @@ func (e *Executor) OnSchemaMigrationStatus(ctx context.Context,

return e.onSchemaMigrationStatus(ctx, uuidParam, status, dryRun, progressPct, etaSeconds, rowsCopied, hint)
}

func (e *Executor) checkOnPreparedPool(table string, waitTime time.Duration, retries int) error {
harshit-gangal marked this conversation as resolved.
Show resolved Hide resolved
for i := 0; i <= retries; i++ {
if e.IsPreparedPoolEmpty(table) {
return nil
}
if i < retries {
time.Sleep(waitTime)
}
}
return vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cannot force cut-over on non-empty prepared pool for table: %s", table)
}
Loading