Skip to content

backupinfo: introduce a backupinfo package#82623

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:backup-info
Jun 28, 2022
Merged

backupinfo: introduce a backupinfo package#82623
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:backup-info

Conversation

@adityamaru
Copy link
Copy Markdown
Contributor

@adityamaru adityamaru commented Jun 8, 2022

The backupinfo package contains logic related to interacting
with information and metadata describing the backup. After this
change we have backupdest depending on backupinfo.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

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.

Did an early read through since I'm thinking of also doing some reorganisation.

Overall, I think it makes sense to have a package focused on interacting with the context of a specific backup directory.

It's easy to spend a lot of time fretting about details (is a backup directory and the chain of incrementals related to it its own concept that deserve a name, should we separate the reading of the raw bytes out of the backup from parsing their meaning a bit more, etc). But, this seems like a reasonable first cut to me.

Comment on lines 96 to 98
// conflicts between the starting bytes of a protobuf and these magic bytes.
func isGZipped(dat []byte) bool {
func IsGZipped(dat []byte) bool {
gzipPrefix := []byte("\x1F\x8B\x08")
return bytes.HasPrefix(dat, gzipPrefix)
}
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.

[future] I could see this moving to somewhere in pkg/util

filename := fmt.Sprintf("%s_%d_%s",
backupPartitionDescriptorPrefix, nextPartitionedDescFilenameID, sanitizeLocalityKV(kv))
filename := fmt.Sprintf("%s_%d_%s", backupPartitionDescriptorPrefix,
nextPartitionedDescFilenameID, backupinfo.SanitizeLocalityKV(kv))
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.

[future] We use "Sanitize" in some places to mean "redaction" and then here we use it to mean "make a name suitable to be a filename". We can probably clean up the naming here.

// is stored if present. It can be found in the name of the backup manifest +
// this suffix.
backupManifestChecksumSuffix = "-CHECKSUM"
BackupManifestChecksumSuffix = "-CHECKSUM"
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.

[future,discussion] Some of these being public is a signal that perhaps we need some other methods in this package. That is, eventually do we expect it to be the case that most users of this package don't need to worry about the internal structure of these constants.

@adityamaru adityamaru force-pushed the backup-info branch 2 times, most recently from 2b9cff3 to 0e109ae Compare June 23, 2022 14:42
@adityamaru adityamaru marked this pull request as ready for review June 23, 2022 14:42
@adityamaru adityamaru requested a review from a team as a code owner June 23, 2022 14:42
@adityamaru adityamaru requested a review from a team June 23, 2022 14:42
@adityamaru adityamaru requested a review from a team as a code owner June 23, 2022 14:42
@adityamaru adityamaru requested review from rhu713 and stevendanna June 23, 2022 14:43
@adityamaru
Copy link
Copy Markdown
Contributor Author

@stevendanna I've made you wait a little but this should be RFAL 😃 I agree that there is definitely follow up cleanup that we should undertake including moving some of the constants in backupbase into relevant packages.

The backupinfo package contains logic related to interacting
with information and metadata describing the backup. After this
change we have `backupdest` depending on `backupinfo`.

Release note: None
@livlobo
Copy link
Copy Markdown
Contributor

livlobo commented Jun 23, 2022

@adityamaru - mind filing a GH issue corresponding to this PR?

@adityamaru
Copy link
Copy Markdown
Contributor Author

@livlobo filed #83338

@livlobo
Copy link
Copy Markdown
Contributor

livlobo commented Jun 24, 2022

Perfect, thank you!

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.

Nice.

@adityamaru
Copy link
Copy Markdown
Contributor Author

TFTR!

bors r=stevendanna

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 28, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 28, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 28, 2022

Build failed (retrying...):

@craig craig bot merged commit 5541cf8 into cockroachdb:master Jun 28, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 28, 2022

Build succeeded:

@adityamaru adityamaru deleted the backup-info branch June 28, 2022 20:54
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.

4 participants