Skip to content

release-26.2: backup: clear default privileges on database and schema descriptors during restore#166183

Merged
rafiss merged 2 commits intocockroachdb:release-26.2from
spilchen:blathers/backport-release-26.2-165997
Mar 19, 2026
Merged

release-26.2: backup: clear default privileges on database and schema descriptors during restore#166183
rafiss merged 2 commits intocockroachdb:release-26.2from
spilchen:blathers/backport-release-26.2-165997

Conversation

@spilchen
Copy link
Contributor

@spilchen spilchen commented Mar 19, 2026

Backport 2/2 commits from #165997 on behalf of @spilchen.


During non-cluster restore, default privileges on database descriptors were carried over verbatim from the backup, potentially referencing users that don't exist on the target cluster. Clear them alongside regular privileges, which are already reset to defaults.

The second commit extends the first fix to also clear default privileges on schema
descriptors during non-cluster restore. Schemas can also carry default
privileges referencing users that don't exist on the target cluster.

Closes #164961
Epic: none
Release note (bug fix): Fixed a bug where restoring a database backup containing default privileges referencing non-existent users would leave dangling user references in the restored database descriptor.


Release justification: fix GA blocker

spilchen and others added 2 commits March 17, 2026 18:17
During non-cluster restore, default privileges on database descriptors
were carried over verbatim from the backup, potentially referencing users
that don't exist on the target cluster. Clear them alongside regular
privileges, which are already reset to defaults.

Closes cockroachdb#164961
Epic: none
Release note (bug fix): Fixed a bug where restoring a database backup
containing default privileges referencing non-existent users would leave
dangling user references in the restored database descriptor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…store

Extend the previous fix to also clear default privileges on schema
descriptors during non-cluster restore. Schemas can also carry default
privileges referencing users that don't exist on the target cluster.

Release note: None
Epic: none

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@spilchen spilchen force-pushed the blathers/backport-release-26.2-165997 branch from 5cadad9 to d3c2cdf Compare March 19, 2026 16:35
@spilchen spilchen requested review from a team as code owners March 19, 2026 16:35
@spilchen spilchen requested review from msbutler and removed request for a team March 19, 2026 16:35
@blathers-crl blathers-crl bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Mar 19, 2026
@blathers-crl blathers-crl bot requested review from dt and rafiss March 19, 2026 16:35
@blathers-crl
Copy link

blathers-crl bot commented Mar 19, 2026

⚠️ End-of-Life Version Warning

This backport targets 26.2, which is an End-of-Life (EOL) version.

Please verify that backporting to this EOL version is intentional and appropriate. EOL versions no longer receive maintenance updates according to our support policy.


Thanks for opening a backport.

Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate.

@blathers-crl blathers-crl bot added backport Label PR's that are backports to older release branches T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Mar 19, 2026
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@msbutler
Copy link
Collaborator

hey @andrew-r-thomas , could you give this PR a close read to ensure it doesn't affect your restore with grants work? in addition, perhaps we should write a test to understand how restore with grants interacts with default privs.

@andrew-r-thomas
Copy link
Contributor

@msbutler currently restore with grants leaves default privs completely untouched (and in fact my understanding assumption was that they were being cleared by the function being modified in this PR), so this shouldn't have any impact on the feature, if anything it helps, restore with grants is set up to assume that it has a nice fresh empty descriptor (wrt privs) to play with in publishDescriptors. Though potentially restoring default privs could go on our list of possible improvements to the feature if we get product/customer signal that it would be useful.

@msbutler
Copy link
Collaborator

@andrew-r-thomas let me be a bit more specific: suppose user max has default select privs on all tables in database foo. Suppose we backup the cluster and then run restore foo (i.e. no with grants) in a new cluster with max in it. Before this PR merged, i think max in the restored cluster would inherit the default select priv on foo. This was a bug. Now max does not inherit the select priv.

I think what you're saying is that even with restore with grants, max should not have select privs on database foo. correct?

@rafiss rafiss merged commit 2f7b26e into cockroachdb:release-26.2 Mar 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) target-release-26.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants