You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "coderzc (via GitHub)" <gi...@apache.org> on 2023/04/13 04:22:54 UTC
[GitHub] [pulsar] coderzc opened a new pull request, #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable
coderzc opened a new pull request, #20086:
URL: https://github.com/apache/pulsar/pull/20086
### Motivation
If the future of load segment timeout but, In fact load index is successful then we need to ensure the previous delayed index is removed from snapshotSegmentLastIndexTable, otherwise, tracker will load the next segment even though we don't need it yet.
### Modifications
Ensure previous delayed index be removed from snapshotSegmentLastIndexTable
### Verifying this change
- [x] Make sure that the change passes the CI checks.
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (10MB)*
- *Extended integration test for recovery after broker failure*
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] coderzc commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1167708939
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -527,17 +528,22 @@ protected long nextDeliveryTime() {
}
@Override
- public synchronized long getNumberOfDelayedMessages() {
+ public long getNumberOfDelayedMessages() {
return numberDelayedMessages;
}
@Override
- public synchronized long getBufferMemoryUsage() {
+ public long getBufferMemoryUsage() {
return this.lastMutableBucket.getBufferMemoryUsage() + sharedBucketPriorityQueue.bytesCapacity();
}
@Override
public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessages) {
+ if (!checkPendingOpDone()) {
Review Comment:
Yes, the delivery of the message will be delayed. I think we can optimize this part in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] coderzc closed pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc closed pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
URL: https://github.com/apache/pulsar/pull/20086
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1166912389
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -567,26 +574,19 @@ public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessa
log.debug("[{}] Loading next bucket snapshot segment, bucketKey: {}, nextSegmentEntryId: {}",
dispatcher.getName(), bucket.bucketKey(), preSegmentEntryId + 1);
}
- // All message of current snapshot segment are scheduled, load next snapshot segment
- // TODO make it asynchronous and not blocking this process
- try {
- boolean createFutureDone = bucket.getSnapshotCreateFuture().orElse(NULL_LONG_PROMISE).isDone();
-
- if (!createFutureDone) {
- log.info("[{}] Skip load to wait for bucket snapshot create finish, bucketKey:{}",
- dispatcher.getName(), bucket.bucketKey());
- break;
- }
-
- if (bucket.currentSegmentEntryId == bucket.lastSegmentEntryId) {
- immutableBuckets.asMapOfRanges().remove(Range.closed(bucket.startLedgerId, bucket.endLedgerId));
- bucket.asyncDeleteBucketSnapshot(stats);
- continue;
- }
+ boolean createFutureDone = bucket.getSnapshotCreateFuture().orElse(NULL_LONG_PROMISE).isDone();
+ if (!createFutureDone) {
+ log.info("[{}] Skip load to wait for bucket snapshot create finish, bucketKey:{}",
+ dispatcher.getName(), bucket.bucketKey());
+ break;
+ }
- long loadStartTime = System.currentTimeMillis();
- stats.recordTriggerEvent(BucketDelayedMessageIndexStats.Type.load);
- bucket.asyncLoadNextBucketSnapshotEntry().thenAccept(indexList -> {
+ long loadStartTime = System.currentTimeMillis();
+ stats.recordTriggerEvent(BucketDelayedMessageIndexStats.Type.load);
+ CompletableFuture<Void> loadFuture = pendingLoad = bucket.asyncLoadNextBucketSnapshotEntry()
Review Comment:
can this line split into multi line ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1167590083
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -527,17 +528,22 @@ protected long nextDeliveryTime() {
}
@Override
- public synchronized long getNumberOfDelayedMessages() {
+ public long getNumberOfDelayedMessages() {
return numberDelayedMessages;
}
@Override
- public synchronized long getBufferMemoryUsage() {
+ public long getBufferMemoryUsage() {
return this.lastMutableBucket.getBufferMemoryUsage() + sharedBucketPriorityQueue.bytesCapacity();
}
@Override
public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessages) {
+ if (!checkPendingOpDone()) {
+ log.info("[{}] Skip getScheduledMessages to wait for bucket snapshot load finish.", dispatcher.getName());
Review Comment:
I think this method is on the hot path. we need change this log level to debug to avoid print logs frequently.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] coderzc commented on pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#issuecomment-1519841339
> This has been cherry-picked to branch-3.0 despite the code freeze. Do you feel strongly that this needs to be in the 3.0 release ? Otherwise we should revert this and delay it 3.0.1/3.1.
This is a severe issue for PIP-195 so it needs into 3.0, thanks~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1167717510
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -527,17 +528,22 @@ protected long nextDeliveryTime() {
}
@Override
- public synchronized long getNumberOfDelayedMessages() {
+ public long getNumberOfDelayedMessages() {
return numberDelayedMessages;
}
@Override
- public synchronized long getBufferMemoryUsage() {
+ public long getBufferMemoryUsage() {
return this.lastMutableBucket.getBufferMemoryUsage() + sharedBucketPriorityQueue.bytesCapacity();
}
@Override
public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessages) {
+ if (!checkPendingOpDone()) {
Review Comment:
agree. hope to see PIP-195 in 3.0.0 : - )
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] coderzc merged pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc merged PR #20086:
URL: https://github.com/apache/pulsar/pull/20086
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] cbornet commented on pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "cbornet (via GitHub)" <gi...@apache.org>.
cbornet commented on PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#issuecomment-1519794136
This has been cherry-picked to branch-3.0 despite the code freeze.
Do you feel strongly that this needs to be in the 3.0 release ? Otherwise we should revert this and delay it 3.0.1/3.1.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1166912389
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -567,26 +574,19 @@ public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessa
log.debug("[{}] Loading next bucket snapshot segment, bucketKey: {}, nextSegmentEntryId: {}",
dispatcher.getName(), bucket.bucketKey(), preSegmentEntryId + 1);
}
- // All message of current snapshot segment are scheduled, load next snapshot segment
- // TODO make it asynchronous and not blocking this process
- try {
- boolean createFutureDone = bucket.getSnapshotCreateFuture().orElse(NULL_LONG_PROMISE).isDone();
-
- if (!createFutureDone) {
- log.info("[{}] Skip load to wait for bucket snapshot create finish, bucketKey:{}",
- dispatcher.getName(), bucket.bucketKey());
- break;
- }
-
- if (bucket.currentSegmentEntryId == bucket.lastSegmentEntryId) {
- immutableBuckets.asMapOfRanges().remove(Range.closed(bucket.startLedgerId, bucket.endLedgerId));
- bucket.asyncDeleteBucketSnapshot(stats);
- continue;
- }
+ boolean createFutureDone = bucket.getSnapshotCreateFuture().orElse(NULL_LONG_PROMISE).isDone();
+ if (!createFutureDone) {
+ log.info("[{}] Skip load to wait for bucket snapshot create finish, bucketKey:{}",
+ dispatcher.getName(), bucket.bucketKey());
+ break;
+ }
- long loadStartTime = System.currentTimeMillis();
- stats.recordTriggerEvent(BucketDelayedMessageIndexStats.Type.load);
- bucket.asyncLoadNextBucketSnapshotEntry().thenAccept(indexList -> {
+ long loadStartTime = System.currentTimeMillis();
+ stats.recordTriggerEvent(BucketDelayedMessageIndexStats.Type.load);
+ CompletableFuture<Void> loadFuture = pendingLoad = bucket.asyncLoadNextBucketSnapshotEntry()
Review Comment:
can this line split into multi line ? var a = b = c seems not usual : - )
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1167579969
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -527,17 +528,22 @@ protected long nextDeliveryTime() {
}
@Override
- public synchronized long getNumberOfDelayedMessages() {
+ public long getNumberOfDelayedMessages() {
return numberDelayedMessages;
Review Comment:
I think we need an `volatile` on field `numberDelayedMessage` if we access without lock.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codecov-commenter commented on pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#issuecomment-1508339284
## [Codecov](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#20086](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (51f2770) into [master](https://codecov.io/gh/apache/pulsar/commit/a332fead21390b3fbbb86c2d17a161717a170161?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a332fea) will **increase** coverage by `37.35%`.
> The diff coverage is `90.47%`.
[](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
```diff
@@ Coverage Diff @@
## master #20086 +/- ##
=============================================
+ Coverage 35.58% 72.94% +37.35%
- Complexity 12423 31904 +19481
=============================================
Files 1691 1868 +177
Lines 128771 138302 +9531
Branches 14044 15215 +1171
=============================================
+ Hits 45822 100880 +55058
+ Misses 76931 29396 -47535
- Partials 6018 8026 +2008
```
| Flag | Coverage Δ | |
|---|---|---|
| inttests | `24.14% <2.38%> (?)` | |
| systests | `24.91% <2.38%> (+0.01%)` | :arrow_up: |
| unittests | `72.24% <90.47%> (+39.09%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...r/delayed/bucket/BucketDelayedDeliveryTracker.java](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9kZWxheWVkL2J1Y2tldC9CdWNrZXREZWxheWVkRGVsaXZlcnlUcmFja2VyLmphdmE=) | `84.59% <89.74%> (+84.59%)` | :arrow_up: |
| [.../pulsar/broker/rest/RestMessagePublishContext.java](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9yZXN0L1Jlc3RNZXNzYWdlUHVibGlzaENvbnRleHQuamF2YQ==) | `92.59% <100.00%> (+92.59%)` | :arrow_up: |
| [...sistent/PersistentDispatcherMultipleConsumers.java](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvUGVyc2lzdGVudERpc3BhdGNoZXJNdWx0aXBsZUNvbnN1bWVycy5qYXZh) | `76.79% <100.00%> (+24.39%)` | :arrow_up: |
| [...a/org/apache/pulsar/admin/cli/PulsarAdminTool.java](https://codecov.io/gh/apache/pulsar/pull/20086?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC10b29scy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2FkbWluL2NsaS9QdWxzYXJBZG1pblRvb2wuamF2YQ==) | `86.77% <100.00%> (+86.77%)` | :arrow_up: |
... and [1438 files with indirect coverage changes](https://codecov.io/gh/apache/pulsar/pull/20086/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20086: [fix][broker] Ensure previous delayed index be removed from snapshotSegmentLastIndexTable & Make load operate asynchronous
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20086:
URL: https://github.com/apache/pulsar/pull/20086#discussion_r1167590266
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/BucketDelayedDeliveryTracker.java:
##########
@@ -527,17 +528,22 @@ protected long nextDeliveryTime() {
}
@Override
- public synchronized long getNumberOfDelayedMessages() {
+ public long getNumberOfDelayedMessages() {
return numberDelayedMessages;
}
@Override
- public synchronized long getBufferMemoryUsage() {
+ public long getBufferMemoryUsage() {
return this.lastMutableBucket.getBufferMemoryUsage() + sharedBucketPriorityQueue.bytesCapacity();
}
@Override
public synchronized NavigableSet<PositionImpl> getScheduledMessages(int maxMessages) {
+ if (!checkPendingOpDone()) {
Review Comment:
does the loading task only triggered we there is not any scheduled message left ? it seems dispatcher have to wait for the loading task finished before any scheduled message on time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org