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

[WIP] sql: partition REGIONAL BY ROW on all indexes during region changes #63968

Closed

Conversation

otan
Copy link
Contributor

@otan otan commented Apr 21, 2021

See individual commits for details.

Refs: #63462

@otan otan requested review from arulajmani, ajstorm and a team April 21, 2021 00:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan force-pushed the fix_drop_index_partition branch 3 times, most recently from a56cb24 to 612552f Compare April 21, 2021 02:19
@otan otan changed the title sql: apply partitions for REGIONAL BY ROW on all indexes sql: partition REGIONAL BY ROW on all indexes during region changes Apr 21, 2021
@otan
Copy link
Contributor Author

otan commented Apr 21, 2021

thought about this more and now i think this is the wrong way to go about it. we should instead repartition after index creation/drop (even during failures). doing this on AllIndexes has a chance of e.g. for RBR->GLOBAL making partitions on the new indexes of the global table.

incompatible

Release note (bug fix): Previously, if a DROP INDEX failed during a
REGIONAL BY ROW transition, the index may be re-inserted back into the
REGIONAL BY ROW table but would be invalid if it was sharded or
partitioned. This is now rectified.
@otan otan removed request for a team, arulajmani and ajstorm April 21, 2021 09:48
@otan otan reopened this Apr 21, 2021
@otan otan changed the title sql: partition REGIONAL BY ROW on all indexes during region changes [WIP] sql: partition REGIONAL BY ROW on all indexes during region changes Apr 21, 2021
@otan otan marked this pull request as draft April 21, 2021 09:48
@otan otan force-pushed the fix_drop_index_partition branch from 612552f to ca02c00 Compare April 21, 2021 10:03
Only doing REGIONAL BY ROW repartitions on non-drop indexes leads us to
a failure mode where if the DROP INDEX fails during an ADD/DROP REGION,
we do not reset the partitions appropriately.

This is now resolved.

Release note (bug fix): Fix a bug where a concurrent DROP INDEX which
fails whilst an ADD/DROP REGION is in progress leads to an invalid
partitioning set up.
@otan otan force-pushed the fix_drop_index_partition branch from ca02c00 to faa2e64 Compare April 21, 2021 10:34
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.

Added a few comments. Would like @arulajmani to have a look too though, as I'm still pretty new to these concurrent tests in go.

Reviewed 3 of 3 files at r1, 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan)


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

}

// TestDropIndexFailureDuringAddOrDropRegion a DROP INDEX failing during

Nit: TestDropIndexFailureDuringAddOrDropRegion tests a DROP INDEX...


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

// TestDropIndexFailureDuringAddOrDropRegion a DROP INDEX failing during
// ADD/DROP REGION, in which case the dropped index should still contain
// the new indexes.

Nit: ...should still contain the proper set of regions?


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

				SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{
					RunBeforeBackfill: func() error {
						if block {

Do we need a mutex above this to ensure that we don't get both racers in this block (in which case the test would hang)?


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

			require.NoError(t, err)

			block = true

I'm confused as to why we need to set this to true down here. Can't we just initialize it to true above? Is there any chance that the DROP/CREATE/CREATE sequence above will invoke the schema changer?


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

			wg.Add(1)

			_, err = sqlDB.Exec(tc.regionChangeSQL)

Forgive me if this comment is noise, as I'm still pretty new to writing these types of concurrent go tests, but shouldn't we wait for the above go routine to make it to the type schema changer before we run this? As written, isn't it possible that the ADD/DROP region statement could make it into the error path before the DROP INDEX statement does?

@ajstorm ajstorm requested a review from arulajmani April 21, 2021 14:33
@ajstorm
Copy link
Collaborator

ajstorm commented Apr 21, 2021

Gah! And now I notice the WIP and closed 🤦

@otan
Copy link
Contributor Author

otan commented Apr 21, 2021

haha sorry, not sure whether this should go through...

@otan otan closed this Apr 22, 2021
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