Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a data race in SeekPrefixGE. The merging iterator's findNextEntry method has an optimization for prefix iteration: When the merging iterator observes a range deletion and seeks lower-level iterators to the deletion's end boundary, the merging iterator checks whether the current iteration prefix is exhausted. Previously, if the entire iterator was exhausted, this optimization would accidentally read the heap root key `m.heap.items[0].key` for a heap that is empty. The iterator that surfaced `m.heap.items[0].key` would have already been exhausted, and the key could point into memory already released (eg, a sstable iterator already returned to a pool). This data race is not likely to have caused any inconsistencies in production, because under the conditions the race was possible the iterator was already exhausted and would be recognized as exhausted regardless of the result of the comparison. This commit fixes this data race by waiting until the beginning of the next iteration of the findNextEntry loop (if there is another iteration) to compare the heap root's prefix against the the search prefix. Fix #1698.
- Loading branch information