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

multitenant: retain range splits after TRUNCATE for secondary tenants #93325

Merged
merged 1 commit into from
Dec 14, 2022
Merged

multitenant: retain range splits after TRUNCATE for secondary tenants #93325

merged 1 commit into from
Dec 14, 2022

Conversation

ecwall
Copy link
Contributor

@ecwall ecwall commented Dec 9, 2022

Fixes #69499
Fixes #82944

Existing split points are preserved after a TRUNCATE statement is executed by a secondary tenant.

Release note: None

@ecwall ecwall requested review from knz, rafiss and arulajmani December 9, 2022 15:48
@ecwall ecwall requested review from a team as code owners December 9, 2022 15:48
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@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 @ecwall, @knz, and @rafiss)


pkg/sql/truncate.go line 409 at r2 (raw file):

	}

	nNodes := execCfg.NodeDescs.GetNodeDescriptorCount()

As you've correctly pointed out, this runs into #93348. Interestingly, what you're replacing here, also wasn't great -- the kv_node_status table doesn't actually account for node liveness. So, if a node was (say) decommissioned, we might still be using it in this calculation as long as its descriptor's TTL in gossip hadn't expired.

We should instead have been using the kv_node_liveness table to begin with. Which brings about a couple of questions -- do we envision making this table available to tenants? If we do, should we build this PR on top of that?

@knz do you have thoughts about this? Or are we happy with this general approach for now?

Copy link
Contributor

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


pkg/sql/truncate.go line 409 at r2 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

As you've correctly pointed out, this runs into #93348. Interestingly, what you're replacing here, also wasn't great -- the kv_node_status table doesn't actually account for node liveness. So, if a node was (say) decommissioned, we might still be using it in this calculation as long as its descriptor's TTL in gossip hadn't expired.

We should instead have been using the kv_node_liveness table to begin with. Which brings about a couple of questions -- do we envision making this table available to tenants? If we do, should we build this PR on top of that?

@knz do you have thoughts about this? Or are we happy with this general approach for now?

The SQL layer has no business inspecting nodes and the number of nodes to do this computation.

There should be a new KV endpoint that does this:

  1. enumerate the split points within the table/index key span
  2. return the list of current split points to the SQL layer
  3. also returns alongside the split points:
    • a recommended number of splits (nSplits)
    • a recommended expiration time (computed off SplitByLoadMergeDelay)

The only remaining code in SQL should be to generate new split points (based on the KV returned details) and issue the AdminSplit/Scatter commands.

Fixes #69499
Fixes #82944

Existing split points are preserved after a TRUNCATE statement is executed
by a secondary tenant.

Release note: None
Copy link
Contributor Author

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


pkg/sql/truncate.go line 409 at r2 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

The SQL layer has no business inspecting nodes and the number of nodes to do this computation.

There should be a new KV endpoint that does this:

  1. enumerate the split points within the table/index key span
  2. return the list of current split points to the SQL layer
  3. also returns alongside the split points:
    • a recommended number of splits (nSplits)
    • a recommended expiration time (computed off SplitByLoadMergeDelay)

The only remaining code in SQL should be to generate new split points (based on the KV returned details) and issue the AdminSplit/Scatter commands.

I created #93549 and linked to it in a TODO.

@ecwall ecwall requested a review from knz December 13, 2022 21:00
Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 5 of 7 files at r1, 3 of 3 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani and @rafiss)

@ecwall
Copy link
Contributor Author

ecwall commented Dec 14, 2022

bors r=knz

@craig craig bot merged commit a30fb14 into cockroachdb:master Dec 14, 2022
@craig
Copy link
Contributor

craig bot commented Dec 14, 2022

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
4 participants