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

concurrency: misc cleanup related to multiple transactions holding locks on a single key #109177

Merged
merged 4 commits into from
Aug 22, 2023

Conversation

arulajmani
Copy link
Collaborator

@arulajmani arulajmani commented Aug 21, 2023

Cleanup following-on from #109049. See individual commits for details.

@arulajmani arulajmani requested review from a team as code owners August 21, 2023 20:23
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@arulajmani arulajmani force-pushed the sl-multiple-locks-follow-up branch from e080535 to a8bee16 Compare August 21, 2023 22:38
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 2 files at r1, 8 of 8 files at r2, 1 of 1 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @arulajmani)


-- commits line 43 at r4:
Did you mean to include this in the commit message?


pkg/kv/kvserver/concurrency/concurrency_control.go line 90 at r2 (raw file):

//	|         | [ lockTable ]                                     |  |  |
//	|         | [    key1   ]    -------------+-----------------+ |  ^  |
//	|         | [    key2   ]  /  keyLocks:  | lockWaitQueue:   |----<---<---<----+

Looks like the spacing on these diagrams got messed up.


pkg/kv/kvserver/concurrency/lock_table.go line 1931 at r1 (raw file):

// part of the specified transaction.
// REQUIRES: l.mu is locked.
func (l *lockState) releaseWritersFromTxn(txn *enginepb.TxnMeta) {

I'm not sure about these changes to pass enginepb.TxnMeta by value in more places. The type is still quite large (~120 bytes) and will only grow larger over time, so I think we'll still want to prefer passing it by reference through functions, even if we store it by value in the data-structure.

My suggestion would be to revert the change to all of the function/method signatures but keep the change to the txnLock struct.


pkg/kv/kvserver/concurrency/lock_table.go line 264 at r4 (raw file):

	// lockAddMaxLocksCheckInterval, locks will be cleared.
	//
	// [1] Simply put, the number of keyLocks objects in the request's lock table

Why specifically reference "the request's lock table snapshot" instead of just "the lockTable btree"?


pkg/kv/kvserver/concurrency/lock_table.go line 3668 at r4 (raw file):

}

// checkMaxNumKeysLockedAndTryClear checks if the request is tracking more lock

Should we remove "Num" to mirror the field name directly?

Previously, we would store a reference to the txn meta in the txnLock
struct. This isn't required, as this field must now always be set. This
patch switches over to storing the txnMeta struct directly. Doing so
means we don't hold on to the entire `roachpb.LockAcquisition` or
`roachpb.LockUpdate` struct in a few places.

Epic: none

Release note: None
@arulajmani arulajmani force-pushed the sl-multiple-locks-follow-up branch from a8bee16 to 8be1ea0 Compare August 22, 2023 14:26
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.

TFTR, RFAL!

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


pkg/kv/kvserver/concurrency/concurrency_control.go line 90 at r2 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Looks like the spacing on these diagrams got messed up.

Fixed.


pkg/kv/kvserver/concurrency/lock_table.go line 1931 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

I'm not sure about these changes to pass enginepb.TxnMeta by value in more places. The type is still quite large (~120 bytes) and will only grow larger over time, so I think we'll still want to prefer passing it by reference through functions, even if we store it by value in the data-structure.

My suggestion would be to revert the change to all of the function/method signatures but keep the change to the txnLock struct.

That makes sense; took your suggestion and reverted all changes to function/method signatures.


pkg/kv/kvserver/concurrency/lock_table.go line 264 at r4 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Why specifically reference "the request's lock table snapshot" instead of just "the lockTable btree"?

My bad, I thought I was working with a lockTableGuardImpl instead of a lockTableImpl; fixed.


pkg/kv/kvserver/concurrency/lock_table.go line 3668 at r4 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Should we remove "Num" to mirror the field name directly?

Fixed.

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: mod the formatting issue in the concurrency_control.go diagram.

Reviewed 9 of 9 files at r5, 8 of 8 files at r6, 1 of 1 files at r7, 3 of 3 files at r8, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/kv/kvserver/concurrency/concurrency_control.go line 90 at r2 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Fixed.

Looks like there's also the same issue in the diagram below:
// lockTable holds a collection of locks

The new name is more apt for the current structure.

Epic: none

Release note: None
More descriptive name. While here, also burn down a TODO.

Epic: none

Release note: None
Ditto for minKeys. These new names better reflect what these limits
were being used for.

Epic: none

Release note: None
@arulajmani arulajmani force-pushed the sl-multiple-locks-follow-up branch from 8be1ea0 to 8b66dac Compare August 22, 2023 15:37
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.

Fixed the formatting.

bors r=nvanbenschoten

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

@craig
Copy link
Contributor

craig bot commented Aug 22, 2023

Build succeeded:

@craig craig bot merged commit 33d6552 into cockroachdb:master Aug 22, 2023
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