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][ml] Preserve cursor position updates during activation by Denovo1998 · Pull Request #27205 · apache/pulsar

Conversation

@Denovo1998

@Denovo1998 Denovo1998 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Motivation

ManagedLedgerImpl.activateCursor() snapshots a cursor's position before registering it in activeCursors. A concurrent seek() or read completion can publish a new read position and finish its notification before registration, so the notification is dropped and activation installs the stale snapshot. This leaves cache-reader tracking incorrect until the next position update, producing wrong expected reader counts or slowest-reader positions.

This is a separate position-tracking race identified while reviewing apache/pulsar#27107.

Modifications

  • Serialize position notifications from cursors whose active flag is still false with the existing active-cursor container monitor, coordinating them with activation's position snapshot and insertion.
  • Re-read the published position after waiting instead of replaying the captured notification argument. Reconcile again if an active update overtakes that snapshot before it reaches the container. Activation and reconciliation use the same read/mark-delete position selection.
  • Keep notifications from active cursors on the existing container-lock path without acquiring the lifecycle monitor.
  • Add deterministic forward/backward seek, delayed read-position notification, overlapping active-seek regressions and active-cursor progress checks to ManagedLedgerBkTest for both cacheEvictionByExpectedReadCount values, using real ZooKeeper and BookKeeper services. The test subclass only pauses after reading the actual cursor position; it does not substitute a position or mock the failure.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • All four forced-interleaving cases fail on the unpatched production implementation: the legacy mode reports stale slowest-reader positions, and expected-read-count mode returns 1 instead of 2 or 2 instead of 1.
  • The four delayed-notification cases also fail on the initial PR implementation: an older read-position notification overwrites a newer activation snapshot. Four additional cases exercise an active seek overtaking reconciliation after its position sample.
  • With the final fix, all 103 focused tests pass locally with retries disabled, including the twelve forced-interleaving regressions, two active-cursor progress checks, existing lifecycle tests and container regressions. There are no failures, errors or skipped tests.
  • quickCheck passes locally.
./gradlew :managed-ledger:test \
  --tests '*ManagedLedgerBkTest.testActivationPreservesConcurrentSeek' \
  --tests '*ManagedLedgerBkTest.testActiveSeekDoesNotWaitForLifecycleMonitor' \
  --tests '*ManagedLedgerBkTest.testActivationIgnoresDelayedReadPositionUpdate' \
  --tests '*ManagedLedgerBkTest.testDelayedReadPositionUpdateReconcilesConcurrentSeek' \
  --tests '*ManagedCursorLifecycleStateTest' \
  --tests '*ManagedCursorLifecycleProgressTest' \
  --tests '*ActiveManagedCursorContainerTest' \
  --tests '*ActiveManagedCursorContainerRetentionTest' \
  --tests '*ActiveManagedCursorContainerUntrackingTest' \
  --tests '*ManagedCursorTest.testAlwaysInactive' \
  --tests '*ManagedCursorTest.testNonDurableCursorActive' \
  -PtestRetryCount=0 -PtestMaxParallelForks=1 --max-workers=1

./gradlew quickCheck --max-workers=1

The local regressions cover readPosition/seek() with mark-delete-based cache eviction disabled. They establish cache-tracking inconsistency, not message loss. No broker-level naturally occurring race reproduction or throughput benchmark was run; the local results above do not report a CI result.

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 — inactive-cursor position notifications now use the existing activation monitor; active-cursor notifications retain their existing container-lock path.
  • 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
Denovo1998 added 2 commits October 28, 2026 19:39
@Denovo1998
[fix][ml] Preserve cursor position updates during activation
bb5a068
@Denovo1998
[fix][ml] Preserve cursor position updates during activation
4a7e019
@merlimat merlimat mentioned this pull request Oct 30, 2026
[fix][ml] Close abandoned managed ledger initialization resources #27212
Merged
1 of 11 tasks
codelipenghui
codelipenghui approved these changes Oct 30, 2026
View reviewed changes

@codelipenghui codelipenghui left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head 4a7e019b3d8c534557798ec9ceaa8d5ea3bd980c.

No actionable findings identified within the reviewed scope. All 105 focused test cases passed with retries disabled.

Limitations: the unpatched baseline was not independently executed; forced mark-delete activation races and sustained-load contention remain unverified.

Sorry, something went wrong.

Uh oh!

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

All reactions
merlimat
merlimat approved these changes Oct 30, 2026
View reviewed changes
@merlimat
merlimat merged commit 4f0654b into apache:master Oct 30, 2026
44 checks passed

Uh oh!

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

lhotari pushed a commit that referenced this pull request Nov 2, 2026
@Denovo1998 @lhotari
[fix][ml] Preserve cursor position updates during activation (#27205)
1dc4012
(cherry picked from commit 4f0654b)
@lhotari lhotari added release/5.0.2 cherry-picked/branch-5.0 labels Nov 2, 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 release/4.2.6 labels Nov 21, 2026
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Nov 26, 2026
@Denovo1998 @lhotari
[fix][ml] Preserve cursor position updates during activation (apache#…
1203cbf
…27205)

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

Reviewers

@merlimat merlimat merlimat approved these changes
@codelipenghui codelipenghui codelipenghui approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

cherry-picked/branch-4.2 cherry-picked/branch-5.0 release/4.2.6 release/5.0.2

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@Denovo1998 @merlimat @codelipenghui @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.