-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve] [ml] Persist mark deleted ops to ZK if create cursor ledger was failed #20935
[improve] [ml] Persist mark deleted ops to ZK if create cursor ledger was failed #20935
Conversation
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Show resolved
Hide resolved
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.
The change looks good to me.
Only add some minor comments to consolidate the test.
} | ||
}, null); | ||
} | ||
|
||
void persistPositionMetaStore(MarkDeleteEntry mdEntry, final VoidCallback callback) { |
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.
void persistPositionMetaStore(MarkDeleteEntry mdEntry, final VoidCallback callback) { | |
void persistPositionToMetaStore(MarkDeleteEntry mdEntry, final VoidCallback callback) { |
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.
@poorbarcode Please check here.
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.
Done
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Show resolved
Hide resolved
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Show resolved
Hide resolved
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Show resolved
Hide resolved
}; | ||
|
||
if (State.NoLedger.equals(STATE_UPDATER.get(this))) { | ||
persistPositionMetaStore(mdEntry, cb); |
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.
If the BookKeeper cluster runs into read-only mode and millions of consumers keep acknowledging the mark-delete position to brokers, we will persist the mark-delete position to the meta store without any throttle policy, will it bring high pressure or risk for the meta store? especially when we use Zookeeper as the Pulsar cluster's meta store service.
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.
If the BookKeeper cluster runs into read-only mode and millions of consumers keep acknowledging the mark-delete position to brokers, we will persist the mark-delete position to the meta store without any throttle policy, will it bring high pressure or risk for the meta store? especially when we use Zookeeper as the Pulsar cluster's meta store service.
Some users may want to set BK to read-only, and stop sending messages but consume messages.
However, pulsar does not support this yet, because even if only the message is consumed, there is still some BK write operations, here are some examples:
- If a transaction is used when consuming a message, a transaction log is also written
- Compaction tasks are still written to BK
- Topic policies depend on BK write
- PIP-192: New Pulsar Broker Load Balancer #16691
- PIP-195: New bucket based delayed message tracker #16763
- PIP178:Multiple snapshots for transaction buffer #16042
- ... and so on
If we want to support the above scenario "Make BK read-only and only consume messages", we should need a large design.
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.
we will persist the mark-delete position to the meta store without any throttle policy
@hangc0276 @poorbarcode Actually, we have a throttling policy that can be configured by managedLedgerDefaultMarkDeleteRateLimit
. For improving this case, it looks like we'd better have a separate one for the zookeeper. So that users can persist to the cursor ledger for each second but persist to zookeeper for every 30 seconds.
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.
@hangc0276 @poorbarcode Actually, we have a throttling policy that can be configured by managedLedgerDefaultMarkDeleteRateLimit. For improving this case, it looks like we'd better have a separate one for the zookeeper. So that users can persist to the cursor ledger for each second but persist to zookeeper for every 30 seconds.
Good idea. Since this solution should change broker.conf
and PersistencePolicies
, maybe a PIP is needed.
In the current PR, I've simpler this behavior to the following: persist to ZK only hits these two scenarios
- the cursor ledger is not null, persist to ZK after persisting to BK failed(the original behavior before this PR)
- the cursor ledger is null, and the
cursor.markDeletedPosition==managedLedger.LAC
. Since the ledger can not be created, no entry can be written now, so the variablemanagedLedger.LAC
will not increase anymore. For per subscription, persist to ZK will only be executed once.
And in the future, we submit a PIP to add a rater limiter to further improve the behavior.
@codelipenghui @hangc0276 What do you think abort?
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.
Yes, it looks good to me. And users can also change managedLedgerDefaultMarkDeleteRateLimit
to reduce the impact.
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.
Don' we need to consider shouldPersistUnackRangesToLedger()
here, as well? If individualDeletedMessages is too big, bigger than maxUnackedRangesToPersistInMetadataStore, shouldn't we persist it to BK, instead of MetadataStore?
/pulsarbot run-failure-checks |
8460bb0
to
7c7e879
Compare
/pulsarbot run-failure-checks |
}; | ||
|
||
if (State.NoLedger.equals(STATE_UPDATER.get(this))) { | ||
if (mdEntry.newPosition.equals(ledger.getLastConfirmedEntry())) { |
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.
Please update the compare logic as we discussed to cover the case that LAC's entryId is -1
and add a test to cover it
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.
Done
c6b4554
to
ebb705a
Compare
/pulsarbot run-failure-checks |
4dd88ef
to
9461ef0
Compare
Rebase master |
Codecov Report
@@ Coverage Diff @@
## master #20935 +/- ##
============================================
+ Coverage 73.03% 73.14% +0.11%
- Complexity 32363 32392 +29
============================================
Files 1887 1887
Lines 139860 139879 +19
Branches 15384 15389 +5
============================================
+ Hits 102140 102316 +176
+ Misses 29634 29477 -157
Partials 8086 8086
Flags with carried forward coverage won't be shown. Click here to find out more.
|
… was failed (#20935) The progress Persist mark deleted position is like this: - persist to BK - If failed to persist to BK, try to persist to ZK But in the current implementation: if the cursor ledger was created failed, Pulsar will not try to persist to ZK. It makes if the cursor ledger created fails, a lot of ack records can not be persisted, and we will get a lot of repeat consumption after the BK recover. Modifications: Try to persist the mark deleted position to ZK if the cursor ledger was created failed (cherry picked from commit 843b830)
… was failed (#20935) The progress Persist mark deleted position is like this: - persist to BK - If failed to persist to BK, try to persist to ZK But in the current implementation: if the cursor ledger was created failed, Pulsar will not try to persist to ZK. It makes if the cursor ledger created fails, a lot of ack records can not be persisted, and we will get a lot of repeat consumption after the BK recover. Modifications: Try to persist the mark deleted position to ZK if the cursor ledger was created failed
Motivation
The progress Persist mark deleted position is like this:
But in the current implementation: if the cursor ledger was created failed, Pulsar will not try to persist to ZK. It makes if the cursor ledger created fails, a lot of ack records can not be persisted, and we will get a lot of repeat consumption after the BK recover.
Modifications
Try to persist the mark deleted position to ZK if the cursor ledger was created failed
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: x