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] Preserve lock state and refresh reads during reacquisition by codelipenghui · Pull Request #27384 · apache/pulsar

Conversation

@codelipenghui

@codelipenghui codelipenghui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

Reacquiring an existing lock owned by the same metadata session can return successfully while the new local handle remains in Init, so subsequent updates fail and ownership-loss handling can stall. A delayed revalidation must also not revive a releasing or released handle.

Separately, an authoritative acquisition conflict can leave a cached self-owner value readable after the failed future is observed.

Modifications

  • Promote a successful same-session reacquisition to Valid only after checking the local lifecycle state under the existing lock.
  • Reject late revalidation results for releasing/released handles.
  • Invalidate the exact lock-read cache entry before exposing a typed acquisition conflict, including the existing BadVersion mapping.
  • Preserve unknown failures and unrelated cached paths.

No ownership-cache caller or topic-admission changes are included.

Verifying this change

Tests-only execution on unpatched Apache master a72adf733ead20ba4b19a76222b698f315073ecf reproduced 7 failures, including Lock was not in valid state: Init, stale self-owner reads after conflicts, and late revalidation results.

With the fix, 62 cases passed, with no failures/errors/skips and retries disabled:

  • ResourceLockImplTest
  • LockManagerReadCacheTest
  • LockManagerTest
  • CoordinationServiceImplTest

Tests retain native in-memory metadata values and versions, while controlling notifications and asynchronous reads. quickCheck and git diff --check passed.

./gradlew :pulsar-metadata:test \
  --tests ResourceLockImplTest \
  --tests LockManagerReadCacheTest \
  --tests LockManagerTest \
  --tests CoordinationServiceImplTest \
  -PtestRetryCount=0 -PtestMaxParallelForks=1 -PtestJavaVersion=21
./gradlew quickCheck

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

Threading: recheck local state after the asynchronous native read and invalidate the cache before completing the failure future; existing executors and lock ordering are retained.

Sorry, something went wrong.

Uh oh!

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

All reactions
@codelipenghui
[fix][meta] Preserve lock state and refresh reads during reacquisition
4b8c782
Validate local lock lifecycle before adopting a same-session value and mark a fresh handle Valid. Invalidate only the conflicted path before exposing a typed acquisition failure, preserving unknown errors and unrelated cache entries.

Seven baseline behavior failures reproduce on unpatched master; all62 related cases and quickCheck pass with retries disabled.

Assisted-by: OpenAI Codex
@codelipenghui codelipenghui self-assigned this Nov 6, 2026
@codelipenghui codelipenghui added type/bug The PR fixed a bug or issue reported a bug release/4.2.6 release/4.0.15 release/5.0.2 labels Nov 6, 2026
@codelipenghui
codelipenghui marked this pull request as ready for review November 6, 2026 17:56
@codelipenghui codelipenghui added this to the 5.1.0 milestone Nov 6, 2026
@codelipenghui
codelipenghui requested review from Denovo1998, lhotari, merlimat and poorbarcode November 9, 2026 17:14
poorbarcode
poorbarcode approved these changes Nov 16, 2026
View reviewed changes
Comment thread ...ar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/ResourceLockImpl.java Resolved

Uh oh!

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

codelipenghui and others added 2 commits November 16, 2026 12:03
@codelipenghui @claude
Merge remote-tracking branch 'apache/master' into penghui/fix-lock-re…
3871b38
…acquire-state-20261105

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codelipenghui @claude
[fix][meta] Align lock release tests with the sequenced release
74a9fc7
release() now deletes the lock only after the update or revalidation in
flight completes (apache#27530), so a release can no longer finish while a
revalidation read is pending. Drop that case from the delayed-read test,
and cover releasing while revalidation re-acquires a stale lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codelipenghui
codelipenghui merged commit 49df762 into apache:master Nov 17, 2026
43 checks passed

Uh oh!

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

lhotari pushed a commit that referenced this pull request Nov 17, 2026
@codelipenghui @claude @lhotari
[fix][meta] Preserve lock state and refresh reads during reacquisition (
f9f8cb2
#27384)

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 49df762)
@lhotari lhotari added the cherry-picked/branch-5.0 label Nov 17, 2026
This was referenced Nov 21, 2026
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27680
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27681
Closed
[improve][ci] Run CI for the 4.2.6 backports to branch-4.2 (do not merge) #27684
Closed
@lhotari lhotari added cherry-picked/branch-4.2 cherry-picked/branch-4.0 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@codelipenghui @claude @lhotari
[fix][meta] Preserve lock state and refresh reads during reacquisition (
f1cb922
apache#27384)

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 49df762)
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@codelipenghui @claude @lhotari
[fix][meta] Preserve lock state and refresh reads during reacquisition (
d284508
apache#27384)

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 49df762)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@poorbarcode poorbarcode poorbarcode approved these changes
@Denovo1998 Denovo1998 Awaiting requested review from Denovo1998
@merlimat merlimat Awaiting requested review from merlimat
@lhotari lhotari Awaiting requested review from lhotari

Uh oh!

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

Assignees

@codelipenghui codelipenghui

Labels

cherry-picked/branch-4.0 cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.0.15 release/4.2.6 release/5.0.2 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Milestone

5.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

3 participants

@codelipenghui @poorbarcode @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.