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: skip backing up excluded spans #108627

Merged
merged 1 commit into from Aug 14, 2023

Conversation

dt
Copy link
Member

@dt dt commented Aug 11, 2023

Previously we sent export requests to all spans being backed up. The ranges for spans of tables that had set the flag to exclude data from backup would reply with an empty response, excluding their data, but the backup process still sent these ranges these requests.

This changes the backup process to not send requests for spans from excluded tables, when performing database, table, or cluster backups. Backups of tenants will still send export requests to every range for the tenant span, and those ranges that host tables that are excluded will continue to reply with no data.

This is done both as an optimization, and so that backups can succeed even when a table is unavailable, if, and only if, that table is excluded.

Release note (ops change): BACKUP now skips contacting the ranges for tables on which exclude_data_from_backup is set, and can thus succeed even if an excluded table is unavailable.
Epic: none.

@dt dt requested review from adityamaru and msbutler August 11, 2023 19:34
@dt dt requested review from a team as code owners August 11, 2023 19:34
@blathers-crl
Copy link

blathers-crl bot commented Aug 11, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

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

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@dt
Copy link
Member Author

dt commented Aug 11, 2023

thinking about how to test this (inspect traces vs installing a kvrequest filter) but putting the diff up in the meantime

@dt
Copy link
Member Author

dt commented Aug 11, 2023

test added

@@ -9494,6 +9508,11 @@ func TestExcludeDataFromBackupAndRestore(t *testing.T) {
restoreDB.Exec(t, `RESTORE DATABASE data FROM LATEST IN $1`, localFoo)
require.Len(t, restoreDB.QueryStr(t, `SELECT * FROM data.foo`), 0)
require.Len(t, restoreDB.QueryStr(t, `SELECT * FROM data.bar`), 10)

before := atomic.LoadInt64(&exportReqsAtomic)
Copy link
Contributor

Choose a reason for hiding this comment

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

so at this point data.foo is going to be empty as asserted above. Can we add a few rows to it before attempt a backup.

Also s/BACKUP TO/BACKUP INTO/g

@adityamaru adityamaru self-requested a review August 11, 2023 20:57
Previously we sent export requests to all spans being backed up. The ranges for spans
of tables that had set the flag to exclude data from backup would reply with an
empty response, excluding their data, but the backup process still sent these
ranges these requests.

This changes the backup process to not send requests for spans from excluded tables,
when performing database, table, or cluster backups. Backups of tenants will still send
export requests to every range for the tenant span, and those ranges that host tables
that are excluded will continue to reply with no data.

This is done both as an optimization, and so that backups can succeed even when a
table is unavailable, if, and only if, that table is excluded.

Release note (ops change): BACKUP now skips contacting the ranges for tables on which exclude_data_from_backup is set, and can thus succeed even if an excluded table is unavailable.
Epic: none.
Copy link
Contributor

@adityamaru adityamaru left a comment

Choose a reason for hiding this comment

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

LGTM, if you have to push again then the last backup can be switched from to to into

@dt
Copy link
Member Author

dt commented Aug 14, 2023

TFTRs!

bors r+

@dt dt added the backport-23.1.x Flags PRs that need to be backported to 23.1 label Aug 14, 2023
@craig
Copy link
Contributor

craig bot commented Aug 14, 2023

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Aug 14, 2023

Build succeeded:

@craig craig bot merged commit b1db60c into cockroachdb:master Aug 14, 2023
7 checks passed
@dt dt deleted the skip-excluded-spans branch August 23, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.1.x Flags PRs that need to be backported to 23.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants