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: prevent opening unsupported database engine #89836

Closed
jbowens opened this issue Oct 12, 2022 · 5 comments · Fixed by #96394
Closed

storage: prevent opening unsupported database engine #89836

jbowens opened this issue Oct 12, 2022 · 5 comments · Fixed by #96394
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-storage Storage Team

Comments

@jbowens
Copy link
Collaborator

jbowens commented Oct 12, 2022

Related to #42653.

Now that the active cluster version is persisted outside of the engine, we should fail early (before opening the Engine) if the database's cluster version is too old. This has come before in support issues where a client receives an inscrutable encryption-at-rest error message when they forgot to finalize the pervious version's cluster version.

This would also help guard against corruption based on assumptions that database state is at least the previous Cockroach version's cluster version.

Jira issue: CRDB-20461

@jbowens jbowens added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Oct 12, 2022
@blathers-crl blathers-crl bot added the T-storage Storage Team label Oct 12, 2022
@RaduBerinde
Copy link
Member

What is the correct policy for when a version is too old? Is it correct to say that the database version must be at least BinaryMinSupportedVersion? Or that it must be at most 1 major release behind the active cluster version?

@jbowens
Copy link
Collaborator Author

jbowens commented Jan 5, 2023

Is it correct to say that the database version must be at least BinaryMinSupportedVersion?

Yeah, I think that's right.

@RaduBerinde
Copy link
Member

AFAICT this check already exists:

if minStoreVersion.Version.Less(binaryMinSupportedVersion) {

I verified manually by starting a new 21.2 cluster then running 22.2:

ERROR: cockroach server exited with error: store <no-attributes>=/tmp/vertest/cockroach-data, last used with cockroach version v21.2, is too old for running version v22.2 (which requires data from v22.1 or later)

Perhaps in the encryption-at-rest case we get an earlier, less useful error? In any case, it looks like we are covered functionally so I'm not sure there is anything to do here.

@jbowens
Copy link
Collaborator Author

jbowens commented Jan 8, 2023

Perhaps in the encryption-at-rest case we get an earlier, less useful error? In any case, it looks like we are covered functionally so I'm not sure there is anything to do here.

This issue is about moving the check up to before we ever open the engine. The above check doesn't use the min-version file and uses the old cluster version key that's stored within the engine itself. In some cases, waiting until you've already opened the engine to check compatibility is too late and has potential to corrupt the database.

We'd like to:

  1. check the min-version file before opening the Engine
  2. remove the cluster version key stored inside the Engine, since it's now made obsolete by the min-version file

@RaduBerinde
Copy link
Member

Ah, thanks for the clarification! If we make those changes, it feels like we'll need to require the existence of the min-version file. It looks like it was added in v21.2 so that would be a safe change at this point.

@RaduBerinde RaduBerinde self-assigned this Jan 14, 2023
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Feb 1, 2023
This change adds a check for old versions as soon as we open the min
version file, before opening the store. We currently check this at a
later time; in some cases, it is too late and there is potential for
corruption.

Release note: None

Fixes cockroachdb#89836
craig bot pushed a commit that referenced this issue Feb 4, 2023
96394: storage: check for old store version upfront r=RaduBerinde a=RaduBerinde

#### storage: minor cleanup around MinVersionIsAtLeastTargetVersion

Removing this unused method from the Engine interface.

Release note: None

#### storage: check for old store version upfront

This change adds a check for old versions as soon as we open the min
version file, before opening the store. We currently check this at a
later time; in some cases, it is too late and there is potential for
corruption.

Release note: None

Fixes #89836

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
@craig craig bot closed this as completed in 39c7443 Feb 4, 2023
cucaroach pushed a commit to cucaroach/cockroach that referenced this issue Feb 14, 2023
This change adds a check for old versions as soon as we open the min
version file, before opening the store. We currently check this at a
later time; in some cases, it is too late and there is potential for
corruption.

Release note: None

Fixes cockroachdb#89836
@jbowens jbowens moved this to Done in [Deprecated] Storage Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-storage Storage Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants