Skip to content

Add reproducer for BufferedChannel partial flush position drift - #4854

Draft
yangxianjungree wants to merge 1 commit into
apache:branch-4.16from
yangxianjungree:reproduce-bufferedchannel-partial-flush-corruption
Draft

Add reproducer for BufferedChannel partial flush position drift#4854
yangxianjungree wants to merge 1 commit into
apache:branch-4.16from
yangxianjungree:reproduce-bufferedchannel-partial-flush-corruption

Conversation

@yangxianjungree

@yangxianjungree yangxianjungree commented Jul 30, 2026

Copy link
Copy Markdown

Related issue

Motivation

This draft PR adds a focused reproducer for a BufferedChannel failure mode that can leave the logical BufferedChannel.position() behind the underlying FileChannel.position() after a partial flush failure.

The suspected production impact is stale entry locations and stale ledgersMapOffset being published by DefaultEntryLogger after the same channel is reused.

This is intentionally a reproducer-only draft, not the final fix.

Changes

  • Add a fault-injected PartialFailingFileChannel for tests.
  • Add a test showing BufferedChannel.position() can lag behind FileChannel.position() after a partial flush IOException.
  • Add a test showing BufferedLogChannel.appendLedgersMap() can write a stale ledgersMapOffset after that position drift.

Verification

Passed on release-4.16.7 baseline:

/home/stephen/github/java/pulsar/mvnw -pl bookkeeper-server -Dtest=BufferedChannelTest test
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

After rebasing onto current branch-4.16, running with -am did not reach tests in this local environment due to a Maven resource copy error in buildtools:

Failed to copy buildtools/src/main/resources/bookkeeper/checkstyle.xml ... Cannot allocate memory

Notes

This PR is intentionally scoped to the minimal unit-level reproducer. Higher-level cluster/E2E reproductions are kept separate from this PR to avoid adding environment-specific setup to the code review.

If maintainers agree with the failure model, the follow-up fix should likely make the main entrylog writer fail closed after non-recoverable write/flush/force failures, and prevent appendLedgersMap() from publishing a stale header offset.

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

Labels

None yet

1 participant