Skip to content

[Bug] Bookkeeper returns mac mismatch while reading #21421

Closed

Description

@KannarFr

Search before asking

  • I searched in the issues and found nothing similar.

Version

2.11.3 to 3.1.0

Minimal reproduce step

N/A

What did you expect to see?

No error

What did you see instead?

After bumped I got a lot of exceptions as:

2023-10-23T15:01:29,964+0000 [BookKeeperClientWorker-OrderedExecutor-7-0] INFO  org.apache.bookkeeper.client.PendingReadOp - Mac mismatch while reading L16702 E0 from bookie: yo-bookkeeper-c3-n3
2023-10-23T15:01:29,965+0000 [BookKeeperClientWorker-OrderedExecutor-7-0] ERROR org.apache.bookkeeper.client.PendingReadOp - Read of ledger entry failed: L16702 E0-E0, Sent to [yo-bookkeeper-c3-n14, yo-bookkeeper-c3-n3, yo-bookkeeper-c3-n7], Heard from [yo-bookkeeper-c3-n14, yo-bookkeeper-c3-n3, yo-bookkeeper-c3-n7] : bitset = {0, 1, 2}, Error = 'Entry digest does not match'. First unread entry is (-1, rc = null)
2023-10-23T15:01:29,966+0000 [main] ERROR org.apache.bookkeeper.client.BookKeeperAdmin - Error reading entry 0 from ledger 16702
org.apache.bookkeeper.client.BKException$BKDigestMatchException: Entry digest does not match
        at org.apache.bookkeeper.client.SyncCallbackUtils.finish(SyncCallbackUtils.java:83) ~[org.apache.bookkeeper-bookkeeper-server-4.16.2.jar:4.16.2]
        at org.apache.bookkeeper.client.SyncCallbackUtils$SyncReadCallback.readComplete(SyncCallbackUtils.java:229) ~[org.apache.bookkeeper-bookkeeper-server-4.16.2.jar:4.16.2]
        at org.apache.bookkeeper.client.LedgerHandle$4.onFailure(LedgerHandle.java:818) ~[org.apache.bookkeeper-bookkeeper-server-4.16.2.jar:4.16.2]
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:38) ~[org.apache.bookkeeper-bookkeeper-common-4.16.2.jar:4.16.2]
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:26) ~[org.apache.bookkeeper-bookkeeper-common-4.16.2.jar:4.16.2]
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?]
        at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?]
        at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:137) ~[org.apache.bookkeeper-bookkeeper-common-4.16.2.jar:4.16.2]
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:107) ~[org.apache.bookkeeper-bookkeeper-common-4.16.2.jar:4.16.2]
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[io.netty-netty-common-4.1.94.Final.jar:4.1.94.Final]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
org.apache.pulsar.broker.service.schema.exceptions.SchemaException: Entry digest does not match -  ledger=103622248 - operation=Failed to read entry - entry=0
        at org.apache.pulsar.broker.service.schema.BookkeeperSchemaStorage.bkException(BookkeeperSchemaStorage.java:711)
        at org.apache.pulsar.broker.service.schema.BookkeeperSchemaStorage$Functions.lambda$getLedgerEntry$0(BookkeeperSchemaStorage.java:655)
        at org.apache.bookkeeper.client.LedgerHandle$4.onFailure(LedgerHandle.java:818)
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:38)
        at org.apache.bookkeeper.common.concurrent.FutureEventListener.accept(FutureEventListener.java:26)
        at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863)
        at java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841)
        at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.safeRunTask(SingleThreadExecutor.java:137)
        at org.apache.bookkeeper.common.util.SingleThreadExecutor.run(SingleThreadExecutor.java:107)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Oct 23, 2023
  2. changed the title [-][Bug] [/-] [+][Bug] Bookkeeper returns Mac mismatch while reading[/+] on Oct 23, 2023
  3. changed the title [-][Bug] Bookkeeper returns Mac mismatch while reading[/-] [+][Bug] Bookkeeper returns mac mismatch while reading[/+] on Oct 23, 2023
  4. KannarFr commented on Oct 23, 2023

    @KannarFr
    ContributorAuthor

    I'm rollbacking brokers (only) to 2.11.

    EDIT: It fixed the issue. So there is an issue with rendering on the client side on v2.11+.

  5. KannarFr commented on Oct 23, 2023

    @KannarFr
    ContributorAuthor

    A bit more context

    2023-10-23T13:35:47,556+0000 [BookKeeperClientWorker-OrderedExecutor-9-0] ERROR org.apache.bookkeeper.client.PendingReadOp - Read of ledger entry failed: L103556923 E0-E0, Sent to [yo-bookkeeper-c3-n8, yo-bookkeeper-c3-n6, yo-bookkeeper-c3-n4], Heard from [yo-bookkeeper-c3-n8, yo-bookkeeper-c3-n6, yo-bookkeeper-c3-n4] : bitset = {0, 1, 2}, Error = 'Entry digest does not match'. First unread entry is (-1, rc = null)
    2023-10-23T13:35:47,556+0000 [BookKeeperClientWorker-OrderedExecutor-9-0] WARN  org.apache.pulsar.broker.service.ServerCnx - [/192.168.2.5:48818][persistent://user_421c40fa-009e-433c-a93b-fc77551a2406/logs/__change_events-partition-0][multiTopicsReader-02b7f937a6] Failed to create consumer: consumerId=2104, Entry digest does not match -  ledger=103556923 - operation=Failed to read entry - entry=0
    

    Where Read of ledger entry failed: L**103556923** E0-E0 really looks like trying to read an empty ledger.

    $ bookkeeper shell ledgermetadata -ledgerid 103556923
    2023-10-23T21:28:51,808+0000 [main] INFO  org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - LedgerMetadata{formatVersion=3, ensembleSize=5, writeQuorumSize=3, ackQuorumSize=2, state=CLOSED, length=8336, lastEntryId=0, digestType=CRC32C, password=base64:, ensembles={0=[yo-bookkeeper-c3-n4, yo-bookkeeper-c3-n6, yo-bookkeeper-c3-n8, yo-bookkeeper-c3-n9, yo-bookkeeper-c3-n15]}, customMetadata={component=base64:c2NoZW1h, application=base64:cHVsc2Fy, pulsar/schemaId=base64:dXNlcl80MjFjNDBmYS0wMDllLTQzM2MtYTkzYi1mYzc3NTUxYTI0MDYvbG9ncy9fX2NoYW5nZV9ldmVudHM=}}
    
  6. miton18 commented on Oct 26, 2023

    @miton18
    Contributor

    We hit the same errors on Pulsar v3.0.1

  7. hangc0276 commented on Oct 26, 2023

    @hangc0276
    Contributor

    We hit the same errors on Pulsar v3.0.1

    @miton18 Do you have any way to reproduce this issue?

  8. miton18 commented on Oct 26, 2023

    @miton18
    Contributor

    We hit the same errors on Pulsar v3.0.1

    @miton18 Do you have any way to reproduce this issue?

    sadly, no

    It happens when upgrading brokers to v3.x.x

  9. hangc0276 commented on Oct 26, 2023

    @hangc0276
    Contributor

    We hit the same errors on Pulsar v3.0.1

    @miton18 Do you have any way to reproduce this issue?

    sadly, no

    It happens when upgrading brokers to v3.x.x

    Only upgrade broker, doesn't upgrade the bookie, right?

  10. miton18 commented on Oct 26, 2023

    @miton18
    Contributor

    bookies has been upgraded to v3.1.0 without issues

  11. miton18 commented on Oct 26, 2023

    @miton18
    Contributor

    ok, trying to read a ledger from bookkeeper itself also throw the same error...

    023-10-26T09:40:26,062+0000 [main] INFO org.apache.bookkeeper.tools.cli.commands.client.LedgerMetaDataCommand - LedgerMetadata{formatVersion=3, ensembleSize=5, writeQuorumSize=3, ackQuorumSize=3, state=CLOSED, length=8336, lastEntryId=0, digestType=CRC32C, password=base64:, ensembles={0=[yo-bookkeeper-c3-n12, yo-bookkeeper-c3-n8, yo-bookkeeper-c3-n14, yo-bookkeeper-c3-n6, yo-bookkeeper-c3-n3]}, customMetadata={component=base64:c2NoZW1h, application=base64:cHVsc2Fy, pulsar/schemaId=base64:b3JnYV8yMWQ3ZjZkMy04Mzk3LTQ3ODItOWE2NS05MWVjYWMxYTQ1OTUvbG9ncy9fX2NoYW5nZV9ldmVudHM=}}

  12. KannarFr commented on Oct 30, 2023

    @KannarFr
    ContributorAuthor

    Looks fixed in 3.1.1.

  13. lhotari commented on Nov 9, 2023

    @lhotari
    Member

    There are some reports on Pulsar Slack that this issue happens when bookkeeperUseV2WireProtocol=false or TLS is enabled for Bookkeeper. @hangc0276 I wonder what the possible bug fix has been if this is already fixed?

  14. Debashish-Mallick commented on Nov 14, 2023

    @Debashish-Mallick

    Looks fixed in 3.1.1.

    @KannarFr Have you checked with 3.0.XX version. Basically Its working, if we set bookkeeperUseV2WireProtocol=true in broker configmap.

  15. KannarFr commented on Nov 14, 2023

    @KannarFr
    ContributorAuthor

    No, I didn't but should I use v2 (legacy) wire proto? I mean this can fix the issue, but this is a jump in the past, nope? :D

  16. 7 remaining items

  17. lhotari commented on Jan 29, 2024

    @lhotari
    Member

    Reopening until latest concerns about other checksum related bugs in BK are resolved.

  18. lhotari commented on Mar 29, 2024

    @lhotari
    Member

    Pending fix in Bookkeeper will be included in 4.16.5 release.
    apache/bookkeeper#4196

  19. pqab commented on Apr 10, 2024

    @pqab

    We are using 4.16.3 and encountering this error with 1-2 events occurring randomly on a daily basis, and we have a workaround to skip the specific position and resend the data to recover it. May I know if you are aware of any other workarounds available before the 4.16.5 release?

  20. lhotari commented on Apr 11, 2024

    @lhotari
    Member

    We are using 4.16.3 and encountering this error with 1-2 events occurring randomly on a daily basis, and we have a workaround to skip the specific position and resend the data to recover it. May I know if you are aware of any other workarounds available before the 4.16.5 release?

    @pqab I'm not aware of a workaround. There's also a concern that there are some other problems (#22103 with some linked BK issue) that cause similar symptoms.
    BK 4.16.5 has been released and there's PR to upgrade in Pulsar, #22484. This will be included in Pulsar releases 3.0.5 and 3.2.3 . ETA for the release is within a few weeks. In the meantime, it's possible to build custom builds of Pulsar.

  21. lhotari commented on May 28, 2024

    @lhotari
    Member

    I believe that this issue is a duplicate of #22601. I have made a fix to bookkeeper which fixes the issue: apache/bookkeeper#4404

  22. dao-jun commented on Jun 23, 2025

    @dao-jun
    Member

    The issue still exists in 3.0.12

  23. lhotari commented on Jun 23, 2025

    @lhotari
    Member

    The issue still exists in 3.0.12

    @dao-jun Is this with a cluster that was upgraded? Already corrupted entries won't get fixed, so it's possible to get the exception even if the actual root cause has been fixed.

  24. dao-jun commented on Jun 23, 2025

    @dao-jun
    Member

    @lhotari We set TTL and Retention for the cluster and it retains 1 day message data. We upgraded Pulsar/Bookkeeper from 3.0.11 to 3.0.12 more than a week, but the broker keeps printing
    Digest mismatch for ledger-id: 6545801, entry-id: 5971

  25. lhotari commented on Jun 23, 2025

    @lhotari
    Member

    @lhotari We set TTL and Retention for the cluster and it retains 1 day message data. We upgraded Pulsar/Bookkeeper from 3.0.11 to 3.0.12 more than a week, but the broker keeps printing Digest mismatch for ledger-id: 6545801, entry-id: 5971

    @dao-jun does this happen with new entries? there's another issue #22906 which is about Pulsar not being able to recover after a corrupted entry.

  26. lhotari commented on Jun 23, 2025

    @lhotari
    Member

    @dao-jun do you happen to set managedLedgerAddEntryTimeoutSeconds in your broker.conf? My concern is that there could be something that could cause entry corruption in that case, but I haven't verified it (related comments: #24411 (comment)).

  27. dao-jun commented on Jun 24, 2025

    @dao-jun
    Member

    @lhotari Yes, we set managedLedgerAddEntryTimeoutSeconds to 30s.
    Interesting, it seems that there has a bug in the feature?

  28. lhotari commented on Jun 24, 2025

    @lhotari
    Member

    @lhotari Yes, we set managedLedgerAddEntryTimeoutSeconds to 30s. Interesting, it seems that there has a bug in the feature?

    @dao-jun It would be useful to file a new GitHub issue. Please do so.

    The problem reminds of issues that I faced in #10738/#10755 along time ago. The problem is most likely different, but that might give some ideas of ways to reproduce the issue.
    Do you get any sign of IllegalReferenceCountException in logs as a result of double releasing buffers?

    Do you happen to have a ManagedLedgerInterceptor configured?

    I found #22221 related to managedLedgerAddEntryTimeoutSeconds. Perhaps that also gives some ideas how to reproduce and what could go wrong.

    When looking at the code, I think I see multiple concerns in the OpAddEntry.run method and using timeouts.
    It seems that the currentLedgerTimeoutTriggered solution added in #22221 is incomplete.
    I don't see how things could work properly when managedLedgerAddEntryTimeoutSeconds is enabled. We can continue to discuss that on the new GitHub issue.

  29. dao-jun commented on Jun 25, 2025

    @dao-jun
    Member

    @lhotari I created a new issue and I will reply you there
    #24464

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions