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

storage: require min version file and deprecate cluster version key #97054

Merged
merged 2 commits into from
Feb 18, 2023

Conversation

RaduBerinde
Copy link
Member

@RaduBerinde RaduBerinde commented Feb 13, 2023

storage: require min version file

This change makes the min version file a requirement for opening an
existing store.

We have been writing this file out for at least two releases, so this
doesn't affect our compatibility story.

Release note: None
Epic: none

storage: deprecate cluster version key

This change deprecates the cluster version key. We have the version
outside the store (in the min version file) so we no longer need to
store it inside a KV.

To keep backward compatibility with 22.2, we still write the key but
we never read it. Once we stop supporting 22.2, we can stop writing it
altogether.

This required updating the TestClusterVersionWriteSynthesize to use
versions that work with the binary. We also clean up the test and move
it to kvstorage where it belongs.

Release note: None
Epic: none

Fixes #42653.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde RaduBerinde force-pushed the no-version-key branch 3 times, most recently from 9c6611e to 9091480 Compare February 14, 2023 18:11
@RaduBerinde RaduBerinde changed the title storage: deprecate cluster version key [draft] storage: require min version file and deprecate cluster version key Feb 14, 2023
@RaduBerinde RaduBerinde marked this pull request as ready for review February 14, 2023 22:13
@RaduBerinde RaduBerinde requested review from a team as code owners February 14, 2023 22:13
@RaduBerinde RaduBerinde requested a review from a team February 14, 2023 22:13
@RaduBerinde RaduBerinde requested review from a team as code owners February 14, 2023 22:13
@RaduBerinde RaduBerinde requested review from smg260, renatolabs, sumeerbhola, jbowens and tbg and removed request for a team February 14, 2023 22:13
Copy link
Member

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Looks good to me (though I'd count this as a non-expert review).

@@ -1078,32 +1078,43 @@ func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {

db, err := pebble.Open(cfg.StorageConfig.Dir, opts)
if err != nil {
if !minVerFileExists && strings.Contains(err.Error(), "already exists") {
Copy link
Member

Choose a reason for hiding this comment

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

strings.Contains? Wouldn't we want a structured error here? An argument could be made that it isn't worth it because it's such a dead code path & the event of a false positive isn't dramatic since the startup was failing either way?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I would add a better way in Pebble. But for now I'm not sure of the higher level logic - what are the expectations if a machine fails during bootstrap? If it fails after creating the store but before creating the min version file, we would need manual cleanup before trying to bootstrap the store again. OTOH if we allow an existing store, then we might open an old version. Maybe the right thing is to add an ErrorIfNotEmpty mode to Pebble?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

Nice

:lgtm:

Reviewed 3 of 5 files at r1, 5 of 5 files at r2, 16 of 16 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @renatolabs, @smg260, @sumeerbhola, and @tbg)

@RaduBerinde RaduBerinde requested a review from a team February 17, 2023 19:55
@RaduBerinde
Copy link
Member Author

TFTR!

This change makes the min version file a requirement for opening an
existing store.

We have been writing this file out for at least two releases, so this
doesn't affect our compatibility story.

Release note: None
Epic: none
This change deprecates the cluster version key. We have the version
outside the store (in the min version file) so we no longer need to
store it inside a KV.

To keep backward compatibility with 22.2, we still write the key but
we never read it. Once we stop supporting 22.2, we can stop writing it
altogether.

This required updating the `TestClusterVersionWriteSynthesize` to use
versions that work with the binary. We also clean up the test and move
it to `kvstorage` where it belongs.

Release note: None
Epic: none
@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 18, 2023

Build succeeded:

@craig craig bot merged commit cc58f15 into cockroachdb:master Feb 18, 2023
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.

storage/engine: improve cluster version handling
4 participants