Skip to content

Conversation

@DomGarguilo
Copy link
Member

Fixes #5788

The main change here is to use the version of Utils.reserveTable() that allows us to pass a range to only lock that portion.

@DomGarguilo DomGarguilo added this to the 4.0.0 milestone Oct 3, 2025
@DomGarguilo DomGarguilo self-assigned this Oct 3, 2025
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.

LGTM

@DomGarguilo DomGarguilo marked this pull request as draft October 9, 2025 17:45
@DomGarguilo
Copy link
Member Author

I have converted this to draft for now. I think #5952 should be merged first as it might have some impact here.

@DomGarguilo DomGarguilo force-pushed the narrowTableLockRange branch from 060b618 to 8d9ec18 Compare January 2, 2026 18:08
@DomGarguilo DomGarguilo marked this pull request as ready for review January 2, 2026 18:09
@DomGarguilo
Copy link
Member Author

Marking this as ready for review. I refactored things and took a slightly different approach.

The main changes are now:

  • a new method to compute the LockRange using the tRange field within LockTable
    • this method takes a safe approach to converting the tRange (a key-range) to a RowRange. We return the LockRange that at least covers whats denoted by tRange but might end up locking a bit more than absolutely needed. This is still an improvement to whats currently happening in the code with an infinite range being locked.

@DomGarguilo
Copy link
Member Author

#5949 mentioned that we should look into using a read lock here instead of a write lock. I looked into it and here is what I came up with:

If I'm understanding things correctly, a read lock will allow concurrent setTabletAvailability() calls. I think this means if two ops run at the same time, there is no guarantee which order they will run in so if they act on overlapping tablets, the outcome will just be whichever op had its conditional mutations run last for each tablet (and the overlap could end up mixed between the two ops). So TLDR: we should keep a write lock if we need these calls to run serially, otherwise a read lock should be fine.

Copy link
Contributor

@ddanielr ddanielr left a comment

Choose a reason for hiding this comment

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

Logic seems straight forward to me.

The need to convert the tRange to a range, and then to a rowRange seemed excessive but I saw the removal of the zeroRowSuffix being done in toRowRange.

minor suggestion to skip the object creation if the range is already infinite.

}

private static KeyExtent findContaining(Ample ample, TableId tableId, Text row) {
public static KeyExtent findContaining(Ample ample, TableId tableId, Text row) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public static KeyExtent findContaining(Ample ample, TableId tableId, Text row) {
/**
* Find all tablets that are contained within the provided table row
*/
public static KeyExtent findContaining(Ample ample, TableId tableId, Text row) {

Since this is now public and used outside of Utils it should probably get a javadoc entry

* be converted to a RowRange, an infinite LockRange is returned.
*/
private LockRange getLockRange(FateEnv env) {
Range range = new Range(tRange);
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid the range conversions if the tRange is already infinite.

Suggested change
Range range = new Range(tRange);
if (tRange.infiniteStartKey && tRange.infiniteStopKey) {
return LockRange.infinite();
}
Range range = new Range(tRange);

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.

Narrow table lock range for set tablet availability fate operation

3 participants