You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "Leondon9 (via GitHub)" <gi...@apache.org> on 2026/09/25 02:58:26 UTC
[PR] [test] Wait for KV flush before tagged lookup assertions [fluss]
Leondon9 opened a new pull request, #4485:
URL: https://github.com/apache/fluss/pull/4485
## Summary
- Fixes the flaky `ReplicaManagerTest.testTaggedLookupAndPrefixResultsUseRpcSlices`, which intermittently fails with an NPE at `lookupValue.offset()`.
- Closes #4177
**Problem.** The test writes with `acks=1` and then immediately looks the key up. `ReplicaManager#lookups` resolves to `KvTablet#multiGet`, which reads RocksDB only and never the kv pre-write buffer — as the javadoc on the sibling `multiGetFromBufferOrKv` states, *"External lookups must keep using `multiGet` so that clients only observe flushed data."* The value therefore becomes visible only once the asynchronous flush publishes it. When the flush loses the race, `lookupValues().get(0)` is `null` and the next line throws.
This matches the CI signature: elapsed time is a constant ~2.1s across every reported failure, so it is an immediate NPE rather than a timeout.
**Evidence.** I instrumented the write path and sampled the flush state at exactly the point the assertions run, right after the put callback:
```
SUMMARY flushBehindAtLookup=20/20 lookupNull=1/20
i=00 hw=0 flushed=0 logEnd=8 flushBehind=true lookup=present
...
i=16 hw=0 flushed=0 logEnd=8 flushBehind=true lookup=NULL
```
- The flushed log offset trailed the local log end offset in **20 of 20** iterations — the window is always open.
- The lookup observed `null` in **1 of 20** (~5%), reproducing the failure condition.
- The high watermark had **not advanced** in any sample (`hw=0`).
**Why not `acks=-1`.** That is the shape used by 3a000ba6a (`[test] Wait for KV flush before limit scan`) for the sibling limit-scan test. The `hw=0` measurement above shows it would only narrow this window rather than close it: a watermark advance merely *enqueues* the flush (`Replica#mayFlushKv` → `KvTablet#requestFlush` → `kvFlushScheduler.enqueue`), which still completes asynchronously.
**Fix.** Wait with the existing `KvTabletTestUtils#flushAndWait` helper, which blocks until `getFlushedLogOffset()` reaches the target, closing the window deterministically. It is already imported in this file and used in 56 places, including the same `flushAndWait(replica.getKvTablet(), Long.MAX_VALUE)` idiom in `TabletServerShutdownITCase`. `acks=1` is deliberately kept so the test still covers the same write path.
## Test Plan
Module: `fluss-server`. JDK 11.
- `ReplicaManagerTest#testTaggedLookupAndPrefixResultsUseRpcSlices` — **30/30 passes** with `-Dfluss.forkCount=1`.
- `ReplicaManagerTest` (41 tests) + `ReplicaTest` (16 tests) — pass under the CI default fork settings (`forkCount=2`, `reuseForks=true`).
- `spotless:check` and `checkstyle:check` — clean (0 violations).
Verified on `b530fcc2b`, which includes the KV tablet locking refactor (#3994).
Note: the failure does not reproduce through the test itself on a fast local machine — 25/25 baseline runs passed — which is why the race is demonstrated by the instrumented measurement above rather than by a bare repeat-until-failure loop.
🤖 AI-assisted changes - reviewed by human developer
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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
Re: [PR] [test] Wait for KV flush before tagged lookup assertions [fluss]
Posted by "platinumhamburg (via GitHub)" <gi...@apache.org>.
platinumhamburg merged PR #4485:
URL: https://github.com/apache/fluss/pull/4485
--
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
Re: [PR] [test] Wait for KV flush before tagged lookup assertions [fluss]
Posted by "Leondon9 (via GitHub)" <gi...@apache.org>.
Leondon9 commented on PR #4485:
URL: https://github.com/apache/fluss/pull/4485#issuecomment-6108562671
@platinumhamburg @wuchong PTAL 🙏
This completes `3a000ba6a` ([test] Wait for KV flush before limit scan) — the same acks-vs-async-flush race, in the tagged lookup test that commit did not cover.
It waits with `KvTabletTestUtils#flushAndWait` rather than raising acks to -1: as the measurement in the description shows, the high watermark had not advanced either at that point (`hw=0` in 20 of 20 samples), and a watermark advance only *enqueues* the asynchronous flush, so `acks=-1` would narrow the window rather than close it.
The bot reported four failures of this test on #4177 between Sept 15 and Sept 25.
--
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