Skip to content

fix(replica): snapshot missing local L0 gaps - #1463

Draft
corylanou wants to merge 1 commit into
issue-1457-gap-heal-upload-only-missingfrom
issue-1458-local-l0-missing-snapshot-fallback
Draft

fix(replica): snapshot missing local L0 gaps#1463
corylanou wants to merge 1 commit into
issue-1457-gap-heal-upload-only-missingfrom
issue-1458-local-l0-missing-snapshot-fallback

Conversation

@corylanou

Copy link
Copy Markdown
Collaborator

Description

When L0 gap healing finds that the missing remote range is also absent locally, force a snapshot at the current database position and advance the replica position to the snapshot TXID. Position recalculation recognizes a snapshot that covers the gap, so later compaction invalidations do not force duplicate snapshots.

Latest restore planning starts from the forced snapshot and does not select the gapped L0 history below it. Other local-open errors and backend write errors retain their existing failure behavior.

This PR stacks on #1462, which stacks on #1155. Its base must remain issue-1457-gap-heal-upload-only-missing until the stack lands.

Motivation and Context

The regression test reproduced the failure before the fix: deleting a two-TXID range from remote L0 and its matching local files caused Replica.Sync to fail at the first local open with no such file or directory. Position cleanup then made every retry repeat the same failure.

The fallback is limited to os.IsNotExist from the expected local L0 path while a later remote L0 file proves an interior gap. It emits a WARN with the full gap range, creates one current-position snapshot, and resumes replication above it.

Fixes #1458

Related: #1462, #1155

How Has This Been Tested?

  • TDD regression verified the missing local L0 open failed before the production change.
  • GOTOOLCHAIN=go1.25.13 go test -race -run "^(TestReplica_InvalidatePos_(HealsL0Gap|MissingLocalL0FallsBackToSnapshot)|TestDB_Compact/L0GapHealsViaReplica|TestReplica_CalcRestorePlan)$" -count=1 .
  • GOTOOLCHAIN=go1.25.13 go test -race ./...
  • GOTOOLCHAIN=go1.25.13 pre-commit run --all-files
  • LOG_LEVEL=DEBUG GOTOOLCHAIN=go1.25.13 go test -tags "integration,soak" -run "^TestLTXBehavior$" -short -v -timeout 15m ./tests/integration/
  • The regression restores a real SQLite database after fallback, verifies its rows, confirms a snapshot-only restore plan, invalidates the position again without another snapshot, and verifies a subsequent transaction replicates.
  • Low-, high-, and burst-volume behavioral profiles passed all applicable assertions and restore integrity checks.

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)

Gap healing cannot re-upload a remote L0 gap after its local source files
are removed. Force a current-position snapshot for that specific missing
local-open error and retain the snapshot as a recalculation baseline so
replication can continue without repeated fallbacks.

The snapshot lets latest restore bypass the gapped lower-level history.

Fixes #1458
@github-actions

Copy link
Copy Markdown

PR Build Metrics

⚠️ Attention needed — Go toolchain outdated (1.25.13 → 1.25.14)

Check Status Summary
Binary size 37.17 MB (0.0 KB / 0.00%)
Dependencies No changes
Vulnerabilities None detected
Go toolchain ⚠️ 1.25.13 → 1.25.14 available
Module graph 1230 edges (0)

Binary Size

Size Change
Base (b53e3ea) 37.17 MB
PR (6aa33c0) 37.17 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 1 vulnerability in packages you import and 3
vulnerabilities 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 31s
Go version go1.25.13
Commit 6aa33c0

🤖 Updated on each push.

@github-actions github-actions Bot added the metrics: go-update Go toolchain has a newer patch release label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics: go-update Go toolchain has a newer patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant