Repository navigation
fix: skip checkpoint on Drop when handle made no writes (issue #226) - #228
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Inner::drop() called do_checkpoint() unconditionally, which called force_dirty() + save() even for read-only handles — growing the file by 4 KB and invalidating other open handles. Add an early-return guard in do_checkpoint: skip when wal_entry_count is zero and pfs is not dirty. force_dirty() is still called when the guard passes, preserving the crash-recovery path where WAL entries are replayed into memory on open (wal_entry_count > 0, dirty == false). File locking already prevents multi-process exposure in the common case; this guard closes same-process double-opens and lock-bypass edge cases. Also fix PersistentFactStorage::new to use !is_new || page_count > 1 instead of page_count > 1 for the load condition. The old condition skipped load() for v5 files with only a header page (page_count == 1), so migrate_v5_to_v6 never ran for empty legacy databases. The new condition ensures FileBackend always loads existing files (is_new=false) while MemoryBackend (is_new always true) retains the page_count check.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
do_checkpoint: skipsforce_dirty()+save()whenwal_entry_count == 0 && !pfs.is_dirty(), preventing read-only handles from writing to the file onDrop.graph.lock) already covers the multi-process case; the guard closes same-process double-opens and lock-bypass edge casesPersistentFactStorage::new: the oldpage_count > 1load condition skipped migration for empty v5 files; replaced with!is_new_backend || page_count > 1using the pre-existingStorageBackend::is_new()methodTest Plan
test_readonly_handle_drop_does_not_modify_file— new regression test: opens a file-backed DB, writes + checkpoints, opens a second read-only handle, drops it, asserts file size is unchangedCloses #226
🤖 Generated with Claude Code