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: fix codec selection during restore #116316

Merged
merged 1 commit into from Dec 15, 2023

Conversation

adityamaru
Copy link
Contributor

Previously, the codec selection logic only looked at a single manifest to determine whether the backup data requires a system or tenant codec to be read. In older release branches if the full backup was empty (but a subsequent incremental was not) then we could incorrectly use a system codec for a backup that actually required a tenant codec.

To fix this we now process all the manifests in the backup chain and use the first non-empty manifest.

Fixes: #115773
Release note(bug fix): an empty full backup, followed by non-empty incrementals taken inside an application tenant may be unrestoreable because of the use of an incorrect SQL codec

Previously, the codec selection logic only looked at a
single manifest to determine whether the backup data requires
a system or tenant codec to be read. In older release branches
if the full backup was empty (but a subsequent incremental
was not) then we could incorrectly use a system codec for
a backup that actually required a tenant codec.

To fix this we now process all the manifests in the backup
chain and use the first non-empty manifest.

Fixes: cockroachdb#115773
Release note(bug fix): an empty full backup, followed by
non-empty incrementals taken inside an application tenant
may be unrestoreable because of the use of an incorrect
SQL codec
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@adityamaru adityamaru added backport-23.1.x Flags PRs that need to be backported to 23.1 backport-23.2.x Flags PRs that need to be backported to 23.2. labels Dec 13, 2023
},
expectedCodec: keys.SystemSQLCodec,
},
} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice test!

Copy link
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

Looks great! nice tests!

sqlDB.Exec(t, "CREATE TABLE create_and_drop.a (k int, v string)")
sqlDB.Exec(t, "INSERT INTO create_and_drop.a VALUES (1, 'foo')")
sqlDB.QueryRow(t, "SELECT cluster_logical_timestamp()").Scan(&tsBefore)
sqlDB.Exec(t, "DROP TABLE create_and_drop.a")
Copy link
Collaborator

Choose a reason for hiding this comment

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

curious: why did you need to drop the table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't necessarily have to, just copy pasted this test from another test where I initially noticed this behaviour

@adityamaru
Copy link
Contributor Author

Thanks!

bors r=msbutler

@craig
Copy link
Contributor

craig bot commented Dec 15, 2023

Build failed:

@adityamaru
Copy link
Contributor Author

bors retry

@craig
Copy link
Contributor

craig bot commented Dec 15, 2023

Build succeeded:

@craig craig bot merged commit 591ddcd into cockroachdb:master Dec 15, 2023
9 checks passed
Copy link

blathers-crl bot commented Dec 15, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from a75b261 to blathers/backport-release-23.1-116316: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1.x failed. See errors above.


error creating merge commit from a75b261 to blathers/backport-release-23.2-116316: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.2.x failed. See errors above.


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

@stevendanna
Copy link
Collaborator

@adityamaru Heads up that your auto-backport failed here.

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 backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

backupccl: empty full followed by incremental backup can result in use of the wrong codec
4 participants