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

sql: allow ALTER DATABASE PRIMARY REGION to work on system tenants #121293

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

jasminejsun
Copy link
Contributor

@jasminejsun jasminejsun commented Mar 28, 2024

Previously, on a multi-region setup the system database could not be modified to be multi-region and it was blocked from being made multi-region aware. To address this, we are now allowing ALTER DATABASE PRIMARY REGION to work on system tenants.

Fixes: #63365
Epic: CRDB-33032

Release note (sql change): Previously, we added support for settings reegion on the system database, which was limited to tenants only. We lifted this limitation to allow ALTER DATABASE PRIMARY REGION to work on system tenants. Note that after adding non-primary regions, we recommend that users do a rolling restart to propogate region information.

@jasminejsun jasminejsun requested review from a team as code owners March 28, 2024 18:33
@jasminejsun jasminejsun requested review from DarrylWong and renatolabs and removed request for a team March 28, 2024 18:33
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jasminejsun jasminejsun requested a review from fqazi March 28, 2024 18:34
@annrpom annrpom self-requested a review March 28, 2024 19:09
@jasminejsun jasminejsun force-pushed the mr_system_database branch 2 times, most recently from 5463cae to ef0fde6 Compare April 1, 2024 17:25
Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 6 files at r1, 1 of 1 files at r2, 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @annrpom and @jasminejsun)


pkg/cmd/roachtest/tests/multi_region_system_database.go line 117 at r3 (raw file):

				t.WorkerStatus("stop")
				stopOpts := option.DefaultStopOpts()
				c.Stop(ctx, t.L(), stopOpts, c.Node(i))

I think this does a graceful kill, lets be a bit more aggressive:

c.Run(ctx, install.WithNodes(c.Node(i), "killall -9 cockroach")


pkg/ccl/multiregionccl/multiregion_system_table_test.go line 310 at r3 (raw file):

}

func TestMRSystemDatabase(t *testing.T) {

I'm thinking we just modify the multi-tenant multi-region one above to also test the system tenant. What do you think?

@jasminejsun jasminejsun force-pushed the mr_system_database branch 2 times, most recently from 3fa7ec1 to cd7939e Compare April 3, 2024 20:02
@jasminejsun jasminejsun requested a review from fqazi April 3, 2024 20:03
Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 2 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @annrpom and @jasminejsun)


pkg/ccl/multiregionccl/multiregion_system_table_test.go line 84 at r4 (raw file):

	tDB.CheckQueryResults(t, `SELECT * FROM crdb_internal.invalid_objects`, [][]string{})

	_, err = sqlDB.Exec(`SET CLUSTER SETTING sql.multiregion.preview_multiregion_system_database.enabled = true`)

Okay perfect, now lets just modify the tests below to check with both tDB and sqlDB. We can use a loop to pick one of the databases and confirm the same properties hold.

@jasminejsun jasminejsun requested a review from fqazi April 8, 2024 14:31
Previously, on a multi-region setup the system database could not be modified to be multi-region and it was blocked from being made multi-region aware. To address this, we are now allowing ALTER DATABASE
PRIMARY REGION to work on system tenants.

Fixes: cockroachdb#63365
Epic: CRDB-33032

Release note (sql change): Previously, we added support for settings reegion on the system database, which was limited to tenants only. We lifted this limitation to allow ALTER DATABASE PRIMARY REGION to work on system tenants.
To support preview status, we created a cluster setting called sql.multiregion.preview_multiregion_system_database that will give users the option to set up their system database as multi-region for Cockroach dedicated
(this cluster setting is not enabled by default). Note that after adding non-primary regions, we recommend that users do a rolling restart to propogate region information.
@fqazi fqazi requested a review from annrpom April 8, 2024 19:12
Copy link
Collaborator

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r5, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jasminejsun)


pkg/ccl/multiregionccl/multiregion_system_table_test.go line 91 at r5 (raw file):

	sDB.Exec(t, `ALTER DATABASE system ADD REGION "us-east3"`)

	testCases := []struct {

Nice!

@jasminejsun
Copy link
Contributor Author

bors r+

@craig craig bot merged commit 610688b into cockroachdb:master Apr 8, 2024
20 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql,*: make some or all system tables LOCALITY GLOBAL
4 participants