[fix][meta] Track explicitly acquired underreplicated ledger locks - #26670
Open
void-ptr974 wants to merge 1 commit into
Open
void-ptr974 wants to merge 1 commit into
void-ptr974 wants to merge 1 commit into
Conversation
Register explicit locks after successful acquisition so release and close can remove them while a shared metadata store remains open. Distinguish these locks from polled tasks with an optional underreplication record version, preventing explicit acquisition from authorizing task deletion. Cover release, shared-store close, record preservation, failed contenders, and preservation of a polled version after a failed duplicate acquisition. Assisted-by: Codex
nodece
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
PulsarLedgerUnderreplicationManager.acquireUnderreplicatedLedger()creates an ephemeral lock but does not register it inheldLocks. BothreleaseUnderreplicatedLedger()andclose()rely on that map, so an explicitly acquired lock remains after the caller releases or closes the manager. Other managers continue to treat the ledger as locked, particularly when the metadata store is shared and its session remains open.Explicit acquisition is also used for mutual exclusion without claiming a pending underreplication task. Tracking these locks must not allow
markLedgerReplicated()to delete a task that the caller did not obtain through the replication queue.Modifications
Optional<Long>, following the native BookKeeper distinction between an explicit lock and a lock acquired with a task version.finallyblock.Verifying this change
Before the fix, the new tests produced 8 failures across Memory and real ZooKeeper because explicitly acquired locks remained after release/close/mark. The 4 failed-acquisition protection cases passed on the original implementation.
Post-fix validation, with automatic retries disabled and no failed or skipped tests:
LedgerUnderreplicationManagerTestpassed, including all five providers and real Oxia. This includes 30 new regression cases and 87 existing cases, including multiple managers acquiring and releasing locks.quickCheckandsanityCheckpassed, covering repository-wide license/style checks and main/test source compilation.Full underreplication manager suite on Linux with Docker:
TEST_METADATA_PROVIDERS=Memory,ZooKeeper,MockZooKeeper,RocksDB,Oxia ./gradlew :pulsar-metadata:test \ --tests 'org.apache.pulsar.metadata.bookkeeper.LedgerUnderreplicationManagerTest' \ -PtestRetryCount=0 -PtestFailFast=false --max-workers=4 --console=plainDoes this pull request potentially affect one of the following parts: