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: add tests for concurrent add/drop region operations #62826

Merged
merged 1 commit into from
Apr 2, 2021

Conversation

arulajmani
Copy link
Collaborator

This patch generalizes the setup in what was previously
TestConcurrentDropRegion and extends it to all combinations of
add/drop region on a multi-region database. The only change is that
I've added a regional by row table into the test setup mixer, so as to
excercise the repartitioning semantics.

Previously, there was a limitation with concurrent add/drop regions
where both the operations were bound to fail in the repartitioning
phase. This limitation was fixed in #60620, but we never had a
regression test for it. Adding a regional by row table during the
test setup serves as one.

Closes #62813

Release note: None

@arulajmani arulajmani requested review from ajstorm and a team March 30, 2021 20:55
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@ajstorm ajstorm 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 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/ccl/multiregionccl/region_test.go, line 72 at r1 (raw file):

			`ALTER DATABASE db ADD REGION "us-east5"`,
			[]string{"us-east1", "us-east3", "us-east5"},
		},

Really nice! Can we also add test cases for adding/dropping the same region concurrently and generalize this to expect an error for one of the commands?


pkg/ccl/multiregionccl/region_test.go, line 138 at r1 (raw file):

			require.NoError(t, err)
			if numRegions != len(tc.expectedRegions) {
				t.Fatalf("unexpected number of regions, expected: %d found %d",

Will erroring out here make this test case difficult to debug? Is it not possible to validate the count and the regions together below, and if either of them are bad, print out the expected list and what was found?

This patch generalizes the setup in what was previously
`TestConcurrentDropRegion` and extends it to all combinations of
add/drop region on a multi-region database. The only change is that
I've added a regional by row table into the test setup mixer, so as to
excercise the repartitioning semantics.

Previously, there was a limitation with concurrent add/drop regions
where both the operations were bound to fail in the repartitioning
phase. This limitation was fixed in cockroachdb#60620, but we never had a
regression test for it. Adding a regional by row table during the
test setup serves as one.

Closes cockroachdb#62813

Release note: None
Copy link
Collaborator Author

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajstorm)


pkg/ccl/multiregionccl/region_test.go, line 72 at r1 (raw file):

Previously, ajstorm (Adam Storm) wrote…

Really nice! Can we also add test cases for adding/dropping the same region concurrently and generalize this to expect an error for one of the commands?

Good call, added!


pkg/ccl/multiregionccl/region_test.go, line 138 at r1 (raw file):

Previously, ajstorm (Adam Storm) wrote…

Will erroring out here make this test case difficult to debug? Is it not possible to validate the count and the regions together below, and if either of them are bad, print out the expected list and what was found?

Is something like this what you had in mind?


pkg/ccl/multiregionccl/region_test.go, line 92 at r2 (raw file):

			`ALTER DATABASE db DROP REGION "us-east2"`,
			[]string{"us-east1", "us-east3"},
			`enum value "us-east2" is already being dropped`,

How do you feel about this error message? I could wrap this around a "cannot drop region" or something of that sort, but before I tack on that commit, do you think it's worth the effort?

@arulajmani arulajmani requested a review from ajstorm April 1, 2021 16:59
Copy link
Collaborator

@ajstorm ajstorm 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 r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/ccl/multiregionccl/region_test.go, line 72 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Good call, added!

Great. One more minor request. Can you also add one where you swap the order to ensure that we get the reverse error message?


pkg/ccl/multiregionccl/region_test.go, line 138 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Is something like this what you had in mind?

🎉


pkg/ccl/multiregionccl/region_test.go, line 92 at r2 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

How do you feel about this error message? I could wrap this around a "cannot drop region" or something of that sort, but before I tack on that commit, do you think it's worth the effort?

Seems to me like the message should refer to the region, and not the enum value. We don't want customers to have to understand the implementation details.

Copy link
Collaborator

@ajstorm ajstorm left a comment

Choose a reason for hiding this comment

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

Sorry, should have been a publish and approve! :lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani)

Copy link
Collaborator Author

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

Discussed offline, we'll unify these error messages in a different PR. TFTR!

bors r=ajstorm

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @ajstorm and @arulajmani)


pkg/ccl/multiregionccl/region_test.go, line 72 at r1 (raw file):

Previously, ajstorm (Adam Storm) wrote…

Great. One more minor request. Can you also add one where you swap the order to ensure that we get the reverse error message?

I've got one for add-drop, drop-add, add-add, and drop-drop. That's all of them, right?

@ajstorm
Copy link
Collaborator

ajstorm commented Apr 1, 2021 via email

@craig
Copy link
Contributor

craig bot commented Apr 1, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Apr 2, 2021

Build succeeded:

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: add test for concurrent region DDL operations
3 participants