Skip to content

backupccl: prevent OR from linking in virtual file pointing to empty key space#122918

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
msbutler:butler-or-targets
May 1, 2024
Merged

backupccl: prevent OR from linking in virtual file pointing to empty key space#122918
craig[bot] merged 2 commits intocockroachdb:masterfrom
msbutler:butler-or-targets

Conversation

@msbutler
Copy link
Copy Markdown
Collaborator

@msbutler msbutler commented Apr 23, 2024

See individual commits.

@msbutler msbutler self-assigned this Apr 23, 2024
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@msbutler msbutler force-pushed the butler-or-targets branch from 56bc559 to 5c6c520 Compare April 25, 2024 14:56
@msbutler msbutler changed the title Butler or targets backupccl: prevent OR from linking in virtual file pointing to empty key space Apr 25, 2024
@msbutler
Copy link
Copy Markdown
Collaborator Author

unrelated test flake

@msbutler msbutler force-pushed the butler-or-targets branch from 5c6c520 to bedcce3 Compare April 25, 2024 19:41
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Apr 25, 2024

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.

@msbutler msbutler marked this pull request as ready for review April 25, 2024 19:42
@msbutler msbutler requested review from a team as code owners April 25, 2024 19:42
@msbutler msbutler requested review from dt and stevendanna and removed request for a team April 25, 2024 19:42
}
if !entry.Span.Contains(file.BackupFileEntrySpan) {
return errors.AssertionFailedf("file span %s is not contained in restore span %s", file.BackupFileEntrySpan, entry.Span)
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

one thought: we don't really clean up linked ssts if the link phase fails partway through. I feel fine with this for private preview. Better to fail loudly then silently corrupt the db.

We could gen spans before the actual link phase but i dont feel like optimizing UX private preview restore rn.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's log file.Path here as well to make it easier to investigate if it happens.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We believe entry.Span == restoringSubspan, right? Should we check that too just to be sure?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done and done.

Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Just some minor nits.

A bit of a bummer to have to bring out such a big hammer, but it's better than the alternative.

}
if !entry.Span.Contains(file.BackupFileEntrySpan) {
return errors.AssertionFailedf("file span %s is not contained in restore span %s", file.BackupFileEntrySpan, entry.Span)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's log file.Path here as well to make it easier to investigate if it happens.

Comment on lines +829 to +830
return nil, errors.Newf("restore target contains two distinct spans with table id %d. Online restore cannot handle this as it may make an empty file span", tableID)
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you fancied we could return an unimplemented error here with a reference to an issue.

To prevent reading from a virtual file that points to empty key space, this
patch fails an online restore if any of the target key spans are not table
spans; for example, if a table had a dropped index.

Informs cockroachdb#122176

Release note: none
@msbutler msbutler force-pushed the butler-or-targets branch from bedcce3 to 195c733 Compare April 30, 2024 20:18
@msbutler msbutler added the backport-24.1.x Flags PRs that need to be backported to 24.1. label Apr 30, 2024
…p files

One way online restore can link a virtual file that points to empty key space
in the backing file is if the restoreSpanEntry does not fully contain one of
its backup files. This patch fails the link phase of online restore if this
condition is detected.

Epic: none

Release note: none
@msbutler msbutler force-pushed the butler-or-targets branch from 195c733 to 3abb0e5 Compare May 1, 2024 14:06
@msbutler
Copy link
Copy Markdown
Collaborator Author

msbutler commented May 1, 2024

TFTR!

bors r=dt

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 1, 2024

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 1, 2024

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented May 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-24.1.x Flags PRs that need to be backported to 24.1.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants