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

kvclient: serve some DeleteRequest's from write buffer #143272

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

stevendanna
Copy link
Collaborator

In order to ensure that a DELETE returns the correct number of deleted rows, it must be integrated with the write buffer so that it observes any previous deletes or writes.

Note that all DELETE statements are not yet handled since we don't yet have DeleteRange support.

Epic: none
Release note: None

@stevendanna stevendanna requested a review from a team as a code owner March 21, 2025 14:01
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@stevendanna stevendanna requested review from mgartner, yuzefovich and michae2 and removed request for mgartner March 21, 2025 14:01
@stevendanna stevendanna force-pushed the ssd/delete-read-from-buffer branch from b784984 to f44a50e Compare March 21, 2025 14:19
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

Another nice find!

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @michae2)


pkg/kv/kvclient/kvcoord/txn_interceptor_write_buffer.go line 429 at r1 (raw file):

			// what the GetResponse that we might have sent says.
			//
			// TODO(review): If we didn't serve the request and we also haven't been

Hm, it's an interesting question. I reviewed the current usage of DeleteRequest in the SQL land, and the only place where we do care about which keys were deleted (meaning we care about FoundKey boolean) is in deleteRangeNode.deleteSpans where we do set MustAcquireExclusiveLock flag.

In principle, I think it'd be cleaner if we added another boolean to DeleteRequest to indicate that we need to know precise value of FoundKey; in practice I think we can just adjust the contract of existing MustAcquireExclusiveLock to mention that if it's not set, then FoundKey in the response might be incorrect and leave a TODO to improve this.


pkg/sql/logictest/testdata/logic_test/buffered_writes line 6 at r1 (raw file):

SET kv_transaction_buffered_writes_enabled=true

statement no-rewrite ok

The way to disable column family mutator is to explicitly specify the column families in the DDL, so let's do that instead and remove new no-rewrite directive.


pkg/sql/logictest/testdata/logic_test/buffered_writes line 37 at r1 (raw file):

DELETE FROM t1 WHERE pk = 1

# The second delete be served from the write buffer

nit: s/be server/should be served/ here and below.

In order to ensure that a DELETE returns the correct number of deleted
rows, it must read from the write buffer so that it observes any
previous deletes or writes.

Note that all DELETE statements are not yet handled since we don't yet
have DeleteRange support.

Epic: none
Release note: None
@stevendanna stevendanna force-pushed the ssd/delete-read-from-buffer branch from f44a50e to d913fee Compare March 24, 2025 10:58
Copy link
Collaborator Author

@stevendanna stevendanna 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 @michae2 and @yuzefovich)


pkg/kv/kvclient/kvcoord/txn_interceptor_write_buffer.go line 429 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Hm, it's an interesting question. I reviewed the current usage of DeleteRequest in the SQL land, and the only place where we do care about which keys were deleted (meaning we care about FoundKey boolean) is in deleteRangeNode.deleteSpans where we do set MustAcquireExclusiveLock flag.

In principle, I think it'd be cleaner if we added another boolean to DeleteRequest to indicate that we need to know precise value of FoundKey; in practice I think we can just adjust the contract of existing MustAcquireExclusiveLock to mention that if it's not set, then FoundKey in the response might be incorrect and leave a TODO to improve this.

Thanks for taking a look. I've added a TODO on MustAcquireExclusiveLock and changed this to a note.


pkg/sql/logictest/testdata/logic_test/buffered_writes line 6 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

The way to disable column family mutator is to explicitly specify the column families in the DDL, so let's do that instead and remove new no-rewrite directive.

Aha, thanks. Done.


pkg/sql/logictest/testdata/logic_test/buffered_writes line 37 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: s/be server/should be served/ here and below.

Thanks. Done.

@stevendanna stevendanna requested a review from arulajmani March 24, 2025 16:13
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani and @michae2)

@stevendanna
Copy link
Collaborator Author

bors r=yuzefovich

@arulajmani Feel free to still review. Happy to handle stuff in a follow-up. Just want to start reducing the delta between master and what we need to test end-to-end.

@craig craig bot merged commit cc4cc90 into cockroachdb:master Mar 24, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants