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] Fix eviction trigger race that cleared the in-progress marker by merlimat · Pull Request #25988 · apache/pulsar

Conversation

@merlimat

@merlimat merlimat commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Motivation

RangeEntryCacheManagerImpl.triggerEvictionWhenNeeded() uses updateAndGet with a lambda that returns null when another eviction is already in progress. Since updateAndGet stores the lambda's result, a thread losing the race overwrites the running eviction's in-progress marker with null. On its next loop iteration that thread installs its own future and submits a duplicate eviction task, while the first cycle's cleanup then clears the second cycle's marker.

With the cache sitting at the eviction trigger threshold and many managed-ledger threads inserting concurrently, this happens routinely: redundant tasks are queued on the single eviction executor (each re-checks the size, so the wasted work is bounded, but timer-driven eviction passes get delayed behind the no-op tasks), and the marker no longer reliably reflects whether an eviction is running.

Modifications

Use compareAndSet(null, newEvictionFuture) so only the winning thread installs the in-progress marker; losing threads loop and pick up the owner's future via get(). The owner remains the only one clearing the marker in triggerEvictionToMakeSpace's finally block.

Sorry, something went wrong.

Uh oh!

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

All reactions
@merlimat
[fix][ml] Fix eviction trigger race that cleared the in-progress marker
891e76a
triggerEvictionWhenNeeded used updateAndGet with a lambda returning null
when another eviction was already in progress, which overwrote the running
eviction's marker with null. The looping thread would then install its own
future and submit a duplicate eviction task, while the first cycle's
cleanup cleared the second's marker. Use compareAndSet so only the winning
thread installs the marker and losers re-read the current owner's future.
@merlimat
merlimat requested a review from lhotari June 9, 2026 23:17
void-ptr974
void-ptr974 approved these changes Jun 10, 2026
View reviewed changes
dao-jun
dao-jun approved these changes Jun 10, 2026
View reviewed changes
lhotari
lhotari approved these changes Jun 10, 2026
View reviewed changes

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Sorry, something went wrong.

Uh oh!

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

All reactions
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 10, 2026
@lhotari lhotari added release/4.2.3 release/4.0.12 release/4.1.4 and removed release/4.0.12 labels Jun 10, 2026
@lhotari
lhotari merged commit fbcfacf into apache:master Jun 10, 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 Jun 10, 2026
@merlimat @lhotari
[fix][ml] Fix eviction trigger race that cleared the in-progress mark…
75fbe6b
…er (#25988)

(cherry picked from commit fbcfacf)
@lhotari lhotari added the cherry-picked/branch-4.2 label Jun 10, 2026
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
@merlimat @dao-jun
[fix][ml] Fix eviction trigger race that cleared the in-progress mark…
6ea72a9
…er (apache#25988)

(cherry picked from commit fbcfacf)
@dao-jun dao-jun mentioned this pull request Oct 4, 2026
[feat][ml] Port batch read and managed-ledger cache improvements (PIP-430) on BK 4.17.4.1 ascentstream/pulsar#105
Closed
@nodece nodece mentioned this pull request Oct 13, 2026
[feat][ml] Port batch read and managed-ledger cache improvements (PIP-430) on BK 4.17.4.1 (ml-only subset) ascentstream/pulsar#106
Closed
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Oct 13, 2026
@merlimat @nodece
[fix][ml] Fix eviction trigger race that cleared the in-progress mark…
c1f5a77
…er (apache#25988)

(cherry picked from commit fbcfacf)
(cherry picked from commit 6ea72a9)
@merlimat
merlimat deleted the mmerli/fix-eviction-trigger-race branch October 24, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lhotari lhotari lhotari approved these changes
@dao-jun dao-jun dao-jun approved these changes
+1 more reviewer
@void-ptr974 void-ptr974 void-ptr974 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

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

Assignees

No one assigned

Labels

cherry-picked/branch-4.2 release/4.1.4 release/4.2.3

Projects

None yet

Milestone

5.0.0-M1

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@merlimat @lhotari @dao-jun @void-ptr974
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.