Skip to content

Commit

Permalink
backupccl: fix scheduled backup pts pushing race
Browse files Browse the repository at this point in the history
Informs #128013

Epic: none
  • Loading branch information
msbutler committed Sep 25, 2024
1 parent 090609b commit 070a6f8
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions pkg/ccl/backupccl/backup_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,21 @@ func (b *backupResumer) Resume(ctx context.Context, execCtx interface{}) error {
defaultURI := details.URI
var backupDest backupdest.ResolvedDestination
if details.URI == "" {
// Choose which scheduled backup pts we will update at the the end of the
// backup _before_ we resolve the destination of the backup. This avoids a
// race with inc backups where backup destination resolution leads this backup
// to extend a chain that is about to be superseded by a new full backup
// chain, which could cause this inc to accidentally push the pts for the
// _new_ chain instead of the old chain it is apart of. By choosing the pts to
// move before we resolve the destination, we guarantee that we push the old
// chain.
insqlDB := p.ExecCfg().InternalDB
if err := insqlDB.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
return planSchedulePTSChaining(ctx, p.ExecCfg().JobsKnobs(), txn, &details, b.job.CreatedBy())
}); err != nil {
return err
}

var err error
backupDest, err = backupdest.ResolveDest(ctx, p.User(), details.Destination, details.EndTime,
details.IncrementalFrom, p.ExecCfg())
Expand Down Expand Up @@ -727,12 +742,6 @@ func (b *backupResumer) Resume(ctx context.Context, execCtx interface{}) error {
return err
}

if err := insqlDB.Txn(ctx, func(ctx context.Context, txn isql.Txn) error {
return planSchedulePTSChaining(ctx, p.ExecCfg().JobsKnobs(), txn, &details, b.job.CreatedBy())
}); err != nil {
return err
}

// The description picked during original planning might still say "LATEST",
// if resolving that to the actual directory only just happened above here.
// Ideally we'd re-render the description now that we know the subdir, but
Expand Down

0 comments on commit 070a6f8

Please sign in to comment.