FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[fix][ml] Fix cached read handle leaks when closing read-only managed ledgers by void-ptr974 · Pull Request #26816 · apache/pulsar · GitHub

Repository navigation

[fix][ml] Fix cached read handle leaks when closing read-only managed ledgers - #26816

Open
void-ptr974 wants to merge 2 commits into
apache:masterfrom
void-ptr974:fix/readonly-ledger-handle-cleanup
Open

void-ptr974 wants to merge 2 commits into
apache:masterfrom
void-ptr974:fix/readonly-ledger-handle-cleanup

Conversation

void-ptr974 commented Oct 2, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Main Issue: #26815

Motivation

A read-only managed ledger has no current write handle. Its close path therefore skips the write-handle callback that normally releases cached read handles, leaving their metadata listeners registered. A read submitted after close can also open another handle and repopulate the cache.

Modifications

  • Invalidate cached handles on normal and fenced close, including opens whose futures have not completed yet.
  • Mark the read-only ledger as closing before draining the cache. Reject subsequent opens and recheck after cache insertion so a concurrent close cannot leave a late insertion behind.
  • Reuse existing asynchronous invalidation cleanup. One close failure does not skip other cached handles, and repeated close does not close the same cached handle again.

Writable managed-ledger behavior is unchanged. Temporary initialization-handle cleanup is covered independently by #26817. This change initiates cached-handle cleanup; it does not make the managed-ledger close callback wait for every pending BookKeeper open/close.

Verifying this change

  • Make sure that the change passes the CI checks.

Local validation passed as described below. Full CI validation is still pending.

ReadOnlyManagedLedgerHandleCloseTest covers six cases: normal/fenced cleanup, a pending open completing after close, rejection of reads after normal/fenced close, and cleanup of multiple cached handles when one close fails. It also verifies an empty cache, exactly-once cleanup on repeated close, and no new BookKeeper open after close. Assertions run before fixture cleanup.

With the tests unchanged and only the production changes removed (base 1046481c970067cbca9c80a25a98257b9179a3da), all six cases fail: handles are not closed, the pending-open cache entry remains, or reads still succeed after close.

With the fix restored, all six cases and ten existing read-only tests pass (16 total), along with quickCheck:

./gradlew :managed-ledger:test \
  --tests '*ReadOnlyManagedLedgerHandleCloseTest' --tests '*ReadOnlyCursorTest' \
  --tests '*ReadOnlyManagedLedgerImplTest' \
  -PtestRetryCount=0 -PtestFailFast=false -PtestMaxParallelForks=1 --max-workers=2 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

Release the read-only handle cache on close, including fenced closes and handles whose opens are pending, without changing writable managed-ledger shutdown.

Main Issue: apache#26815

Assisted-by: OpenAI Codex
void-ptr974 changed the title [fix][ml] Close cached handles when a read-only managed ledger closes [fix][ml] Fix cached read handle leaks when closing read-only managed ledgers Oct 2, 2026
Guard cache insertion against concurrent close and cover reads after normal or fenced close, repeated close, and independent cleanup failures.

Assisted-by: OpenAI Codex
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL