Skip to content

Bookie does not try to download ledger from another bookie #2273

Closed

Description

@hamadodene

BUG REPORT

Describe the bug

We have a cluster of Bookkeeper with 3 servers.
For example we can considered (bk1,bk2 and bk3). We writing only inside bk1 and bk2 , and bk3 read from bk2.
When bk2 come down bk3 continue to search reading from bk2.
We expected if bk2 come down, bk3 should try to read from bk1 and not continue to try with bk2.

20-02-24-12-35-21       While readLastConfirmed ledger: 19734 did not hear success responses from all quorums
20-02-24-12-35-27       While readLastConfirmed ledger: 19734 did not hear success responses from all quorums
20-02-24-12-35-33       While readLastConfirmed ledger: 19734 did not hear success responses from all quorums
20-02-24-12-35-39       While readLastConfirmed ledger: 19734 did not hear success responses from all quorums
20-02-24-12-33-30       Could not connect to bookie: [id: 0xa6f88d56, L:/ip-bk3:37224]/bk2:3181, current state CONNECTING :
20-02-24-12-33-30       io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: No route to host: bk2/ip-address:3181
io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: No route to host: bk2/ip-address:3181
        at io.netty.channel.unix.Errors.throwConnectException(Errors.java:112)
        at io.netty.channel.unix.Socket.finishConnect(Socket.java:269)
        at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:670)
        at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:647)
        at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.epollOutReady(AbstractEpollChannel.java:527)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:422)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:333)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:906)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:830)
Caused by: java.net.ConnectException: finishConnect(..) failed: No route to host
        ... 11 more

To reproduce it , follow my description above

Activity

  1. sijie commented on Feb 24, 2020

    @sijie
    Member

    @hamadodene It attempts to read from bk-2. but it seems that bk-2 is not reachable - No route to host: bk2/ip-address:3181

  2. eolivelli commented on Feb 24, 2020

    @eolivelli
    Contributor

    I talked offline about this issue with @hamadodene .

    The ledger is written with WQ=2 and ledger metadata point that segment to bk1 and bk2 bookies.
    The client (reader) is on bk3.
    It seems that BK is trying only to read from bk3.

    The case here is that bk2 machine has been forcibly partitioned away from network.

    @hamadodene please correct me if I am wrong.
    Do you have more logs?

  3. hamadodene commented on Feb 25, 2020

    @hamadodene
    Author

    @eolivelli yes is correct,
    bk2 had been partitioned from the network.
    We were writing on bookkeeeper with replica 2 (precisely at that moment on bk1 and bk2) and at that moment bk3 was reading the data from bk2.
    When bk2 was partitioned, we expected bk3 to read from bk1 after a few minutes. Instead after 30 minutes he was still trying to read the data from bk2.

    I have this expection from bk3 logs:

    org.apache.bookkeeper.client.BKException$BKReadException: Error while reading ledger
            at org.apache.bookkeeper.client.SyncCallbackUtils.finish(SyncCallbackUtils.java:83)
            at org.apache.bookkeeper.client.SyncCallbackUtils$SyncOpenCallback.openComplete(SyncCallbackUtils.java:157)
            at org.apache.bookkeeper.client.LedgerOpenOp.openComplete(LedgerOpenOp.java:232)
            at org.apache.bookkeeper.client.LedgerOpenOp$2.readLastConfirmedComplete(LedgerOpenOp.java:215)
            at org.apache.bookkeeper.client.LedgerHandle$10.readLastConfirmedDataComplete(LedgerHandle.java:1405)
            at org.apache.bookkeeper.client.ReadLastConfirmedOp.readEntryComplete(ReadLastConfirmedOp.java:142)
            at org.apache.bookkeeper.proto.PerChannelBookieClient$ReadCompletion$1.readEntryComplete(PerChannelBookieClient.java:1829)
            at org.apache.bookkeeper.proto.PerChannelBookieClient$ReadCompletion.lambda$errorOut$0(PerChannelBookieClient.java:1845)
            at org.apache.bookkeeper.proto.PerChannelBookieClient$CompletionValue$1.safeRun(PerChannelBookieClient.java:1638)
            at org.apache.bookkeeper.common.util.SafeRunnable.run(SafeRunnable.java:36)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            at java.base/java.lang.Thread.run(Thread.java:830)
    
    
  4. eolivelli commented on Mar 5, 2020

    @eolivelli
    Contributor

    Finally we realized the "problem", it is not a strictly a bug in BookKeeper but it is a very unexpected behaviour that needs a workaround in the application and a workaround is not always possible.

    The scenario is the following:

    • we have the usual leader/follower pattern for BK users
    • the leader holds on metadata service (ZooKeeper) a list of "active ledgers" that build up an unlimited stream of data
    • the leader creates a new ledger with WQ=2, gets the id and appends it to the list of "active ledgers"
    • the ledger is empty, no write has ever been issues to bookies
    • bookies locally do not know anything about the ledger
    • now let's stop one of the two bookies (or partition it away from client network, that's the @hamadodene 's case)
    • so we have on ledger metadata an ensemble with bookie1 and bookie2, ledger is in state OPEN, LAC = -1
    • bookie1 is up and running, but it doesn't hold any entry
    • bookie2 is unreachable from the client
    • the follower tries to open the ledger (no recovery), and boom !
    • the ledger is OPEN, the follower reads "NoSuchLedger" from Bookie1 and it gets a network error (BookieHandleNotAvailable or something like that) from Bookie2

    It looks like that even a recovery read is not possible in this case.

    The workaround is to write (and block until a successful acknowledge) an entry to the ledger before adding the ledger to the list of "active ledgers", this way you are sure that each bookie knows about the ledger and does not answer NoSuchLedger.

    With QA < WQ this workaround won't work, because the write of entry 0 may not be acklowledged by Bookie1 (the one running during the open action) but the client will consider it successfully written (because Bookie2 at the time of the write is up and running).

    cc @hamadodene @aluccaroni @ivankelly @fpj @jvrao @sijie

  5. ivankelly commented on Apr 3, 2020

    @ivankelly
    Contributor
  6. eolivelli commented on Apr 3, 2020

    @eolivelli
    Contributor

    @ivankelly thanks for sharing.
    Your comment is useful

    @rdhabalia please take a look

    This is something we must fix in next release.

  7. ivankelly commented on Apr 3, 2020

    @ivankelly
    Contributor

    As I said in the linked comment above, I have a fix already. Will push on monday.

  8. ivankelly commented on Apr 3, 2020

    @ivankelly
    Contributor

    Also, for clarity, it's not data loss broken really. It's more an availability issue.

  9. eolivelli commented on Dec 2, 2020

    @eolivelli
    Contributor

    This issue has been fixed with BK 4.11

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions