[server] Prevent WAL memory pool deadlocks - #4294
Open
platinumhamburg wants to merge 3 commits into
Open
platinumhamburg wants to merge 3 commits into
platinumhamburg wants to merge 3 commits into
Conversation
Track pages owned by each WAL allocation, reject requests exceeding the pool capacity, and abort a younger blocked allocation when holders cannot make progress. Release resources through batch cleanup so other writes can finish and aborted writes can retry.
platinumhamburg
force-pushed
the
fix-wal-memory-allocation
branch
from
September 11, 2026 12:37
6105fa8 to
80cbdef
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical page-ownership validation and moderate initialization-cleanup issues remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds scoped WAL memory allocations and deadlock recovery to prevent KV writes from stalling when the shared pool is exhausted.
Changes:
- Adds allocation ownership, lifecycle cleanup, and deadlock victim handling.
- Integrates scoped allocations into WAL writes.
- Adds regression tests for exhaustion, contention, rollback, and retries.
Review findings:
- Critical (1 vote):
MemoryAllocation.javamust validate that all bulk-returned pages belong to the allocation. - Moderate (1 vote):
ArrowWalBuilder.javamust release pages acquired before builder construction fails.
File summaries
| File | Description |
|---|---|
fluss-server/src/test/java/org/apache/fluss/server/kv/KvTabletWalMemoryTest.java |
Tests WAL exhaustion, rollback, contention, and retry correctness. |
fluss-server/src/main/java/org/apache/fluss/server/kv/wal/ArrowWalBuilder.java |
Handles Arrow writer initialization cleanup. |
fluss-server/src/main/java/org/apache/fluss/server/kv/KvWriteProcessor.java |
Applies scoped memory allocation to WAL writes. |
fluss-common/src/test/java/org/apache/fluss/memory/MemoryAllocationTest.java |
Tests allocation behavior and recovery. |
fluss-common/src/main/java/org/apache/fluss/memory/MemorySegmentPool.java |
Exposes scoped allocation creation. |
fluss-common/src/main/java/org/apache/fluss/memory/MemoryAllocation.java |
Tracks page ownership and cleanup. |
fluss-common/src/main/java/org/apache/fluss/memory/LazyMemorySegmentPool.java |
Detects and resolves allocation deadlocks. |
Review details
Suppressed comments (1)
fluss-server/src/main/java/org/apache/fluss/server/kv/wal/ArrowWalBuilder.java:47
- If
ManagedPagedOutputViewis created successfully butMemoryLogRecordsArrowBuilder.builder(...)then throws, this catch only recycles theArrowWriter; the initial page already acquired byoutputViewis leaked because construction never returns and callers cannot invokedeallocate(). ReleaseoutputView.allocatedPooledSegments()in this failure path as well, while handling the case whereoutputViewcreation itself failed.
} catch (Throwable t) {
writer.close();
throw t;
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
platinumhamburg
force-pushed
the
fix-wal-memory-allocation
branch
from
September 14, 2026 06:50
c88afaa to
746cdcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #4290
Brief change log
Tests
API and Format
Documentation