Skip to content

[improve][broker]Skip to mark delete if the target position of expira… - #24881

Merged
Technoboy- merged 2 commits into
apache:masterfrom
poorbarcode:improve/skip_expire_msg
Oct 27, 2025
Merged

[improve][broker]Skip to mark delete if the target position of expira…#24881
Technoboy- merged 2 commits into
apache:masterfrom
poorbarcode:improve/skip_expire_msg

Conversation

@poorbarcode

Copy link
Copy Markdown
Contributor

Motivation

#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

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: x

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Oct 22, 2025
@Technoboy-

Copy link
Copy Markdown
Contributor

/pulsarbot rerun-failure-checks

…ersistent/PersistentMessageExpiryMonitor.java

Co-authored-by: Zixuan Liu <nodeces@gmail.com>
@Technoboy-

Copy link
Copy Markdown
Contributor

/pulsarbot rerun-failure-checks

@Technoboy-
Technoboy- merged commit 14b0821 into apache:master Oct 27, 2025
96 of 98 checks passed
Technoboy- added a commit that referenced this pull request Oct 27, 2025
#24881)

Co-authored-by: Jiwei Guo <jwguo@streamnative.io>
Co-authored-by: Zixuan Liu <nodeces@gmail.com>
lhotari pushed a commit that referenced this pull request Oct 28, 2025
#24881)

Co-authored-by: Jiwei Guo <jwguo@streamnative.io>
Co-authored-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 14b0821)
manas-ctds pushed a commit to datastax/pulsar that referenced this pull request Oct 29, 2025
apache#24881)

Co-authored-by: Jiwei Guo <jwguo@streamnative.io>
Co-authored-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 14b0821)
(cherry picked from commit 5bdc5aa)
public void findEntryComplete(Position position, Object ctx) {
if (position != null) {
var markDeletedPosition = cursor.getMarkDeletedPosition();
if (markDeletedPosition != null && markDeletedPosition.compareTo(position) >= 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See more context here: #24607

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Thanks

@lhotari

lhotari commented Nov 4, 2025

Copy link
Copy Markdown
Member

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

srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Nov 6, 2025
apache#24881)

Co-authored-by: Jiwei Guo <jwguo@streamnative.io>
Co-authored-by: Zixuan Liu <nodeces@gmail.com>
(cherry picked from commit 14b0821)
(cherry picked from commit 5bdc5aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants