Skip to content

Specific topic becomes unavailable due to failure of cursor recovery #2666

Closed

Description

@massakam

Currently, specific topic is unavailable in our Pulsar cluster. We can not send/receive messages to/from the topic, and HTTP requests to get stats/stats-internal timed-out. We don't know how to reproduce this phenomenon.

The info-internal of that topic is as follows:
info-internal.txt

Metadata on ZK:

$ pulsar-managed-ledger-admin print-managed-ledger \
  -zk zk15.xxx.xxx.xxx \
  -mlp xxxx/global/yyyy/persistent/zzzz

ledgerInfo {
  ledgerId: 65425
  entries: 2
  size: 238
  timestamp: 1506510325426
}
ledgerInfo {
  ledgerId: 1952728
  timestamp: 0
}

$ pulsar-managed-ledger-admin print-cursor \
  -zk zk15.xxx.xxx.xxx \
  -mlp xxxx/global/yyyy/persistent/zzzz \
  -cn sub.30

cursorsLedgerId: -1
markDeleteLedgerId: 1952575
markDeleteEntryId: -1

The following error was output to the broker log. It seems to have failed to recover the cursor due to invalid range error.

08:58:51.367 [bookkeeper-ml-workers-OrderedExecutor-7-0] INFO  o.a.b.mledger.impl.ManagedCursorImpl - [xxxx/global/yyyy/persistent/zzzz] Cursor sub.30 recovered to position 1952728:-1
08:58:51.368 [bookkeeper-ml-workers-OrderedExecutor-7-0] ERROR o.a.b.common.util.SafeRunnable       - Unexpected throwable caught
java.lang.IllegalArgumentException: Invalid range: (1952728:-1..65425:1]
        at com.google.common.collect.Range.<init>(Range.java:352) ~[guava-21.0.jar:na]
        at com.google.common.collect.Range.create(Range.java:146) ~[guava-21.0.jar:na]
        at com.google.common.collect.Range.openClosed(Range.java:194) ~[guava-21.0.jar:na]
        at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.recoveredCursor(ManagedCursorImpl.java:358) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.access$300(ManagedCursorImpl.java:90) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$1.operationComplete(ManagedCursorImpl.java:244) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl$1.operationComplete(ManagedCursorImpl.java:218) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.mledger.impl.MetaStoreImplZookeeper.lambda$null$7(MetaStoreImplZookeeper.java:240) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.mledger.util.SafeRun$1.safeRun(SafeRun.java:32) ~[managed-ledger-original-2.1.1-incubating.jar:2.1.1-incubating]
        at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36) ~[bookkeeper-common-4.7.2.jar:4.7.2]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.22.Final.jar:4.1.22.Final]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]

I have a couple of questions:

  • Is this caused by incorrect metadata on ZK? Or is it a bug in managed ledger related classes?
  • How can we restore this topic to normal?

System configuration

Pulsar version: 2.1.1-incubating

Activity

  1. massakam commented on Sep 27, 2018

    @massakam
    ContributorAuthor

    If ManagedCursorImpl has been modified as follows, the cursor recovery is successfully completed and the topic become available. Is this change appropriate?

    --- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
    +++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java
    @@ -353,6 +353,9 @@ public class ManagedCursorImpl implements ManagedCursor {
                 }
                 position = nextExistingLedger != null ? PositionImpl.get(nextExistingLedger, -1) : position;
             }
    +        if (position.compareTo(ledger.getLastPosition()) > 0) {
    +            position = PositionImpl.get(ledger.getLastPosition());
    +        }
             log.info("[{}] Cursor {} recovered to position {}", ledger.getName(), name, position);
    
             messagesConsumedCounter = -getNumberOfEntries(Range.openClosed(position, ledger.getLastPosition()));
  2. massakam commented on Oct 2, 2018

    @massakam
    ContributorAuthor

    This problem can be avoided by #2673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions