You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "yangshangqing95 (via GitHub)" <gi...@apache.org> on 2026/10/19 19:35:42 UTC
[I] [test] Stabilize RemoteLogDownloader prefetch permit assertions [fluss]
yangshangqing95 opened a new issue, #4738:
URL: https://github.com/apache/fluss/issues/4738
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/fluss/issues) and found nothing similar.
### Fluss version
1.0.0 (latest release)
### Please describe the bug 🐞
`RemoteLogDownloaderTest.testPrefetchNum` remains flaky in CI, occasionally failing with:
```
expected: 2
but was: 1
```
This issue was previously reported in #3460. The same failure was observed continuously.
https://github.com/apache/fluss/actions/runs/39093405548/job/117574725446?pr=4696
The root cause is a race between the test thread and the background download thread.
In `RemoteLogDownloader.fetchOnce()`, the downloader acquires a prefetch permit before polling the request queue. Even when the queue is empty, the background thread may temporarily hold a permit until the poll times out.
Consequently, immediately checking `availablePermits() == 2` after recycling two segments is not deterministic. The background thread may have already acquired one of the released permits, causing the assertion to observe `1`.
### Solution
Stabilize `testPrefetchNum` without changing the production download scheduling logic.
The existing first `acquire()` then `poll()` ordering is intentional. It ensures that a download request remains in the priority queue until prefetch capacity is available, preserving the intended segment ordering.
Swapping these operations would introduce additional risks: **a request could be removed from the priority queue while waiting for a permit, potentially bypassing newly arrived higher-priority requests.** Interruptions during that wait would also require additional handling to avoid losing the dequeued request.
Temporarily holding a permit while polling an empty queue is expected under the current implementation. The permit is released when the poll returns without a request. The observed CI failure therefore results from the test asserting a transient concurrent state rather than demonstrating a permit leak.
I propose driving `fetchOnce()` explicitly within `testPrefetchNum` to make prefetch scheduling deterministic. This allows the test to verify the exact permit count, prefetch limit, queued requests, and permit recycling without interference from the background fetch loop.
The background downloader thread can then be started separately to verify asynchronous file cleanup.
This keeps the production behavior unchanged while preserving strict assertions and making the test deterministic.
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
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: issues-unsubscribe@fluss.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [test] Stabilize RemoteLogDownloader prefetch permit assertions [fluss]
Posted by "polyzos (via GitHub)" <gi...@apache.org>.
polyzos closed issue #4738: [test] Stabilize RemoteLogDownloader prefetch permit assertions
URL: https://github.com/apache/fluss/issues/4738
--
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: issues-unsubscribe@fluss.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org