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: remove manually split ranges during TRUNCATE and DROP #38221

Merged
merged 1 commit into from
Jun 25, 2019

Conversation

jeffrey-xiao
Copy link
Contributor

If a table/index is dropped/truncated, any manually split ranges in the table/index should be unsplit so the automatic merge queue can clean up after it.

Additionally, re-enable splits in clearrange which was previously timing out because manual splits could not be automatically merged.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jeffrey-xiao jeffrey-xiao force-pushed the truncate-remove-splits branch 2 times, most recently from a3b1614 to 4615820 Compare June 17, 2019 18:35
@jeffrey-xiao jeffrey-xiao marked this pull request as ready for review June 17, 2019 18:40
@jeffrey-xiao jeffrey-xiao requested review from a team June 17, 2019 18:40
Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm: Good stuff.

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)

Copy link
Member

@nvanbenschoten nvanbenschoten 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 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jeffrey-xiao)


pkg/cmd/roachtest/clearrange.go, line 55 at r1 (raw file):

		// NB: on a 10 node cluster, this should take well below 3h.
		tBegin := timeutil.Now()
		// Currently we must set `--ranges=0` since automatic merges cannot merge ranges created by

You tested that this roachtest passes with this change, right?


pkg/sql/drop_index.go, line 245 at r1 (raw file):

				if (desc.StickyBit != hlc.Timestamp{}) && span.Key.Compare(desc.StartKey.AsRawKey()) <= 0 {
					if err := p.ExecCfg().DB.AdminUnsplit(ctx, desc.StartKey); err != nil {
						return err

Do we want to swallow "key is not the start of a range" errors? That would mean that the sticky bit was removed and the range was merged concurrently with all of this. It's not likely, but also not something we should fail the DROP INDEX statement for.

Same question below.


pkg/sql/logictest/testdata/logic_test/crdb_internal, line 490 at r1 (raw file):



# Testing split_enforced_until when truncating and dropping.

Nice tests.


pkg/sql/logictest/testdata/logic_test/crdb_internal, line 495 at r1 (raw file):


statement ok
ALTER INDEX foo@idx SPLIT AT VALUES (1), (2), (3)

Let's query crdb_internal.ranges WHERE split_enforced_until IS NOT NULL before each of these drops to show that something is happening.

@jeffrey-xiao jeffrey-xiao force-pushed the truncate-remove-splits branch 3 times, most recently from 4d37bf8 to f30c754 Compare June 19, 2019 18:27
Copy link
Contributor Author

@jeffrey-xiao jeffrey-xiao 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 (and 1 stale) (waiting on @ajwerner and @nvanbenschoten)


pkg/cmd/roachtest/clearrange.go, line 55 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

You tested that this roachtest passes with this change, right?

I've tested that clearrange/checks=false passes with this change.


pkg/sql/drop_index.go, line 245 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Do we want to swallow "key is not the start of a range" errors? That would mean that the sticky bit was removed and the range was merged concurrently with all of this. It's not likely, but also not something we should fail the DROP INDEX statement for.

Same question below.

Makes sense. Done.

Copy link
Member

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @ajwerner and @nvanbenschoten)

@jeffrey-xiao
Copy link
Contributor Author

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 24, 2019

Build failed

@jeffrey-xiao
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 24, 2019

Build failed

@jeffrey-xiao
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 24, 2019

Build failed

If a table/index is dropped/truncated, any manually split ranges in the
table/index should be unsplit so the automatic merge queue can clean up
after it.

Additionally, re-enable splits in clearrange which was previously timing
out because it was waiting for manual splits to be automatically merged,
which is not possible.

Release note: None
@jeffrey-xiao
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request Jun 25, 2019
38221: sql: remove manually split ranges during TRUNCATE and DROP r=jeffrey-xiao a=jeffrey-xiao

If a table/index is dropped/truncated, any manually split ranges in the table/index should be unsplit so the automatic merge queue can clean up after it.

Additionally, re-enable splits in clearrange which was previously timing out because manual splits could not be automatically merged.

Release note: None

Co-authored-by: Jeffrey Xiao <jeffrey.xiao1998@gmail.com>
@craig
Copy link
Contributor

craig bot commented Jun 25, 2019

Build succeeded

@craig craig bot merged commit 7375d59 into cockroachdb:master Jun 25, 2019
@jeffrey-xiao jeffrey-xiao deleted the truncate-remove-splits branch June 25, 2019 16:15
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.

4 participants