Skip to content

CASSANDRA-21183 Safely regain ranges that were previously owned by a node#268

Open
alanwang67 wants to merge 23 commits intoapache:trunkfrom
alanwang67:CASSANDRA-21183
Open

CASSANDRA-21183 Safely regain ranges that were previously owned by a node#268
alanwang67 wants to merge 23 commits intoapache:trunkfrom
alanwang67:CASSANDRA-21183

Conversation

@alanwang67
Copy link

Currently nodes that are regaining ranges can result in subtle edge cases when we still have command stores left over from previous epochs that overlap with the range we are regaining.

To address this we:

  1. Allow the regaining of ranges only if the epoch in which we previously owned the range is already retired
  2. Mark as unsafe to read the ranges that we are regaining for the command store that previously owned the range and prevent future setSafeToRead invocations to revert this change.
  3. Throw an error when we query two command stores for the same range

return additions;
}

public List<Long> epochsWeAreRegainingRangesFor(Topology curr, Topology next)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this and block... aren't used, so could remove them (and the associated notify)?

* But they may still be ordered for other key ranges they participate in.
*/
private NavigableMap<Timestamp, Ranges> safeToRead = emptySafeToRead();
private Ranges retiredRanges = Ranges.EMPTY;
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably don't need this; we can simply query redundantBefore, as this won't happen on any fast paths

Copy link
Author

Choose a reason for hiding this comment

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

Maybe I should come up with a better name, but this variable is for keeping track of the ranges that we marked as unsafe to read in the CommandStore because we are regaining the range for it, so it is a subset of the actual retiredRanges. I use this value to ensure that whenever we set ranges as safeToRead we exclude these ranges as it is no longer safe to read from them if there exists a CommandStore with a greater epoch that has the same range. If we query redundantBefore, I'm not sure if we will be able to get this value.

@alanwang67 alanwang67 marked this pull request as ready for review March 4, 2026 18:52
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.

2 participants