GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][meta] Track explicitly acquired underreplicated ledger locks by void-ptr974 · Pull Request #26670 · apache/pulsar

Conversation

@void-ptr974

@void-ptr974 void-ptr974 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

PulsarLedgerUnderreplicationManager.acquireUnderreplicatedLedger() creates an ephemeral lock but does not register it in heldLocks. Both releaseUnderreplicatedLedger() and close() 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

  • Register explicitly acquired locks only after acquisition succeeds.
  • Represent the underreplication record version as Optional<Long>, following the native BookKeeper distinction between an explicit lock and a lock acquired with a task version.
  • Keep the actual version for poll/get acquisition. Only delete an underreplication record when that version is present; explicit locks are still released in the existing finally block.
  • Add six regression tests covering explicit release, close with a shared live store, marking with/without an existing record, failed contenders, and a failed duplicate acquisition preserving a previously polled record version.

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:

  • macOS / JDK 25: 40 cases passed across Memory, real ZooKeeper, MockZooKeeper and RocksDB. This includes the six new tests and existing locking, release, task completion and record updates while a task is locked.
  • Linux x86_64 / JDK 21 / Docker: all 117 cases in LedgerUnderreplicationManagerTest passed, including all five providers and real Oxia. This includes 30 new regression cases and 87 existing cases, including multiple managers acquiring and releasing locks.
  • quickCheck and sanityCheck passed, 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=plain

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@void-ptr974
[fix][meta] Track explicitly acquired underreplicated ledger locks
e63e411
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
nodece approved these changes Sep 21, 2026
View reviewed changes
@merlimat
merlimat merged commit 2857cc3 into apache:master Sep 22, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@lhotari lhotari added this to the 5.0.0 milestone Sep 22, 2026
@lhotari lhotari added release/4.2.5 release/4.0.14 labels Sep 22, 2026
lhotari pushed a commit that referenced this pull request Sep 23, 2026
@void-ptr974 @lhotari
[fix][meta] Track explicitly acquired underreplicated ledger locks (#…
2a2c98e
…26670)

(cherry picked from commit 2857cc3)
@lhotari lhotari added the cherry-picked/branch-4.2 label Sep 23, 2026
lhotari pushed a commit that referenced this pull request Sep 23, 2026
@void-ptr974 @lhotari
[fix][meta] Track explicitly acquired underreplicated ledger locks (#…
985b705
…26670)

(cherry picked from commit 2857cc3)
@lhotari lhotari added the cherry-picked/branch-4.0 label Sep 23, 2026
@Denovo1998 Denovo1998 mentioned this pull request Sep 28, 2026
[fix][meta] Fix underreplication locks left behind when closing by handling each deletion independently #26674
Merged
1 of 11 tasks
Radiancebobo pushed a commit to Radiancebobo/pulsar that referenced this pull request Oct 8, 2026
@void-ptr974 hechengbo
[fix][meta] Track explicitly acquired underreplicated ledger locks (a…
69a59b0
…pache#26670)
@nodece nodece mentioned this pull request Nov 5, 2026
[fix][ml][broker][client] Sync branch-as-4.0 with apache branch-4.0 (2026-09 to 2026-11, 159 commits) ascentstream/pulsar#109
Merged
4 of 5 tasks
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Nov 16, 2026
@void-ptr974 @nodece
[fix][meta] Track explicitly acquired underreplicated ledger locks (a…
a683678
…pache#26670)

(cherry picked from commit 2857cc3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@nodece nodece nodece approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 release/4.0.14 release/4.2.5

Projects

None yet

Milestone

5.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@void-ptr974 @nodece @merlimat @lhotari
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.