Repository navigation
fix(target/queue): Clean up dangling entries when meta file is missing - #901
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
readDiskQueue scanned only .meta files, so an entry whose .meta was removed but still had .header and .body left those two files on disk forever. They were never iterated and never cleaned up. Group all queue files by message ID first and treat an entry as dangling whenever any of the three files (.meta, .header, .body) is missing, then remove whatever is left. Complete entries are loaded as before. This enables the previously skipped NoMeta sub-test of TestQueueDelivery_DeserlizationCleanUp. Fixes foxcpp#209. Assisted-By: Claude Opus 4.8 (Claude Code) Signed-off-by: amalsaidov <amalsaidov@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #209.
What
readDiskQueuewalked only.metafiles to decide what to load and what to clean up. If a messages.metafile was gone but its.headerand.bodyfiles were still on disk, that entry was never looked at, so the two leftover files stayed in the queue directory forever.This rewrites the scan to group all queue files by message ID first. An entry is treated as dangling when any of its three files (
.meta,.header,.body) is missing, and whatever files remain are removed. Complete entries are loaded exactly as before.Why
Partial writes and partial removals can leave any one of the three files missing, not just
.headeror.body. The old meta-first scan could not recover from a missing.meta, so those orphans accumulated on disk.Tested
The
NoMetasub-test ofTestQueueDelivery_DeserlizationCleanUpcovered exactly this case but was skipped witht.Skip("Not implemented"). I removed the skip, and the fix makes it pass alongside the existingNoBodyandNoHeadersub-tests.go test ./internal/target/queue/...passes, including all threeDeserlizationCleanUpsub-testsgo vet ./internal/target/queue/...cleangofmt -lreports no changes on the touched filesgo build ./...builds cleanly for every package exceptcmd/maddy-pam-helper, which fails to compile its C code on my local macOS clang over an unrelated-Wstrict-prototypeswarning and is untouched by this changeAssisted-By: Claude Opus 4.8 (Claude Code)