You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "poorbarcode (via GitHub)" <gi...@apache.org> on 2025/10/22 02:49:41 UTC

[PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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

   ### Motivation
   
   https://github.com/apache/pulsar/pull/24622 improved the message expiration, but forgot to skip expiring if the target position is less than mark deleted position
   
   ```
   2025-10-22T02:22:37,301+0000 [BookKeeperClientWorker-OrderedExecutor-2-0] WARN  org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor - [persistent://t1/ns/tp-partition-8][ostFixtureSubscription2] Message expiry failed - mark delete failed
   org.apache.bookkeeper.mledger.ManagedLedgerException: org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$MarkDeletingMarkedPosition: Mark deleting an already mark-deleted position. Current mark-delete: 4200475:458 -- attempted mark delete: 4193092:3606
   Caused by: org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$MarkDeletingMarkedPosition: Mark deleting an already mark-deleted position. Current mark-delete: 4200475:458 -- attempted mark delete: 4193092:3606
   	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.setAcknowledgedPosition(ManagedCursorImpl.java:2031) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.asyncMarkDelete(ManagedCursorImpl.java:2163) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor.findEntryComplete(PersistentMessageExpiryMonitor.java:237) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor.expireMessages(PersistentMessageExpiryMonitor.java:157) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at org.apache.pulsar.broker.service.persistent.PersistentSubscription.expireMessages(PersistentSubscription.java:1258) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at org.apache.pulsar.broker.service.persistent.PersistentTopic.lambda$checkMessageExpiryWithSharedPosition$85(PersistentTopic.java:2205) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at java.base/java.util.concurrent.ConcurrentHashMap.forEach(Unknown Source) ~[?:?]
   	at org.apache.pulsar.broker.service.persistent.PersistentTopic.lambda$checkMessageExpiryWithSharedPosition$88(PersistentTopic.java:2197) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source) ~[?:?]
   	at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source) ~[?:?]
   	at java.base/java.util.concurrent.CompletableFuture.complete(Unknown Source) ~[?:?]
   	at org.apache.pulsar.broker.service.persistent.PersistentTopic$8.findEntryComplete(PersistentTopic.java:2179) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at org.apache.pulsar.broker.service.persistent.PersistentMessageFinder.findEntryComplete(PersistentMessageFinder.java:160) ~[io.streamnative-pulsar-broker-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.OpFindNewest.readEntryComplete(OpFindNewest.java:138) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheImpl$1.readEntriesComplete(RangeEntryCacheImpl.java:241) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheImpl$2.readEntriesComplete(RangeEntryCacheImpl.java:362) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.cache.PendingReadsManager$PendingRead.readEntriesComplete(PendingReadsManager.java:278) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.mledger.impl.cache.PendingReadsManager$PendingRead.lambda$attach$0(PendingReadsManager.java:244) ~[io.streamnative-managed-ledger-4.0.6.6.jar:4.0.6.6]
   	at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:128) ~[io.streamnative-bookkeeper-common-4.17.2.2.jar:4.17.2.2]
   	at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:99) ~[io.streamnative-bookkeeper-common-4.17.2.2.jar:4.17.2.2]
   	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.127.Final.jar:4.1.127.Final]
   	at java.base/java.lang.Thread.run(Unknown Source) [?:?]
   ```
   
   
   ### Modifications
   
   Improve the behaviour
   
   ### 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: x
   


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode closed pull request #24881: [improve][broker]Skip to mark delete if the target position of expira…
URL: https://github.com/apache/pulsar/pull/24881


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   I created #24941 to fix the bug and it also contains a test case



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   Ah, 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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,9 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            if (cursor.getMarkDeletedPosition() != null && cursor.getMarkDeletedPosition().compareTo(position) >= 0) {

Review Comment:
   ```suggestion
               var markDeletedPosition = cursor.getMarkDeletedPosition();
               if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {
   ```
   
   Avoid NPE.



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #24881:
URL: https://github.com/apache/pulsar/pull/24881#issuecomment-3449256063

   /pulsarbot rerun-failure-checks


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,9 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            if (cursor.getMarkDeletedPosition() != null && cursor.getMarkDeletedPosition().compareTo(position) >= 0) {

Review Comment:
   The second call to `cursor. getMarkDeletedPosition()` may return null.



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   The variable will be finally set to `false` after the task is completely finished(after mark deleting task is finished), see also this two lines:
   - https://github.com/apache/pulsar/blob/v4.1.1/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java#L217
   - https://github.com/apache/pulsar/blob/v4.1.1/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java#L226



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   @poorbarcode This seems to miss `expirationCheckInProgress = FALSE;`. Could you please check?



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari commented on PR #24881:
URL: https://github.com/apache/pulsar/pull/24881#issuecomment-3484538631

   There's a follow up in #24941 which fixes a bug introduced by this PR


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   See more context here: https://github.com/apache/pulsar/pull/24607



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,10 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            var markDeletedPosition = cursor.getMarkDeletedPosition();
+            if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Review Comment:
   > The variable will be finally set to after the task is completely finished(after mark deleting task is finished), see also this two lines:
   
   Please check again. `markDeleteCallback` won't get executed at all after the new code in this PR has been added.
   



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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #24881:
URL: https://github.com/apache/pulsar/pull/24881#issuecomment-3441718893

   /pulsarbot rerun-failure-checks


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


Re: [PR] [improve][broker]Skip to mark delete if the target position of expira… [pulsar]

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


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -231,6 +231,9 @@ public void markDeleteFailed(ManagedLedgerException exception, Object ctx) {
     @Override
     public void findEntryComplete(Position position, Object ctx) {
         if (position != null) {
+            if (cursor.getMarkDeletedPosition() != null && cursor.getMarkDeletedPosition().compareTo(position) >= 0) {

Review Comment:
   what's the difference?



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