Skip to content

Consumer can't get messages with earliest position subscription type under some circumstances  #7941

Closed

Description

@alexku7

Hello
We have severe issue with partitioned topics and key_shared subscriptions with multiple consumers per subscription.
After some time (could be few hours or few days) the consumers are stopping to consume messages . The backlog continues to grow.

The problem being observed in 2.5.2, 2.6.0, 2.6.1. (we didn't work with earlier versions)

In the broker log we can find these errors:

[bookkeeper-ml-workers-OrderedExecutor-7-0] WARN org.apache.bookkeeper.mledger.impl.ManagedCursorImpl - [persistent://sometenanat/somenamespace/b8d863eb-a632-4ae9-8682-2541f1a9c25e_02bae02b-partition-1][hostidentity-subscription-cloud] Error while replaying entries
org.apache.bookkeeper.mledger.ManagedLedgerException: Unknown exception.

(I am not sure that this error is related to the issue)

The issue more likely occurs when we do some change in the consumers like remove consumer, add another one.
It seems that it more likely happens with earliest subscription types .

I see enough available permits, no other problems that can explain this problem.
The problem is very serious and preventing us to move to production.

How can we start to troubleshooting this kind of problem ?

Activity

  1. added
    type/bug
    on Aug 31, 2020
  2. changed the title [-]Error while replaying entries org.apache.bookkeeper.mledger.ManagedLedgerException: Unknown exception[/-] [+]Consumer can't get messages with earliest position subscription type under some circumstances [/+] on Aug 31, 2020
  3. alexku7 commented on Aug 31, 2020

    @alexku7
    Author

    Hello
    I am pretty sure that i succeeded to reproduce the conditions for this issue.

    1. create a topic with three partitions. my-tenant/my-namespace/my/topic
    2. The topic should have producers for producing relatively many messages ( let's say 3000 per second) with different keys
    3. create simultaneously 2 consumers with key_shared subscription and earliest position:

    bin/pulsar-client consume -p Earliest -n 0 -s alex_test -t Key_Shared persistent://my-tenant/my-namespace/my/topic

    3, after 1-2 minutes , create third consumer with the same settings.

    You should see after 10-40 seconds that the all partitions are stuck with zero rate out and the backlog continues to grow .

    Interesting, that if i remove the third consumer, all are starting working again but if i remove the first or second consumer it's still stuck.

    The issue doesn't occur with Latest position.

  4. BewareMyPower commented on Sep 1, 2020

    @BewareMyPower
    Contributor

    I also reproduced the problem, though a little different. When I start 3rd consumer, it cannot consume any messages.

    I found these logs from the broker:

    14:42:36.274 [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
    java.lang.ArrayIndexOutOfBoundsException: null
    /* a lot of the same logs */
    14:42:37.488 [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
    java.lang.ArrayIndexOutOfBoundsException: null
    

    Also, there're some ManagedLedgerException logs around the large amount ArrayIndexOutOfBoundsException logs

    14:36:04.708 [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
    java.lang.ArrayIndexOutOfBoundsException: null
    14:36:04.744 [pulsar-io-23-15] WARN  org.apache.bookkeeper.mledger.impl.EntryCacheImpl - failed to read entries for 4726-4726:476113
    java.lang.ArrayIndexOutOfBoundsException: null
    14:36:04.745 [pulsar-io-23-15] WARN  org.apache.bookkeeper.mledger.impl.ManagedCursorImpl - [public/default/persistent/my-topic-partition-1][SubscriptionName-new] Error while replaying entries
    org.apache.bookkeeper.mledger.ManagedLedgerException: Unknown exception
    14:36:04.802 [pulsar-io-23-15] WARN  org.apache.bookkeeper.mledger.impl.EntryCacheImpl - failed to read entries for 4726-4726:476184
    java.lang.ArrayIndexOutOfBoundsException: null
    14:36:04.803 [pulsar-io-23-15] WARN  org.apache.bookkeeper.mledger.impl.ManagedCursorImpl - [public/default/persistent/my-topic-partition-1][SubscriptionName-new] Error while replaying entries
    org.apache.bookkeeper.mledger.ManagedLedgerException: Unknown exception
    14:36:04.806 [bookkeeper-ml-workers-OrderedExecutor-3-0] WARN  org.apache.bookkeeper.mledger.impl.ManagedCursorImpl - [public/default/persistent/my-topic-partition-1][SubscriptionName-new] Error while replaying entries
    org.apache.bookkeeper.mledger.ManagedLedgerException: Unknown exception
    14:36:04.864 [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
    java.lang.ArrayIndexOutOfBoundsException: null
    
  5. alexku7 commented on Sep 1, 2020

    @alexku7
    Author

    @BewareMyPower Hi. I also sometimes slightly different behaviors,
    Sometimes it was working for a while (10-40 sec) and sometimes was stopping immediately on the third consumer

  6. jiazhai commented on Sep 4, 2020

    @jiazhai
    Member

    @codelipenghui could this be related with #7682 ?

  7. alexku7 commented on Sep 5, 2020

    @alexku7
    Author

    I think we have here more complex bug then may be probably have thought .
    I succeeded to reproduce the same issue under other conditions.
    For example when i create quickly very large backlog that issue happens again .
    It always occurs with Key_Shared subscriptions.

    For example
    bin/pulsar-perf produce --warmup-time 5 --batch-time-window 3000 --num-producers 1 --size 900 --rate 10000 --num-topic 150--test-duration 43200 --stats-interval-seconds 60 internal/testtest

    consume: bin/pulsar-perf consume --num-topics 150 --rate 1000 --stats-interval-seconds 60 --subscription-type Key_Shared internal/test/test

    The second simulates the slow consumer.I executed a few similar shells and after few minutes i started to see "dead" topics with growing backlogs and lot of errors in the brokers

    [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught

    and

    [bookkeeper-ml-workers-OrderedExecutor-3-0] ERROR org.apache.bookkeeper.common.util.SafeRunnable - Unexpected throwable caught
    java.lang.ArrayIndexOutOfBoundsException: null

    Very strange and very annoying .The problem is that this issue is real blocker for us because we must working with key_shared :(

  8. codelipenghui commented on Sep 9, 2020

    @codelipenghui
    Contributor

    @alexku7 I have tested on my laptop, but the error information looks a bit different

    java.lang.IndexOutOfBoundsException: Index -125 out of bounds for length 5
            at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
            at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
            at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248) ~[?:?]
            at java.util.Objects.checkIndex(Objects.java:372) ~[?:?]
            at java.util.ArrayList.get(ArrayList.java:458) ~[?:?]
            at org.apache.pulsar.broker.service.persistent.PersistentStickyKeyDispatcherMultipleConsumers.sendMessagesToConsumers(PersistentStickyKeyDispatcherMultipleConsumers.java:173) ~[org.apache.pulsar-pulsar-broker-2.6.1.jar:2.6.1]
            at org.apache.pulsar.broker.service.persistent.PersistentDispatcherMultipleConsumers.readEntriesComplete(PersistentDispatcherMultipleConsumers.java:480) ~[org.apache.pulsar-pulsar-broker-2.6.1.jar:2.6.1]
            at org.apache.bookkeeper.mledger.impl.OpReadEntry.lambda$checkReadCompletion$2(OpReadEntry.java:152) ~[org.apache.pulsar-managed-ledger-2.6.1.jar:2.6.1]
            at org.apache.bookkeeper.mledger.util.SafeRun$1.safeRun(SafeRun.java:32) ~[org.apache.pulsar-managed-ledger-2.6.1.jar:2.6.1]
            at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) [org.apache.bookkeeper-bookkeeper-common-4.10.0.jar:4.10.0]
            at org.apache.bookkeeper.common.util.OrderedExecutor$TimedRunnable.run(OrderedExecutor.java:203) [org.apache.bookkeeper-bookkeeper-common-4.10.0.jar:4.10.0]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.48.Final.jar:4.1.48.Final]
            at java.lang.Thread.run(Thread.java:834) [?:?]
    

    Could you please help verify without message batching? I suspect to the batch message and I have verified on my laptop(2.6.1). So I can confirm if they are the same issue.

  9. self-assigned this
    on Sep 9, 2020
  10. added this to the 2.7.0 milestone on Sep 9, 2020
  11. alexku7 commented on Sep 9, 2020

    @alexku7
    Author

    @codelipenghui Hi
    Did you disable the batching on the consumer or producer?
    I just wondering how i can disable the batching on the pulsar-client or probably i need my own java client ?

  12. alexku7 commented on Sep 9, 2020

    @alexku7
    Author

    @codelipenghui sorry but one question

    did you succeed to reproduce this issue with pulsar-client as was mentioned in my first message and also in the @BewareMyPower ?

  13. codelipenghui commented on Sep 9, 2020

    @codelipenghui
    Contributor

    @alexku7 Yes, I reproduced it when enable message batching. When I disable the message batching, looks the problem does not appear.

    I test by pulsar-perf and add -bm 1 to disable message batching.

  14. added 2 commits that reference this issue on Sep 11, 2020
    f9988b4
    880c485
  15. added a commit that references this issue on Oct 3, 2020
    a7c6078
  16. added a commit that references this issue on Oct 30, 2020
    807f550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

release/2.6.2type/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions