Skip to content
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

[fix][broker] Avoid expired unclosed ledgers when checking expired messages by ledger closure time #22335

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

coderzc
Copy link
Member

@coderzc coderzc commented Mar 25, 2024

Motivation

#21940 introduced a way to expire messages based on ledger closure time, but can't exclude unclosed ledgers because the ledger's timestamp has a default value of 0. This will result in the following warn log when trying to expire an unclosed ledger.

2024-03-25T13:31:30,095 - WARN  - [main:PersistentMessageExpiryMonitor] - [topicname][testCheckExpiryByLedgerClosureTimeWithAckUnclosedLedger] 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: 4:1 -- attempted mark delete: 4:-1
Caused by: org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$MarkDeletingMarkedPosition: Mark deleting an already mark-deleted position. Current mark-delete: 4:1 -- attempted mark delete: 4:-1
	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.setAcknowledgedPosition(ManagedCursorImpl.java:1850) ~[classes/:?]
	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.asyncMarkDelete(ManagedCursorImpl.java:2017) ~[classes/:?]
	at org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor.findEntryComplete(PersistentMessageExpiryMonitor.java:218) ~[classes/:?]
	at org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor.checkExpiryByLedgerClosureTime(PersistentMessageExpiryMonitor.java:135) ~[classes/:?]
	at org.apache.pulsar.broker.service.persistent.PersistentMessageExpiryMonitor.expireMessages(PersistentMessageExpiryMonitor.java:89) ~[classes/:?]
	at org.apache.pulsar.broker.service.PersistentMessageFinderTest.testCheckExpiryByLedgerClosureTimeWithAckUnclosedLedger(PersistentMessageFinderTest.java:499) ~[test-classes/:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
	at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:677) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:221) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:969) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:194) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128) ~[testng-7.7.1.jar:7.7.1]
	at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
	at org.testng.TestRunner.privateRun(TestRunner.java:829) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.TestRunner.run(TestRunner.java:602) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:437) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:431) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:391) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunner.run(SuiteRunner.java:330) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1256) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1176) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.TestNG.runSuites(TestNG.java:1099) ~[testng-7.7.1.jar:7.7.1]
	at org.testng.TestNG.run(TestNG.java:1067) ~[testng-7.7.1.jar:7.7.1]
	at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66) ~[testng-rt.jar:?]
	at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:105) ~[testng-rt.jar:?]

Modifications

Excluding ledgers with a timestamp of 0 when checking for expired messages by the ledger closure time.

Verifying this change

  • 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

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

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

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 25, 2024
@coderzc coderzc self-assigned this Mar 25, 2024
@coderzc coderzc added type/bug The PR fixed a bug or issue reported a bug area/broker labels Mar 25, 2024
@coderzc coderzc changed the title [Fix] Avoid expired unclosed ledgers when checking expired messages by ledger closure time [fix][broker] Avoid expired unclosed ledgers when checking expired messages by ledger closure time Mar 25, 2024
@Technoboy- Technoboy- added this to the 3.3.0 milestone Mar 25, 2024
Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@lhotari lhotari requested a review from poorbarcode March 25, 2024 07:05
@lhotari lhotari merged commit f77fe5f into apache:master Mar 27, 2024
63 of 64 checks passed
lhotari pushed a commit that referenced this pull request Mar 27, 2024
…ssages by ledger closure time (#22335)

(cherry picked from commit f77fe5f)
lhotari pushed a commit that referenced this pull request Mar 27, 2024
…ssages by ledger closure time (#22335)

(cherry picked from commit f77fe5f)
Technoboy- pushed a commit to Technoboy-/pulsar that referenced this pull request Apr 1, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 15, 2024
…ssages by ledger closure time (apache#22335)

(cherry picked from commit f77fe5f)
(cherry picked from commit 20be6ca)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 17, 2024
…ssages by ledger closure time (apache#22335)

(cherry picked from commit f77fe5f)
(cherry picked from commit 20be6ca)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 17, 2024
…ssages by ledger closure time (apache#22335)

(cherry picked from commit f77fe5f)
(cherry picked from commit 20be6ca)
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 19, 2024
…ssages by ledger closure time (apache#22335)

(cherry picked from commit f77fe5f)
(cherry picked from commit 20be6ca)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 23, 2024
…ssages by ledger closure time (apache#22335)

(cherry picked from commit f77fe5f)
(cherry picked from commit 20be6ca)
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