zhang-arvin opened a new pull request, #9500:
URL: https://github.com/apache/paimon/pull/9500

   ## What changes were proposed in this pull request?
   
   Fix #9483: Concurrent `LocalTableQuery` lookups across files can return null 
because the `SliceComparator` in `RowCompactedSerializer` uses shared mutable 
`reader1`/`reader2` fields across all threads. When two threads concurrently 
call `compare()`, the `pointTo()` calls interleave, producing incorrect 
comparison results and causing binary search to return false negatives (null).
   
   ### Root Cause
   
   `LocalTableQuery` creates a single `LookupStoreFactory` with a 
`RowCompactedSerializer.createSliceComparator()` that is shared across all 
`LookupLevels` instances (all partitions and buckets). The `SliceComparator` 
has mutable `reader1` and `reader2` fields that are repositioned via 
`pointTo()` on each `compare()` call, creating a race condition.
   
   ### Fix
   
   Convert `reader1` and `reader2` in `SliceComparator` to 
`ThreadLocal<RowReader>` instances, giving each thread its own independent 
reader pair.
   
   ## How was this patch tested?
   
   - `paimon-common` module compiles successfully
   - `LookupLevelsTest` 19 tests pass
   - `PrimaryKeySimpleTableTest` 133 tests pass


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to