Skip to content

Conversation

@keith-turner
Copy link
Contributor

Added ranges to table locks using the ranges from fate operations. For write locks these ranges are widened to the nearest splits, see comments in Utils.reserveTable for details. See comments and code in DistributedReadWriteLock.WriteLock.tryLock() and
DistributedReadWriteLock.ReadLock.tryLock() for details about how these ranges change lock behavior. Added tests to excercise this new locking behavior. Modified the accumulo admin fate -l command to display lock ranges. Also modified how this command determines if a lock is held or waiting.

fixes #2483

Added ranges to table locks using the ranges from fate operations.  For
write locks these ranges are widened to the nearest splits, see comments
in Utils.reserveTable for details.  See comments and code in
DistributedReadWriteLock.WriteLock.tryLock() and
DistributedReadWriteLock.ReadLock.tryLock() for details about how these
ranges change lock behavior.  Added tests to excercise this new locking
behavior. Modified the `accumulo admin fate -l` command to display lock
ranges.  Also modified how this command determines if a lock is held or
waiting.

fixes apache#2483
@keith-turner keith-turner added this to the 4.0.0 milestone Aug 8, 2025
@keith-turner
Copy link
Contributor Author

This change is important for the new automatic merge feature. Even though merges are fast now, if a merge gets stuck waiting on a long running compaction then it will block all subsequent compactions and bulk imports from running. Adding ranges prevents blocking for the case where the ranges do not overlap.

This PR can also close #1324 #3823

Copy link
Member

@kevinrr888 kevinrr888 left a comment

Choose a reason for hiding this comment

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

I haven't looked through everything, posting comments I have. Overall, this looks like a very nice improvement to table locking.

Copy link
Member

@kevinrr888 kevinrr888 left a comment

Choose a reason for hiding this comment

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

Looks good. I didn't follow all of the bulk import changes, but looks like you added more bulk import testing for these changes as well. May be good to run full set of ITs before this is merged

Comment on lines +156 to +177
/*
* Write locks are widened to table split points to avoid non-overlapping ranges operating on
* the same tablet. For example assume a table has splits at c,e and two fate operations need
* write locks on ranges (a1,c2] and (d1,d9]. The fate ranges do not overlap, however both
* will operate on the tablet (c,e]. When the ranges are widened, (a1,c2] turns into (null,e]
* and (d1,d9] turns into (c,e]. The widened ranges for the fate operations overlap which
* prevents both from operating on the same tablet.
*
* Widening is done for write locks because those need to work on mutually exclusive sets of
* tablets w/ other write or read locks. Read locks do not need to be mutually exclusive w/
* each other and it does not matter if they operate on the same tablet so widening is not
* needed for that case. Widening write locks is sufficient for detecting overlap w/ any
* tablets that read locks need to use. For example if a write locks is obtained on (a1,c2]
* and it widens to (null,e] then a read lock on (d1,d9] would overlap with the widened range.
*
* Mostly widening for write locks is nice because fate operations that get read locks are
* probably more frequent. So the work of widening is not done on most fate operations. Also
* widening an infinite range is a quick operation, so create/delete table will not be slowed
* down by widening.
*
* Widening is done for compactions because those operations widen their range.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Very good explanation. I wonder if there's a better/more visible spot for this. This spot seems fine though

@keith-turner
Copy link
Contributor Author

I was running bulk random walk test against this branch and found #5833. The test is a good test for this change because it does lots of concurrent table operations with different ranges.

…Ops/Utils.java

Co-authored-by: Kevin Rathbun <kevinrr888@gmail.com>
@keith-turner
Copy link
Contributor Author

I didn't follow all of the bulk import changes

The cause of the bulk changes was the code was computing the range after it got the lock. Needed to reorg the code to compute the range prior to getting the lock.

@keith-turner keith-turner merged commit 7cf47dc into apache:main Aug 28, 2025
8 checks passed
@keith-turner keith-turner deleted the table-range-lock branch August 28, 2025 15:12
keith-turner added a commit to keith-turner/accumulo that referenced this pull request Aug 28, 2025
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.

Implement Table Range locks for FaTE transactions

3 participants