Repository navigation
Description
Search before asking
- I searched in the issues and found nothing similar.
Read release policy
- I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.
Version
Warning
It's possible that the test setup contains bugs. More work is needed to validate that the test case is valid.
Note
It's possible that multiple bugs are involved. The comments describe some observations which might be client side bugs.
This applies to both master branch (which includes PIP-282 changes) as well as in branch-3.3
Minimal reproduce step
the test case has invocationCount=50 to repeat it 50 times. It usually fails about 25% of the test runs.
This is the test case:
org.apache.pulsar.client.api.KeySharedSubscriptionTest#testOrderingAfterReconnects
The test code depends on some new test utility methods.
reproducing based on master branch (with PIP-282 changes)
git clone -b lh-key_shared-testing-2024-09-13-220512 --depth=2 --single-branch https://github.com/lhotari/pulsar
cd pulsar
mvn -Pcore-modules,-main -T 1C clean install -DskipTests -Dspotbugs.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -DnarPluginPhase=none
mvn -DredirectTestOutputToFile=false -DtestRetryCount=0 test -pl pulsar-broker "-Dtest=org.apache.pulsar.client.api.KeySharedSubscriptionTest#testOrderingAfterReconnects"
based on branch-3.3 (without PIP-282)
git clone -b lh-key_shared-testing-branch-3.3-2024-09-13-220747 --depth=2 --single-branch https://github.com/lhotari/pulsar
cd pulsar
mvn -Pcore-modules,-main -T 1C clean install -DskipTests -Dspotbugs.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -DnarPluginPhase=none
mvn -DredirectTestOutputToFile=false -DtestRetryCount=0 test -pl pulsar-broker "-Dtest=org.apache.pulsar.client.api.KeySharedSubscriptionTest#testOrderingAfterReconnects"
What did you expect to see?
Key_Shared subscription in AUTO_SPLIT mode should retain ordering of messages by message key.
This should happen by holding back delivery of message keys that are currently handled by a consumer that is no longer the current "owner" of the hash range where the message key belongs to at the time of sending.
What did you see instead?
- message ordering by key isn't preserved in message processing
- sometimes message processing gets blocked and doesn't proceed
- there are duplicate messages in cases where it isn't expected
Anything else?
The initial goal of the test scenario was to simulate a rolling restart of consumers. However this isn't strictly followed in the test case. The test case was modified until test failures started appearing.
Are you willing to submit a PR?
- I'm willing to submit a PR!
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
lhotari commentedon Sep 13, 2024
@equanz Do you have a chance to validate whether the test results are valid?
lhotari commentedon Sep 13, 2024
It's possible that this is a Pulsar client bug. I'm using
.receiveAsyncin the test case.I also tested with
.receiveand threads to consume: https://github.com/lhotari/pulsar/blob/53188f42babd14c8120b7244b83066ec22b8222a/pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java#L2074-L2108The results were similar.
The third experiment was with messageListeners to receive messages and where consumers are paused initially. The problem doesn't reproduce in this case. I added some jitter for simulating processing. https://github.com/lhotari/pulsar/blob/0e608c93c5b0d6a9cf76751a4a82726b5e1654b4/pulsar-broker/src/test/java/org/apache/pulsar/client/api/KeySharedSubscriptionTest.java#L1922-L2109
It looks like using
.receive/.receiveAsyncmight be messing up ordering.lhotari commentedon Sep 13, 2024
The test fails consistently when using
.messageListenerwithout.startPaused(true). In that case, there's 7 to 10 out-of-order messages in each test run. With these changes: lhotari@ca41a88fThis looks like a client-side bug instead of broker side issue with Key_Shared.
lhotari commentedon Sep 13, 2024
I was testing this in branch-3.3 . It's possible that it reproduces the PIP-282 issue without
.startPaused(true). I'll check.lhotari commentedon Sep 13, 2024
Tested also with master branch (includes PIP-282), the problem reproduces with .messageListener unless
.startPaused(true)is used for c2 in the test (commit lhotari@1ff8c7ca).lhotari commentedon Sep 14, 2024
I've created #23309 as a proposal to address the issue.
equanz commentedon Sep 17, 2024
Further investigation may be needed, but I think this is an issue related to redelivery.
I added the following patches.
And I ran the test, then failed as follows.
When the c2 is reconnected, the dispatcher sends replay messages to the c2. After the c3 is disconnected,
8:2will be resent to the c2.(I didn't address redelivery messages in the PIP-282 because I think we can't fully address redelivery messages' ordering. For example, the dispatcher can't control the client-side redelivery operation such as unack
x:101beforex:100. cf. #21953 (comment) )I am asking some questions below to see if this issue is resolved in PIP-379.
#23309 (review)
lhotari commentedon Sep 19, 2024
Thanks for the careful investigation @equanz. Very helpful!
There's a past related issue #12885 with PR #12890 in this area.
It'll try to take this case into account when working on PIP-379 design and implementation.
lhotari commentedon Oct 3, 2024
This issue is fixed in PIP-379 implementation, #23352