Skip to content

Fix page refcount leak in RangeIterator.TrySeek - #25

Merged
hadashiA merged 1 commit into
mainfrom
fix-range-iterator-refcount-leak
Jul 11, 2026
Merged

Fix page refcount leak in RangeIterator.TrySeek#25
hadashiA merged 1 commit into
mainfrom
fix-range-iterator-refcount-leak

Conversation

@hadashiA

Copy link
Copy Markdown
Owner

Problem

RangeIterator.TrySeek / TrySeekAsync call TreeWalker.TrySearch, which returns the found leaf page with a newly retained reference. When seeking to a key on the page the iterator already holds (currentPage == page), that new reference was neither stored nor released, so the page's refcount grew by one on every such seek. A leaked refcount prevents the page buffer from ever being disposed after cache eviction.

Fix

Release the duplicate reference when the seek lands on the page the iterator already holds.

Test

Added a regression test that seeks the same key repeatedly and asserts the refcount stays balanced (1 held by the page cache + 1 by the iterator). It fails with refcount=4 before this fix.

🤖 Generated with Claude Code

@hadashiA
hadashiA merged commit ee5e5fa into main Jul 11, 2026
1 check passed
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.

1 participant