feat(wal): expose AllowEmpty config and add TruncateAll method#3049
Merged
wen-coding merged 2 commits intomainfrom Mar 11, 2026
Merged
feat(wal): expose AllowEmpty config and add TruncateAll method#3049wen-coding merged 2 commits intomainfrom
wen-coding merged 2 commits intomainfrom
Conversation
5447d4f to
1ef5869
Compare
Passes tidwall/wal's AllowEmpty option through the Config struct so callers can permit removing all entries from the log. Adds a TruncateAll() convenience method that empties the log in one call. This enables callers (e.g. autobahn persistence) to clear a WAL in-place instead of the heavier close-remove-reopen pattern. Made-with: Cursor
1ef5869 to
82877e8
Compare
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3049 +/- ##
==========================================
+ Coverage 58.33% 58.36% +0.02%
==========================================
Files 2079 2080 +1
Lines 171885 171733 -152
==========================================
- Hits 100268 100229 -39
+ Misses 62671 62577 -94
+ Partials 8946 8927 -19
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
5 tasks
yzang2019
approved these changes
Mar 11, 2026
cody-littley
approved these changes
Mar 11, 2026
wen-coding
added a commit
that referenced
this pull request
Mar 11, 2026
Now that sei-db/wal exposes AllowEmpty and TruncateAll (#3049), use them to clear a WAL in-place instead of the heavier close → remove directory → reopen pattern. - Enable AllowEmpty in WAL config. - Replace Reset() with TruncateAll() — single call, no dir removal. - Remove dir/codec fields from indexedWAL (only needed for reopen). - Eliminate firstIdx == 0 sentinel: Count() is now just nextIdx - firstIdx, empty when equal. Write() no longer needs the first-write bookkeeping branch. - Update openIndexedWAL to handle AllowEmpty's empty-log reporting (first > last) uniformly with the non-empty case. Made-with: Cursor
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
AllowEmpty booltowal.Configand passes it through totidwall/wal.Options, enabling callers to permit a fully empty log after truncation.TruncateAll()method toWAL[T]that removes all entries in a single call. No-ops on an already-empty log; returns an error ifAllowEmptyis not set.indexedWAL.Reset().Test plan
TestTruncateAll— writes entries, truncates all, verifies empty state, writes new entries, reopens and verifies continuityTestTruncateAllWithoutAllowEmpty— confirmsTruncateAllreturns an error whenAllowEmptyis not setTestTruncateAllOnEmptyLog— confirms no-op on an already-empty log