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

backup: include tenant_settings in cluster backup #76758

Merged
merged 1 commit into from
Feb 18, 2022
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
13 changes: 13 additions & 0 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7199,6 +7199,12 @@ func TestBackupRestoreTenant(t *testing.T) {
return nil
})

// Set an all-tenant override and a tenant-specific override.
// TODO(radu): use ALTER TENANT when available.
systemDB.Exec(t, `INSERT INTO system.tenant_settings (tenant_id, name, value, value_type) VALUES
(0, 'tenant_cost_model.kv_read_cost_per_megabyte', '123', 'f'),
(10, 'tenant_cost_model.kv_write_cost_per_megabyte', '456', 'f')`)

systemDB.Exec(t, `BACKUP system.users TO 'nodelocal://1/users'`)
systemDB.CheckQueryResults(t, `SELECT manifest->>'tenants' FROM [SHOW BACKUP 'nodelocal://1/users' WITH as_json]`, [][]string{{"[]"}})

Expand Down Expand Up @@ -7387,13 +7393,20 @@ func TestBackupRestoreTenant(t *testing.T) {
restoreTenant10.CheckQueryResults(t, `select * from foo.bar`, tenant10.QueryStr(t, `select * from foo.bar`))
restoreTenant10.CheckQueryResults(t, `select * from foo.bar2`, tenant10.QueryStr(t, `select * from foo.bar2`))

// Verify cluster overrides.
restoreTenant10.CheckQueryResults(t, `SHOW CLUSTER SETTING tenant_cost_model.kv_read_cost_per_megabyte`, [][]string{{"123"}})
restoreTenant10.CheckQueryResults(t, `SHOW CLUSTER SETTING tenant_cost_model.kv_write_cost_per_megabyte`, [][]string{{"456"}})

_, restoreConn11 := serverutils.StartTenant(
t, restoreTC.Server(0), base.TestTenantArgs{TenantID: roachpb.MakeTenantID(11), Existing: true},
)
defer restoreConn11.Close()
restoreTenant11 := sqlutils.MakeSQLRunner(restoreConn11)

restoreTenant11.CheckQueryResults(t, `select * from foo.baz`, tenant11.QueryStr(t, `select * from foo.baz`))

// Check the all-tenant override.
restoreTenant11.CheckQueryResults(t, `SHOW CLUSTER SETTING tenant_cost_model.kv_read_cost_per_megabyte`, [][]string{{"123"}})
})

t.Run("restore-tenant10-to-ts1", func(t *testing.T) {
Expand Down
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 @@ -637,6 +637,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
{"role_options"},
{"scheduled_jobs"},
{"settings"},
{"tenant_settings"},
{"ui"},
{"users"},
{"zones"},
Expand Down Expand Up @@ -727,6 +728,7 @@ func TestClusterRestoreFailCleanup(t *testing.T) {
{"role_options"},
{"scheduled_jobs"},
{"settings"},
{"tenant_settings"},
{"ui"},
{"users"},
{"zones"},
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 @@ -359,7 +359,7 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.TenantSettingsTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
shouldIncludeInClusterBackup: optInToClusterBackup,
},
}

Expand Down