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 more testing for concurrent region/rbr interactions #63804

Merged
merged 1 commit into from
Apr 19, 2021

Conversation

arulajmani
Copy link
Collaborator

Informs #63462

This patch adds TestRegionAddDropEnclosingRegionalByRowOps, which
contains subtests with the following sketch:

  • Client 1 performs an ALTER ADD / DROP REGION. Let the user txn commit.
  • Block in the type schema changer.
  • Client 2 performs an operation on a REGIONAL BY ROW table, such as creating
    an index, unique constraint, altering the primary key etc.
  • Test both a rollback in the type schema changer and a successful execution.
  • Ensure the partitions on the REGIONAL BY ROW table are sane.

Release note: None

@arulajmani arulajmani requested review from otan, ajstorm and a team April 16, 2021 22:04
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@otan otan 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 and @arulajmani)


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

					_, err := sqlDB.Exec(regionAlterCmd.cmd)
					if regionAlterCmd.shouldSucceed {
						require.NoError(t, err)

t.Fatal on a goroutine is apparently a no-no from my research, can we send an error to a waiting channel to be checked by the main channel?


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

					} else {
						if !testutils.IsError(err, "boom") {
							t.Errorf("expected error boom, found %v", err)

probably should be the equivalent of require.Truef(t, testutils.IsError(err, "boom") ), but goroutine so should send it out.


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

						}
					}
					typeChangeFinished <- struct{}{}

nit: can we defer this to prevent stuck routines? also, do you mind using close instead of send empty struct?


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

					return nil
				})
				<-typeChangeFinished

nit: can we defer this close

Copy link
Contributor

@otan otan 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 and @arulajmani)


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

Previously, otan (Oliver Tan) wrote…

nit: can we defer this to prevent stuck routines? also, do you mind using close instead of send empty struct?

(i.e. defer func() { close (typeChangeFinished) }() at the beginning of the goroutine)


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

Previously, otan (Oliver Tan) wrote…

nit: can we defer this close

oops, ignore this comment!

Informs cockroachdb#63462

This patch adds TestRegionAddDropEnclosingRegionalByRowOps, which
contains subtests with the following sketch:

- Client 1 performs an ALTER ADD / DROP REGION. Let the user txn commit.
- Block in the type schema changer.
- Client 2 performs an operation on a REGIONAL BY ROW table, such as creating
 an index, unique constraint, altering the primary key etc.
- Test both a rollback in the type schema changer and a successful execution.
- Ensure the partitions on the REGIONAL BY ROW table are sane.

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 and @otan)


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

Previously, otan (Oliver Tan) wrote…

t.Fatal on a goroutine is apparently a no-no from my research, can we send an error to a waiting channel to be checked by the main channel?

I'll just switch to using t.Error which I know is encouraged over t.Fatal in goroutines.


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

Previously, otan (Oliver Tan) wrote…

probably should be the equivalent of require.Truef(t, testutils.IsError(err, "boom") ), but goroutine so should send it out.

Errorf is fine, a linter told me once.


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

Previously, otan (Oliver Tan) wrote…

(i.e. defer func() { close (typeChangeFinished) }() at the beginning of the goroutine)

Done!

@arulajmani
Copy link
Collaborator Author

CI failure is unlreated, gonna merge. TFTR!

bors r=otan

@craig
Copy link
Contributor

craig bot commented Apr 19, 2021

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Apr 19, 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.

3 participants