Skip to content

fix(db): skip repeated passive before truncate#1347

Draft
corylanou wants to merge 2 commits into
issue-1310-disk-full-staging-wedgefrom
issue-1339-skip-the-passive-first-attempt-in-the-emergency-truncate-pat
Draft

fix(db): skip repeated passive before truncate#1347
corylanou wants to merge 2 commits into
issue-1310-disk-full-staging-wedgefrom
issue-1339-skip-the-passive-first-attempt-in-the-emergency-truncate-pat

Conversation

@corylanou

Copy link
Copy Markdown
Collaborator

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=5
  • go test -race -v ./...
  • pre-commit run --all-files
  • go build -o bin/litestream ./cmd/litestream
  • go build -o bin/litestream-test ./cmd/litestream-test
  • All low-volume, high-volume, and burst-volume TestLTXBehavior soak 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project (go fmt, go vet)
  • I have tested my changes (go test ./...)
  • I have updated the documentation accordingly (if needed)

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Build Metrics

All clear — no issues detected

Check Status Summary
Binary size 36.98 MB (0.0 KB / 0.00%)
Dependencies No changes
Vulnerabilities None detected
Go toolchain 1.25.12 (latest)
Module graph 1240 edges (0)

Binary Size

Size Change
Base (9566a1a) 36.98 MB
PR (7b3024d) 36.98 MB 0.0 KB (0.00%)

Dependency Changes

No dependency changes.

govulncheck Output

=== Symbol Results ===

No vulnerabilities found.

Your code is affected by 0 vulnerabilities.
This scan also found 0 vulnerabilities in packages you import and 1
vulnerability in modules you require, but your code doesn't appear to call these
vulnerabilities.
Use '-show verbose' for more details.

Build Info

Metric Value
Build time 40s
Go version go1.25.12
Commit 7b3024d

History (2 previous)

Commit Updated Status Summary
71b259e 2026-07-16 15:08 UTC 36.98 MB (0.0 KB / 0.00%)
722bbb8 2026-07-10 00:18 UTC 36.98 MB (0.0 KB / 0.00%)

🤖 Updated on each push.

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.
@corylanou corylanou force-pushed the issue-1339-skip-the-passive-first-attempt-in-the-emergency-truncate-pat branch from 014b9fc to c0a1926 Compare July 16, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants