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/02/23 18:59:41 UTC

[GitHub] [pulsar] coderzc opened a new pull request, #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

coderzc opened a new pull request, #19615:
URL: https://github.com/apache/pulsar/pull/19615

   PIP: #16763
   
   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/wiki/proposals/PIP.md -->
   
   ### Motivation
   
   The `getRemainSnapshotSegment` should load data from nextSegmentEntryId to lastSegmentEntryId otherwise, the tracker will record replicated index.
   
   ### Modifications
   
   * Fix merge issues
   * Improve test
   * Start bucketSnapshotStorage
   
   ### 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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118604859


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -155,9 +157,17 @@ void clear(boolean delete) {
         getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
             if (delete) {
                 snapshotGenerateFuture.cancel(true);
+                String bucketKey = bucketKey();
+                long bucketId = getAndUpdateBucketId();
                 try {
-                    asyncDeleteBucketSnapshot().get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
-                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                    removeBucketCursorProperty(bucketKey())
+                            .thenApply(__ -> bucketSnapshotStorage.deleteBucketSnapshot(bucketId).exceptionally(ex -> {
+                                log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}",
+                                        bucketId, bucketKey, ex);
+                                return null;
+                            })).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (Exception e) {
+                    log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}", bucketId, bucketKey, e);

Review Comment:
   Because `bucketSnapshotStorage.deleteBucketSnapshot` use the same thread with `clear`, so we can't block `deleteBucketSnapshot` when clearing the bucket snapshot.



-- 
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] codelipenghui commented on a diff in pull request #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118191253


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -479,7 +479,7 @@ public void testClearDelayedMessagesWhenClearBacklog() throws PulsarClientExcept
         Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                 .topic(topic).create();
 
-        final int messages = 100;
+        final int messages = 10;

Review Comment:
   Is it related to this PR?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/BucketDelayedDeliveryTrackerFactory.java:
##########
@@ -63,7 +64,7 @@ public void initialize(PulsarService pulsarService) throws Exception {
     public DelayedDeliveryTracker newTracker(PersistentDispatcherMultipleConsumers dispatcher) {
         return new BucketDelayedDeliveryTracker(dispatcher, timer, tickTimeMillis, isDelayedDeliveryDeliverAtTimeStrict,
                 bucketSnapshotStorage, delayedDeliveryMinIndexCountPerBucket,
-                delayedDeliveryMaxTimeStepPerBucketSnapshotSegmentSeconds,
+                TimeUnit.SECONDS.toMillis(delayedDeliveryMaxTimeStepPerBucketSnapshotSegmentSeconds),

Review Comment:
   We should change `timeStepPerBucketSnapshotSegment` in `BucketDelayedDeliveryTracker` to `timeStepPerBucketSnapshotSegmentInMillis` 



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118602717


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -155,9 +157,17 @@ void clear(boolean delete) {
         getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
             if (delete) {
                 snapshotGenerateFuture.cancel(true);
+                String bucketKey = bucketKey();
+                long bucketId = getAndUpdateBucketId();
                 try {
-                    asyncDeleteBucketSnapshot().get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
-                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                    removeBucketCursorProperty(bucketKey())
+                            .thenApply(__ -> bucketSnapshotStorage.deleteBucketSnapshot(bucketId).exceptionally(ex -> {
+                                log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}",
+                                        bucketId, bucketKey, ex);
+                                return null;
+                            })).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (Exception e) {
+                    log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}", bucketId, bucketKey, e);

Review Comment:
   Because `bucketSnapshotStorage.deleteBucketSnapshot` use the same thread with `clear`, so we can't block `deleteBucketSnapshot` when clearing the bucket snapshot.



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118602717


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -155,9 +157,17 @@ void clear(boolean delete) {
         getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
             if (delete) {
                 snapshotGenerateFuture.cancel(true);
+                String bucketKey = bucketKey();
+                long bucketId = getAndUpdateBucketId();
                 try {
-                    asyncDeleteBucketSnapshot().get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
-                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                    removeBucketCursorProperty(bucketKey())
+                            .thenApply(__ -> bucketSnapshotStorage.deleteBucketSnapshot(bucketId).exceptionally(ex -> {
+                                log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}",
+                                        bucketId, bucketKey, ex);
+                                return null;
+                            })).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (Exception e) {
+                    log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}", bucketId, bucketKey, e);

Review Comment:
   Because `bucketSnapshotStorage.deleteBucketSnapshot` use the same thread as `clear`, so we can't block `deleteBucketSnapshot` when clearing the bucket snapshot.



-- 
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] codelipenghui merged pull request #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui merged PR #19615:
URL: https://github.com/apache/pulsar/pull/19615


-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118539846


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -479,7 +479,7 @@ public void testClearDelayedMessagesWhenClearBacklog() throws PulsarClientExcept
         Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                 .topic(topic).create();
 
-        final int messages = 100;
+        final int messages = 10;

Review Comment:
   Revert code



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118604859


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -155,9 +157,17 @@ void clear(boolean delete) {
         getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
             if (delete) {
                 snapshotGenerateFuture.cancel(true);
+                String bucketKey = bucketKey();
+                long bucketId = getAndUpdateBucketId();
                 try {
-                    asyncDeleteBucketSnapshot().get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
-                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                    removeBucketCursorProperty(bucketKey())
+                            .thenApply(__ -> bucketSnapshotStorage.deleteBucketSnapshot(bucketId).exceptionally(ex -> {
+                                log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}",
+                                        bucketId, bucketKey, ex);
+                                return null;
+                            })).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (Exception e) {
+                    log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}", bucketId, bucketKey, e);

Review Comment:
   Because `bucketSnapshotStorage.deleteBucketSnapshot` use the same thread with `clear`, so we can't block `deleteBucketSnapshot` when clearing the bucket snapshot.



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118481355


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -479,7 +479,7 @@ public void testClearDelayedMessagesWhenClearBacklog() throws PulsarClientExcept
         Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                 .topic(topic).create();
 
-        final int messages = 100;
+        final int messages = 10;

Review Comment:
   Due to I increase snapshot in test, this test is timeout, so I reduced the number of messages



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118481355


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -479,7 +479,7 @@ public void testClearDelayedMessagesWhenClearBacklog() throws PulsarClientExcept
         Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                 .topic(topic).create();
 
-        final int messages = 100;
+        final int messages = 10;

Review Comment:
   Due to I increase snapshot, this test is timeout, so I reduced the number of messages



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118481355


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/DelayedDeliveryTest.java:
##########
@@ -479,7 +479,7 @@ public void testClearDelayedMessagesWhenClearBacklog() throws PulsarClientExcept
         Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                 .topic(topic).create();
 
-        final int messages = 100;
+        final int messages = 10;

Review Comment:
   Due to I increase snapshot in test, this test is timeout, so I reduced the number of messages



-- 
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 #19615: [fix][broker] Fix BucketDelayedDeliveryTracker merge issues

Posted by "coderzc (via GitHub)" <gi...@apache.org>.
coderzc commented on code in PR #19615:
URL: https://github.com/apache/pulsar/pull/19615#discussion_r1118604859


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/delayed/bucket/ImmutableBucket.java:
##########
@@ -155,9 +157,17 @@ void clear(boolean delete) {
         getSnapshotCreateFuture().ifPresent(snapshotGenerateFuture -> {
             if (delete) {
                 snapshotGenerateFuture.cancel(true);
+                String bucketKey = bucketKey();
+                long bucketId = getAndUpdateBucketId();
                 try {
-                    asyncDeleteBucketSnapshot().get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
-                } catch (InterruptedException | ExecutionException | TimeoutException e) {
+                    removeBucketCursorProperty(bucketKey())
+                            .thenApply(__ -> bucketSnapshotStorage.deleteBucketSnapshot(bucketId).exceptionally(ex -> {
+                                log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}",
+                                        bucketId, bucketKey, ex);
+                                return null;
+                            })).get(AsyncOperationTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (Exception e) {
+                    log.error("Failed to delete bucket snapshot, bucketId: {}, bucketKey: {}", bucketId, bucketKey, e);

Review Comment:
   Because `bucketSnapshotStorage.deleteBucketSnapshot` use the same thread as `clear`, so we can't block `deleteBucketSnapshot` when clearing the bucket snapshot.



-- 
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