Skip to content

Invalidate the read handle after all cursors consumed. - #11389

Merged
codelipenghui merged 4 commits into
apache:masterfrom
codelipenghui:penghui/invalidate_read_handle
Jul 22, 2021
Merged

Invalidate the read handle after all cursors consumed.#11389
codelipenghui merged 4 commits into
apache:masterfrom
codelipenghui:penghui/invalidate_read_handle

Conversation

@codelipenghui

Copy link
Copy Markdown
Contributor

Motivation

Currently, the read ReadHandle only invalidates when removing the ledger from the ManagedLedger.
If the ManagedLedger has many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed data, the ReadHandle can be closed safely. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopened again.

Verifying this change

New tests were added to ensure the ReadHandle had been invalidated property.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Currently, the read ReadHandle only invalidate when removing the ledger from the ManagedLedger.
If the ManagedLedger have many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed the data, the ReadHandle can be closed safety. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopen again.
@codelipenghui codelipenghui self-assigned this Jul 20, 2021
@codelipenghui codelipenghui added the doc-not-needed Your PR changes do not impact docs label Jul 20, 2021
@codelipenghui codelipenghui added this to the 2.9.0 milestone Jul 20, 2021
@codelipenghui codelipenghui added release/2.7.4 release/2.8.1 type/bug The PR fixed a bug or issue reported a bug labels Jul 20, 2021

@315157973 315157973 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request Jul 20, 2021
protected final MetaStore store;

private final ConcurrentLongHashMap<CompletableFuture<ReadHandle>> ledgerCache = new ConcurrentLongHashMap<>(
protected final ConcurrentLongHashMap<CompletableFuture<ReadHandle>> ledgerCache = new ConcurrentLongHashMap<>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can make it "package protected" in order to reduce visibility

@codelipenghui

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@codelipenghui
codelipenghui merged commit 47deafc into apache:master Jul 22, 2021
@codelipenghui
codelipenghui deleted the penghui/invalidate_read_handle branch July 22, 2021 09:27
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Jul 22, 2021
### Motivation

Currently, the read ReadHandle only invalidates when removing the ledger from the ManagedLedger.
If the ManagedLedger has many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed data, the ReadHandle can be closed safely. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopened again.

### Verifying this change

New tests were added to ensure the ReadHandle had been invalidated property.
codelipenghui added a commit that referenced this pull request Jul 23, 2021
### Motivation

Currently, the read ReadHandle only invalidates when removing the ledger from the ManagedLedger.
If the ManagedLedger has many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed data, the ReadHandle can be closed safely. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopened again.

### Verifying this change

New tests were added to ensure the ReadHandle had been invalidated property.

(cherry picked from commit 47deafc)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jul 23, 2021
codelipenghui added a commit that referenced this pull request Jul 23, 2021
Currently, the read ReadHandle only invalidates when removing the ledger from the ManagedLedger.
If the ManagedLedger has many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed data, the ReadHandle can be closed safely. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopened again.

New tests were added to ensure the ReadHandle had been invalidated property.

(cherry picked from commit 47deafc)
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Jul 23, 2021
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
### Motivation

Currently, the read ReadHandle only invalidates when removing the ledger from the ManagedLedger.
If the ManagedLedger has many ledgers(the topic might retain infinite data), we will get oom
on the direct memory since we are using 1MB read cache by default for the offloaded data ReadHandle.

If all the cursors are consumed data, the ReadHandle can be closed safely. And if a cursor reset
to an earlier position to consume the historical data, the ReadHandle will be reopened again.

### Verifying this change

New tests were added to ensure the ReadHandle had been invalidated property.
@codelipenghui
codelipenghui restored the penghui/invalidate_read_handle branch May 17, 2022 01:23
@codelipenghui
codelipenghui deleted the penghui/invalidate_read_handle branch May 17, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.7 Archived: 2.7 is end of life cherry-picked/branch-2.8 Archived: 2.8 is end of life doc-not-needed Your PR changes do not impact docs release/2.7.4 release/2.8.1 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants