Kaixuan-Duan opened a new pull request, #3305:
URL: https://github.com/apache/fluss/pull/3305

   
   
   ### Purpose
   
   Linked issue: close #3218 
   
   ### Brief change log
   
   The test `BatchScannerITCase.testKvSnapshotLease` is flaky because it 
hardcodes expected snapshot IDs (`{0L, 0L, 0L}`, `{1L, 1L, 1L}`) assuming 
snapshot IDs always start from 0 and increment in lockstep across all buckets.
   
   However, `FlussClusterExtension.triggerSnapshot()` has a race condition: it 
calls `kvSnapshotManager.triggerSnapshot()` which submits the task 
asynchronously to guardedExecutor, then immediately checks 
`currentSnapshotId()`. If the async task hasn't executed yet, the method 
returns null and skips waiting for that bucket's snapshot. The background 
snapshot still completes eventually, potentially causing snapshot IDs to 
diverge from the hardcoded expectations.
   
   The fix replaces all hardcoded snapshot IDs with dynamically computed values 
based on the actual snapshot IDs returned by `admin.getLatestKvSnapshots()`. A 
helper method `buildExpectedBucketSnapshots()` is introduced to construct the 
expected Long[] array from the actual consumeBuckets map.
   
   ### Tests
   
   Since the flakiness is caused by a race condition in snapshot ID assignment, 
it cannot be reliably reproduced in a single run. 
   
   The key verification is that the test no longer relies on hardcoded snapshot 
IDs — it dynamically reads actual snapshot IDs from the cluster and uses them 
to construct assertions, making it resilient to any snapshot ID offset caused 
by async timing.
   
   ./mvnw -pl fluss-client -Dtest='BatchScannerITCase.testKvSnapshotLease' 
-DfailIfNoTests=false test
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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