fix(db): skip repeated passive before truncate#1347
Draft
corylanou wants to merge 2 commits into
Draft
Conversation
PR Build Metrics✅ All clear — no issues detected
Binary Size
Dependency ChangesNo dependency changes. govulncheck OutputBuild Info
History (2 previous)
🤖 Updated on each push. |
f2851b1 to
9566a1a
Compare
Do not treat checkpoint-lock skips as failed passive attempts. Clear the no-progress state whenever a WAL restart is detected, including checkpoints outside the emergency path.
014b9fc to
c0a1926
Compare
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.
Description
Persist a no-progress result from the emergency PASSIVE checkpoint attempt. While the logical WAL remains above the truncate threshold, later sync cycles go directly to TRUNCATE; the PASSIVE attempt is re-armed when the threshold clears or the WAL restarts.
This is intentionally limited to emergency checkpoint selection and its regression coverage. It is stacked on #1322 and targets
issue-1310-disk-full-staging-wedge.Motivation and Context
A pinned reader reproduced the issue: before the fix, two blocked sync cycles executed two PASSIVE checkpoints and two TRUNCATE checkpoints. After the fix, those same cycles execute one PASSIVE checkpoint and two TRUNCATE checkpoints, avoiding the repeated write-lock barrier, sequence bump, and bookkeeping L0 file while still attempting TRUNCATE every cycle.
The regression test also verifies that PASSIVE is retried after the truncate threshold clears and after the WAL restarts.
Fixes #1339
How Has This Been Tested?
go test -race . -run 'TestDB_(SyncTruncateCheckpointFiresDuringChunkedCatchUp|CheckpointPassiveRestartSkipsTruncate|CheckpointTruncateSkipsRepeatedPassiveWithoutProgress)$' -count=5go test -race -v ./...pre-commit run --all-filesgo build -o bin/litestream ./cmd/litestreamgo build -o bin/litestream-test ./cmd/litestream-testTestLTXBehaviorsoak profiles passed their behavioral, restore, and integrity checks.go test -tags 'integration,soak' -run '^TestLTXBehavior_NoExcessiveSnapshots$' -short -v -timeout 5m ./tests/integration/Types of changes
Checklist
go fmt,go vet)go test ./...)