Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35466: kv: stop DistSender from double-covering RangeFeeds during splits r=nvanbenschoten a=danhhz If a RangeFeed was running over `[/a,/d)` and it split at `/b`, then we'd get an error from the server and the span would be kicked out to `divideAndSendRangeFeedToRanges`. The `RangeIterator` would usually hand out the post-split `[/a,/b)` descriptor for `/a`, then advance to `/b` and first try the pre-split `[/a,/d)` descriptor. Each would get a new RangeFeed. The one over `[/a,/d)` would immediately come back with an error from the server that it didn't fit in the bounds of a range, evict the `RangeDescriptorCache` token, and get kicked out again to `divideAndSendRangeFeedToRanges`. This time, because of the eviction, the `RangeIterator` would get the post-split `[/b,/d)` descriptor. The end result was one RangeFeed over `[/a,/b)` and two over `[/b,/d)`. A second split at `/c` meant we could double it again and end up with 4 over `[/c,/d)`. RangeFeed always has the potential for sending duplicates, so changefeeds have to be resilient to this, and this was not a correctness issue, but it's obviously bad. The fix is simple: use the same 'nextRS' trick that `divideAndSendBatchToRanges` does to keep track of the uncovered part of the input `rs` span to `divideAndSendRangeFeedToRanges` and use that to trim the descriptors that come back. Found when splits were added to TestChangefeedNemeses and manually investiating why RangeFeed was returning duplicates. No test yet since one is coming in cockroachdb#32721. Release note: None Co-authored-by: Daniel Harrison <[email protected]>
- Loading branch information