Skip to content

[client] Release KvBatchScanner response buffers - #4364

Open
fxbing wants to merge 1 commit into
apache:mainfrom
fxbing:fix/20260916-kv-batch-scanner-bytebuf-leak
Open

fxbing wants to merge 1 commit into
apache:mainfrom
fxbing:fix/20260916-kv-batch-scanner-bytebuf-leak

Conversation

@fxbing

@fxbing fxbing commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Purpose

Closes #4363

Fix network buffer leaks in no-limit primary-key batch scans, including when results are fully consumed and the scanner is closed normally.

Related to #3003, which addresses LimitBatchScanner.

Brief change log

  • Release consumed ScanKvResponse buffers in finally, covering data, empty, error, and parsing-failure paths.
  • Replace cancellation of the pending future with a completion callback that releases completed or late responses.
  • Release close-scanner responses.

getRecords() copies the data, so returned rows remain valid after the response buffer is released.

Tests

Added regression coverage using real serialized and parsed responses, with explicit reference-count assertions, row reads after buffer release, and exactly-once release verification.

The four minimal reproductions fail before the fix (refCnt == 1) and pass afterward (refCnt == 0).

Passed locally:

  • KvBatchScannerTest: 28 tests.
  • CompositeBatchScannerTest: 5 tests.
  • KvSnapshotAndLogBatchScannerTest: 1 test.
  • TableKvScanITCase: 9 tests.
  • Checkstyle, Spotless, and license validation.

The full repository suite was not run. Other previously observed CI leak warnings have not been individually attributed.

API and Format

No public API or storage-format changes.

Documentation

No user-facing documentation changes required.

Generative AI disclosure

AI-assisted implementation and review using Codex, Claude, and GLM.

Release consumed ScanKv responses and hand unconsumed responses to close callbacks.
Release close-scanner acknowledgements and preserve late-response delivery.
Add ByteBuf ownership regression tests for consumption, errors, and scanner closure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] KvBatchScanner leaks response buffers even after normal close

1 participant