Fix eviction queue purge correctness#51
Open
krleonid wants to merge 9 commits into
Open
Conversation
…ue churn Three related bugs in the buffer pool's eviction queue purge path caused dead nodes to accumulate, alive but pinned nodes to be lost, and the multi-iteration purge loop to make no real progress. 1. Dead increment skipped when buffer was already null 2. Pinned/current nodes were classified as dead during purge 3. Multi-iteration purge churned the purge thread's own moodycamel sub-queue Also adds regression tests and a concurrent stress test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…eue churn Replace the alive_nodes_to_reenqueue vector approach with moodycamel consumer/producer tokens. The consumer token progresses sequentially through sub-queues, while alive nodes are re-enqueued via a dedicated producer token whose sub-queue sits behind the consumer position. This prevents re-processing the same alive nodes on subsequent iterations without starving the eviction path (nodes stay in the queue, visible to EvictBlocks). Also adds background_queue_purge setting and fixes memory_limit syntax for v1.5-stable compatibility in the stress test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…in test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
EtgarDev
reviewed
May 17, 2026
| D_ASSERT(!GetBuffer() || GetBuffer()->GetBufferType() == GetBufferType()); | ||
| if (GetBuffer() && GetBufferType() != FileBufferType::TINY_BUFFER) { | ||
| // Kill the latest version in the eviction queue. | ||
| if (EverInEvictionQueue() && GetBufferType() != FileBufferType::TINY_BUFFER) { |
EtgarDev
reviewed
May 17, 2026
| return shared_memory_p; | ||
| } | ||
|
|
||
| bool BufferEvictionNode::IsDeadNode(idx_t debug_sleep_micros) { |
There was a problem hiding this comment.
do we need this debugging logic in the code?
…rInEvictionQueue The ~BlockMemory destructor used a sticky flag (ever_in_eviction_queue) to decide whether to call IncrementDeadNodes. After eviction via IterateUnloadableBlocks, the queue entry is consumed (dequeued) and eviction_seq_num is reset to 0 — but the flag remained true, causing IncrementDeadNodes for a non-existent entry. In out-of-core workloads this inflated total_dead_nodes unboundedly, making purge hold purge_lock for excessive iterations and blocking eviction threads under memory pressure. Fix: check GetEvictionSequenceNumber() > 0 — true iff there is a live queue entry (reset to 0 on Unload). Remove the now-unused ever_in_eviction_queue field and MarkAddedToEvictionQueue(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The move-assignment operator was missing the UpdateUsedMemory call to release the old reservation's bytes, causing the pool to over-count used memory and trigger premature OOM on spill-to-disk workloads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Persistent segments are resized to block_size during checkpoint, so passing them as the size hint for a new transient segment is misleading. Pass nullptr instead to start fresh when appending after a persistent segment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… updates Previously, each UpdateInfo for the root node allocated space for STANDARD_VECTOR_SIZE entries regardless of how many rows were actually updated. For workloads with many sparse updates across different vectors (e.g., 70K attached databases with scattered writes), this caused massive memory waste — up to 98KB per updated vector with 16K vector size. This change introduces compact allocation: the root UpdateInfo starts with capacity rounded up to the next power of two (minimum 8), and re-allocates with doubled capacity when more rows in the same vector are subsequently updated. For single-row-per-vector updates, this reduces memory from ~98KB to ~168 bytes per allocation (586x reduction). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
ever_in_eviction_queueflag for accurate dead-node accountingTest plan
🤖 Generated with Claude Code