GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — [fix][ml] Fix ManagedCursor missing active-cursor registration during concurrent state changes by void-ptr974 · Pull Request #27107 · apache/pulsar Conversation
|
| Step | Thread A | Thread B | isActive |
Registered in activeCursors |
|---|---|---|---|---|
| 1 | Calls setActive(), registers the cursor, releases the container monitor, then pauses before writing the flag. |
false |
Yes | |
| 2 | Paused. | Calls setActive() and still sees false. The ledger finds the existing registration, so it skips adding it again. B writes isActive = true and returns. |
true |
Yes |
| 3 | Paused. | Calls setInactive(), removes the registration, writes isActive = false, and returns. |
false |
No |
| 4 | Resumes, writes isActive = true, and returns. |
true |
No |
Both threads have finished, but the cursor reports active while its registration is absent. The registration was successfully added and subsequently removed; the delayed flag write from A leaves the mismatch. Later setActive() calls see isActive = true and skip ledger.activateCursor(), so repeated activation requests do not repair it. The missing registration excludes the cursor from active-reader cache tracking and can increase BookKeeper reads. The reproduced failure concerns active-cursor membership; it does not establish message loss.
Production reachability depends on the callers. Consumer addition and removal hold the same subscription monitor, so those operations alone do not establish this race. With cacheEvictionByExpectedReadCount=false, the backlog-check timer provides an independent activation without that monitor: it can register a caught-up Shared subscription and pause before flag publication, while a new consumer's addition activates it again and subsequent removal of the last consumer deactivates it. The timer can then publish the stale true flag. The current default is true, which skips this backlog-check path. This is source-level reachability; the deterministic tests force the scheduling, and no naturally occurring broker-level reproduction, production incident, or occurrence rate has been established.
There is also a separate permanent-inactive race. Starting with an active cursor:
setAlwaysInactive(). Its call to setInactive() removes the registration and writes isActive = false; A pauses before setting alwaysInactive = true.setActive(), sees both flags still false, re-registers the cursor, writes isActive = true, and returns.alwaysInactive = true and returns, leaving a permanently inactive cursor active and registered.Local validation passed with retries disabled:
9cbb6d9b89 and pass with the fix.toString(); two existing cursor activity tests also pass (12 invocations total).quickCheck, managed-ledger Checkstyle, and microbench compilation/Checkstyle pass../gradlew :managed-ledger:test \ --tests '*ManagedCursorLifecycleStateTest' \ --tests '*ManagedCursorLifecycleProgressTest' \ --tests '*ManagedCursorTest.testAlwaysInactive' \ --tests '*ManagedCursorTest.testNonDurableCursorActive' \ -PtestRetryCount=0 -PtestMaxParallelForks=1 quickCheck ./gradlew :microbench:compileJava :microbench:checkstyleMain
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Serialize cursor activity changes with the ledger's existing active-cursor monitor. Preserve volatile fast paths for repeated requests and cover permanent deactivation. Add deterministic regressions, bounded progress tests and a lifecycle JMH benchmark. Assisted-by: OpenAI Codex
Guard each cursor's activity transitions with its own lock while keeping container synchronization inside ManagedLedgerImpl. This removes the dependency on the monitor returned by getActiveCursors and avoids extending the shared container lock to cursor-local flag publication. Add progress coverage for two cursors sharing a ledger in both cache eviction modes. Assisted-by: OpenAI Codex
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Reviewed cc265d0. No actionable findings identified within the reviewed scope.
Both pre-fix lifecycle races were reproduced. All 14 focused test cases passed with the fix, including both cache eviction modes, and microbenchmark compilation passed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
… concurrent state changes (apache#27107) (cherry picked from commit b02b041)
… concurrent state changes (apache#27107) (cherry picked from commit b02b041)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.