Skip to content

memdb: count a key put again in a time block once - #50

Merged
mumtaz6 merged 1 commit into
masterfrom
memdb-size
Oct 4, 2026
Merged

mumtaz6 merged 1 commit into
masterfrom
memdb-size

Conversation

@mumtaz6

@mumtaz6 mumtaz6 commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

memdb: block.put counted every put that wasn't a delete, but a key put again in the same time block replaces its record.

Effect: Size grew with every rewrite of a record, such as a security state or a session, and stayed too high after a delete. A store looked bigger than it was, and a copy of it, which puts each key once, looked smaller than its source. Recovery replays puts through block.put, so it now counts each key once too.

Test: TestSizeCountsAKeyOnce. Without the fix, Size is 3 after putting one key three times and deleting it, where 1 is expected. The memdb and root package tests pass.

Independent of the backup PRs, which count memdb records as they copy them, so they don't depend on Size.

🤖 Generated with Claude Code

block.put counted every put that wasn't a delete, though a key put again
in the same block replaces its record. So Size, which sums the counts,
grew with every rewrite of a record (a security state, a session), and
stayed too high after a delete: a store looked bigger than it was, and a
copy of it, which puts each key once, smaller than its source. Recovery
replays puts through block.put, and counts once too now.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mumtaz6
mumtaz6 merged commit ba1ba67 into master Oct 4, 2026
6 checks passed
@mumtaz6
mumtaz6 deleted the memdb-size branch October 6, 2026 09:37
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