lhotari opened a new pull request, #25385: URL: https://github.com/apache/pulsar/pull/25385
### Motivation Fix flaky `testSkipRedeliverTemporally` in `PersistentStickyKeyDispatcherMultipleConsumersClassicTest`. The test was flaky because the `asyncReadEntriesOrWait` mock returned the same entries (msg1, msg2 for the slow consumer) indefinitely, creating an infinite normal-read loop. Normal reads couldn't deliver to the slow consumer because `getRestrictedMaxEntriesForConsumer` returns 0 when `readType==Normal` and the `stickyKeyHashes` are in `redeliveryMessages`. Only replay reads can deliver these messages, but the `isDispatcherStuckOnReplays` flag prevented replay reads from being attempted. In a real cursor, `asyncReadEntriesOrWait` advances the read position — entries can only be re-read through `asyncReplayEntries`. The mock didn't simulate this behavior. ### Modifications 1. **Realistic cursor mock** — `asyncReadEntriesOrWait` now tracks which entries it has already returned and doesn't return them again (simulating cursor read position advancement). When no new entries exist, it doesn't call the callback (simulating "OrWait" behavior), which stops the infinite normal-read loop. 2. **Explicit `readMoreEntriesAsync()` call** — After setting the slow consumer's permits, the test triggers a new dispatch cycle. This mimics what `consumerFlow` does in production when a consumer sends more permits. With the loop stopped and `isDispatcherStuckOnReplays` never set, the dispatcher correctly enters the replay read path and delivers messages to the slow consumer. ### Verifying this change This change is already covered by existing tests: - `PersistentStickyKeyDispatcherMultipleConsumersClassicTest.testSkipRedeliverTemporally` — the test itself, verified passing 5/5 consecutive runs - All 7 tests in `PersistentStickyKeyDispatcherMultipleConsumersClassicTest` pass ### Does this pull request potentially affect one of the following parts: - [ ] Dependencies (add or upgrade a dependency) - [ ] The public API - [ ] The schema - [ ] The default values of configurations - [ ] The threading model - [ ] The binary protocol - [ ] The REST endpoints - [ ] The admin CLI options - [ ] The metrics - [ ] Anything that affects deployment ### Documentation - [x] `doc-not-needed` ### Matching PR in forked repository PR in forked repository: <!-- ENTER URL after creating --> -- 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]
