Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIP 81: Split the individual acknowledgments into multiple entries #10729

Closed
wants to merge 22 commits into from

Conversation

315157973
Copy link
Contributor

@315157973 315157973 commented May 27, 2021

Motivation

Pulsar persists the individual acknowledgments into Ledger for each subscription.
acknowledgment hole uses guava range to record.
Now a single entry is used to record these holes, but a single entry can not stores more than 5MB data.
Therefore, this PIP stores these holes in different entries separately. And use LRU to ensure low memory usage.
In this way, we can support almost unlimited acknowledgment hole.

Doc: https://docs.google.com/document/d/1uQtyb8t6X04v2vrSrdGWLFkuCkBcGYZbqK8XsVJ4qkU/edit

Modifications

recover:

  1. Added API recoverFromMultiEntry
  2. The old logic is abstract as recoverFromSingleEntry

persist position to ledger:

  1. Add API persistPositionToMultiEntry and saveMarker
  2. The old logic is abstract as persistPositionToSingleEntry

when creating new ledger:

  1. Add API copyLruEntriesToNewLedger
  2. The old logic remains the same

LRU:

  1. Add class RangeSetWrapper. Responsible for loading and eliminating of LRU data .
  2. The loading of LRU data is synchronous, and elimination of LRU data is asynchronous, with RangeSetWrapper#LruTask

Verifying this change

persist position to ledger has 3 chain:

internalAsyncMarkDelete + NoLedger -> startCreatingNewMetadataLedger -> createNewMetadataLedgerAndSwitch -> doCreateNewMetadataLedger -> persistPositionToLedger -> switchToNewLedger -> flushPendingMarkDeletes -> internalMarkDelete -> persistPositionToLedger -> remove individualDeletedMessages
internalAsyncMarkDelete + Ledger is Open -> internalMarkDelete -> persistPositionToLedger -> remove individualDeletedMessages
persistPositionWhenClosing -> persistPositionToLedger -> close ledger

create new ledger has 1 chain:

initialize -> createNewMetadataLedgerAndSwitch -> doCreateNewMetadataLedger -> switchToNewLedger -> flushPendingMarkDeletes -> internalMarkDelete -> persistPositionToLedger -> remove individualDeletedMessages

recover has 1 chain:

initializeCursors -> recover -> recoverFromLedger -> recoverFromMultiEntry

@315157973 315157973 closed this May 27, 2021
@315157973 315157973 reopened this May 27, 2021
@Anonymitaet
Copy link
Member

@315157973 thanks for your contribution. For this PR, do we need to update docs?

@315157973 315157973 closed this Jul 19, 2021
@315157973 315157973 deleted the ack branch July 19, 2021 11:11
@315157973 315157973 restored the ack branch July 21, 2021 00:45
@315157973 315157973 reopened this Jul 21, 2021
# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java
@315157973 315157973 added the doc-not-needed Your PR changes do not impact docs label Jul 22, 2021
@hangc0276 hangc0276 self-requested a review October 4, 2021 14:00
@eolivelli eolivelli modified the milestones: 2.9.0, 2.10.0 Oct 6, 2021
@codelipenghui codelipenghui modified the milestones: 2.10.0, 2.11.0 Jan 21, 2022
@codelipenghui
Copy link
Contributor

The pr had no activity for 30 days, mark with Stale label.

codelipenghui pushed a commit that referenced this pull request May 6, 2022
…or reuse (#15425)

### Motivation
It is difficult to get CR due to so many modifications in PIP 81 #10729.
So I split this PR into multiple sub-PRs to facilitate CR

### Modifications
I split the logic in createNewMetadataLedger into multiple methods to facilitate subsequent reuse
1. Put the logic of creating Ledger into `doCreateNewMetadataLedger` separately
2. `switchToNewLedger` does not need to wrap another layer of callback, so remove redundant wrapping
3. When persisting data fails, we need to delete the created Ledger, this part of the logic is put into `deleteLedger`

### Verifying this change
This modification does not change any previous behavior, so no unit tests are required, but the previous unit tests must be ensured to pass
@codelipenghui codelipenghui modified the milestones: 2.11.0, 2.12.0 Jul 26, 2022
@tisonkun
Copy link
Member

tisonkun commented Dec 9, 2022

Closed as stale and conflict. Please rebase and resubmit the patch if it's still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs lifecycle/stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants