Skip to content

NPE on resetCursor #230

Closed
Closed

Description

@sschepens

@merlimat @rdhabalia
I just got a coulpe of NPE's when calling resetCursor on a subscription with active consumers.
The stack is:

java.lang.NullPointerException
	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.persistPosition(ManagedCursorImpl.java:1858)
	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.internalResetCursor(ManagedCursorImpl.java:700)
	at org.apache.bookkeeper.mledger.impl.ManagedCursorImpl.lambda$asyncResetCursor$4(ManagedCursorImpl.java:765)
	at org.apache.bookkeeper.mledger.util.SafeRun$1.safeRun(SafeRun.java:27)
	at org.apache.bookkeeper.util.SafeRunnable.run(SafeRunnable.java:31)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
	at java.lang.Thread.run(Thread.java:745)

Apparently, the ManagedCursorImpl has a null cursorLedger so the ends up passing null as LedgerHandle to persistPosition which fails when calling lh.asyncAddEntry here.

This leaves the subscription in a inconsistent state because the callback is never called and the subrscription is never unfenced.

Is it OK for a ManagedCursorImpl to have no cursor ledger? is it because data is stored in ZK? what should we do in this case?

Activity

  1. merlimat commented on Feb 21, 2017

    @merlimat
    Contributor

    Yes, after recovery the ledger is not immediately created (to avoid doing it in case the topic is not used). The cursor position data will be either stored on the old ledger or on the z-node, depending on how the managed-ledger was closed.

    A new request to perform mark-delete should trigger the ledger creation, though we need to make sure the mark-delete request does not get rate-limited.

  2. sschepens commented on Feb 21, 2017

    @sschepens
    ContributorAuthor

    But how do we handle this case here? we're resetting the cursor, all consumers have been disconected, but we have no ledger.
    Should we create one and the continue?

  3. added
    type/bug
    on Feb 23, 2017
  4. added this to the 1.17 milestone on Feb 23, 2017
  5. added a commit that references this issue on May 26, 2021
    ac78325
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions