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

backupccl: incremental schedules always wait on_previous_running #98249

Merged
merged 1 commit into from
Mar 9, 2023

Conversation

adityamaru
Copy link
Contributor

@adityamaru adityamaru commented Mar 8, 2023

An incremental backup schedule must always wait if there is a running job
that was previously scheduled by this incremental schedule. This is
because until the previous incremental backup job completes, all future
incremental jobs will attempt to backup data from the same StartTime
corresponding to the EndTime of the last incremental layer. In this
case only the first incremental job to complete will succeed, while the
remaining jobs will either be rejected or worse corrupt the chain of
backups.

This change overrides the Wait behaviour for an incremental schedule to
always default to wait during schedule creation or in an alter statement.
Note the user specified value will still be applied to the full backup schedule.

Ideally we'd have a way to configure options for both the full and
incremental schedule separately, in which case we could reject the
on_previous_running configuration for incremental schedules.
Until then this workaround will have to do and we should call out this
known limitation.

Fixes: #96110

Release note (enterprise change): backup schedules created or altered to
have the option on_previous_running will have the full backup
schedule created with the user specified option, but will override the
incremental backup schedule to always default to on_previous_running = wait.
This ensures correctness of the backup chains created by the incremental
schedule by preventing duplicate incremental jobs from racing against each
other.

@adityamaru adityamaru requested review from dt and benbardin March 8, 2023 21:38
@adityamaru adityamaru requested a review from a team as a code owner March 8, 2023 21:38
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@adityamaru
Copy link
Contributor Author

An alternative suggested by @shermanCRL is that we stop accepting wait and skip for incremental schedules and just default to one of those two. That will allow us to document on_previous_running as a full backup schedule only option instead of this weird "if you specify x you'll get x, but if you specify y you'll get x here and y there" 😅

@@ -384,6 +387,30 @@ func doCreateBackupSchedules(
kmsURIs, nil, resultsCh)
}

func maybeOverrideIncrementalScheduleDetails(ctx context.Context, details *jobspb.ScheduleDetails) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to error and fail rather than overriding with a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can do that because that would mean CREATE SCHEDULE with an on_previous_running = start would fail as a whole. Since we do not have a way to express full backup and inc backup schedules separately we still want start to apply to the full schedule but want to override what applies to the incremental schedule. As mentioned in my comment above and in the slack thread I think we'll change this to unconditionally set inc schedule to have the WAIT option.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right 🤦 In that case, maybe the warning could include that? on_previous_running=start only applies to full backups. incremental backups will use on_previous_running=wait or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After an internal chat we decided that we should simplify the user story by making on_previous_running a configurable option for only full backup schedules. Incrementals will always wait for previous running jobs to complete before spawning a new incremental job. I've updated the commit message and the code with this new implementation. I don't think we even need to log a warning anymore.

@adityamaru adityamaru changed the title backupccl: incremental schedules override on_previous_running = start backupccl: incremental schedules always wait on_previous_running Mar 9, 2023
@adityamaru adityamaru requested a review from benbardin March 9, 2023 15:58
@adityamaru
Copy link
Contributor Author

cc: @kathancox for the required docs changes to make on_previous_running a full backup schedule only option!

An incremental backup schedule must always wait if there is a running job
that was previously scheduled by this incremental schedule. This is
because until the previous incremental backup job completes, all future
incremental jobs will attempt to backup data from the same `StartTime`
corresponding to the `EndTime` of the last incremental layer. In this
case only the first incremental job to complete will succeed, while the
remaining jobs will either be rejected or worse corrupt the chain of
backups.

This change overrides the Wait behaviour for an incremental schedule to
always default to `wait` during schedule creation or in an alter statement.
Note the user specified value will still be applied to the full backup schedule.

Ideally we'd have a way to configure options for both the full and
incremental schedule separately, in which case we could reject the
`on_previous_running` configuration for incremental schedules.
Until then this workaround will have to do and we should call out this
known limitation.

Release note (enterprise change): backup schedules created or altered to
have the option `on_previous_running` will have the full backup
schedule created with the user specified option, but will override the
incremental backup schedule to always default to `on_previous_running = wait`.
This ensures correctness of the backup chains created by the incremental
schedule by preventing duplicate incremental jobs from racing against each
other.
@adityamaru
Copy link
Contributor Author

TFTR!

bors r=benbardin

@craig
Copy link
Contributor

craig bot commented Mar 9, 2023

Build succeeded:

@craig craig bot merged commit 6f444d4 into cockroachdb:master Mar 9, 2023
@blathers-crl
Copy link

blathers-crl bot commented Mar 9, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from e22626f to blathers/backport-release-22.1-98249: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


error creating merge commit from e22626f to blathers/backport-release-22.2-98249: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backupccl: scheduled backups should stop adding to an incremental chain after a certain number of running jobs
3 participants