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, restoreccl: include system.privileges in full cluster restore #86830

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/ccl/backupccl/full_cluster_backup_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
{"database_role_settings"},
{"external_connections"},
{"locations"},
{"privileges"},
{"role_id_seq"},
{"role_members"},
{"role_options"},
Expand Down Expand Up @@ -735,6 +736,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
{"database_role_settings"},
{"external_connections"},
{"locations"},
{"privileges"},
{"role_id_seq"},
{"role_members"},
{"role_options"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
expectMissingInSystemTenant: true,
},
systemschema.SystemPrivilegeTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
shouldIncludeInClusterBackup: optInToClusterBackup, // No desc ID columns.
Copy link
Collaborator

Choose a reason for hiding this comment

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

✅ Double checked that it looks like the format for the path element in the table also doesn't use any IDs that need rewritting.

},
systemschema.SystemExternalConnectionsTable.GetName(): {
shouldIncludeInClusterBackup: optInToClusterBackup, // No desc ID columns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ external_connections table full
foo table full
locations table full
postgres database full
privileges table full
public schema full
public schema full
public schema full
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ external_connections table full
foo table full
locations table full
postgres database full
privileges table full
public schema full
public schema full
public schema full
Expand Down
49 changes: 49 additions & 0 deletions pkg/ccl/backupccl/testdata/backup-restore/system-privileges-table
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
new-server name=s1
----

exec-sql
CREATE USER testuser;
CREATE USER testuser2;
GRANT SYSTEM MODIFYCLUSTERSETTING, VIEWACTIVITY TO testuser;
GRANT SELECT ON crdb_internal.tables TO testuser;
CREATE EXTERNAL CONNECTION foo AS 'nodelocal://0/foo';
GRANT USAGE ON EXTERNAL CONNECTION foo TO testuser2;
GRANT SYSTEM VIEWACTIVITYREDACTED TO testuser2;
GRANT SELECT ON crdb_internal.databases, crdb_internal.tables TO testuser2;
GRANT ALL ON EXTERNAL CONNECTION foo TO testuser2;
----

query-sql
SELECT * FROM system.privileges
----
root /externalconn/foo {ALL} {}
testuser /global/ {MODIFYCLUSTERSETTING,VIEWACTIVITY} {}
testuser /vtable/crdb_internal/tables {SELECT} {}
testuser2 /externalconn/foo {ALL} {}
testuser2 /global/ {VIEWACTIVITYREDACTED} {}
testuser2 /vtable/crdb_internal/databases {SELECT} {}
testuser2 /vtable/crdb_internal/tables {SELECT} {}

exec-sql
BACKUP INTO 'nodelocal://0/test/'
----

# Start a new cluster with the same IO dir.
new-server name=s2 share-io-dir=s1
----

# Restore into the new cluster.
exec-sql server=s2
RESTORE FROM LATEST IN 'nodelocal://0/test/'
----

query-sql server=s2
SELECT * FROM system.privileges
----
root /externalconn/foo {ALL} {}
testuser /global/ {MODIFYCLUSTERSETTING,VIEWACTIVITY} {}
testuser /vtable/crdb_internal/tables {SELECT} {}
testuser2 /externalconn/foo {ALL} {}
testuser2 /global/ {VIEWACTIVITYREDACTED} {}
testuser2 /vtable/crdb_internal/databases {SELECT} {}
testuser2 /vtable/crdb_internal/tables {SELECT} {}