Repository navigation
[Bug] Recover from invalid and failed exported log snapshots - #32853
Conversation
Validate export candidates before import so a damaged newer image can be removed and an older safe image used. Reconcile completed worker failures and retry exports after transient filesystem errors. Update to the merged Dragonboat export error release.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Queue requested — the merge queue status continues in this comment ↓. |
Treat missing and malformed exported metadata or image headers as invalid candidates so truncation can fall back to an older valid export. Cover the regular tick and TN replay watermark across five corruption types.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 1242496003eef1e29c96ced8513a1935fb3c69b1
Assessment: request_changes
The patch reuses Dragonboat’s export worker and preserves the TN replay check when falling back to an older snapshot. The previously reported restart fence and tombstone sync regressions pass. Invalid-candidate eviction can still strand files, and two snapshot filesystem error paths still panic.
Model: gpt-6.2-sol / xhigh
Session: 01a1f0a0-5126-78f3-9ab8-ef4e87f2f119 · slot 0 · generation 3
-
P2
pkg/logservice/snapshot.go:223: Deleting a confirmed invalid export removes its metadata and then returns an I/O error. The service restarts before cleanup completes.
Impact: Startup drops the directory from its inventory and leaves the corrupt image on disk indefinitely. The image still consumes disk space and its directory can block another export at the same index.
Evidence: The restart probe imported snapshot 14 and confirmed that the image for snapshot 24 remained with zero tracked exports. DropInvalid uses recursive deletion, while startup skips unflagged directories with missing metadata. Reuse the existing durable tombstone cleanup for invalid-candidate eviction and the analogous post-import cleanup reported in #32842. See invalid-eviction-confirmed.jsonl. -
P2
go.mod:303: An export finds an existing final directory at its Raft index, then hits an I/O error while removing the rejected export’s temporary directory.
Impact: The Dragonboat worker panics and terminates LogService before the truncation loop can receive an error or retry.
Evidence: The ordinary truncation tick reproduced the panic in the pinned dependency’s MustRemoveTempDir call from node.doSave. The worker’s new error handler only sees returned errors. Use an export cleanup path in Dragonboat that returns the filesystem error to the worker. See export-abort.jsonl. -
P2
pkg/logservice/store.go:696: During retained-replica startup, the reconciliation directory scan succeeds and the subsequent snapshot inventory scan returns EIO.
Impact: LogService exits through a panic instead of returning the startup error. This is the retained-replica failure documented in #32836, which the PR marks fixed.
Evidence: The startup probe reproduced the panic on the second directory listing. Both voting and nonvoting start paths still panic on snapshotMgr.Init errors, as they did in the base revision. Return the error through the existing startup paths, or narrow the issue closure and track this case separately. See startup-list.jsonl.
Validation:
-
Verified the frozen patch, whitespace, runtime preflight, retained native build inputs, and both pinned Dragonboat checksums. The V2 snapshot writer and format match.
-
Twenty-four focused LogService test functions passed through the supplied executor, covering corrupt export fallback, TN replay safety, export retry, replica restart, and parent-directory sync.
-
Three isolated fault-injection probes reproduced the findings. Commands, terminal receipts, and logs are indexed in validation-evidence.json. All 11 discussion entries are recorded in discussion-assessment.json.
Limitations:
-
The fault probes used a single local replica and injected filesystem errors.
-
Full-package race results were author-reported. The independent run was focused, and the frozen upgrade CI jobs were skipped.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes: a transient cleanup rename error after a successful import can leave the live shard unable to compact its WAL again.
P2 — Retry canonical snapshots left behind when post-import rename fails (pkg/logservice/truncation.go:399, pkg/logservice/snapshot.go:181)
importSnapshot now advances truncatedLsn immediately after the Raft import and before snapshotMgr.Remove. If the first rename to .removing returns an I/O error, removeAt leaves the canonical snapshot in the inventory, but it does not mark any cleanup pending. On subsequent normal ticks, shouldDoImport declines that same snapshot because its index is already at the forwarded watermark, and nothing retries Remove for it. If the inventory has reached MaxExportedSnapshot, shouldDoExport also declines new exports, so later WAL cannot be compacted even after the filesystem recovers. This applies to the supported limit of 1 and also to the default limit when the inventory is full. The comment claiming a watermark-based residue purge is unreachable no longer holds for this error path.
I reproduced this against d438e90136fd using a real single-replica Raft store and a filesystem wrapper that returns EIO exactly once for the post-import rename. With MaxExportedSnapshot=1, the import advanced to index 14, then cleanup failed. After restoring the filesystem, appending more records, and running three ordinary truncation ticks, the inventory still held index 14 and the rename-attempt count was still 1. A restart is outside that observation; the demonstrated stall is in the running process.
Please make cleanup of entries at or below the successfully imported watermark retry through the ordinary tick (or record an equivalent durable/pending cleanup obligation), without re-importing an already compacted snapshot. Include a regression that injects failure before the rename, recovers storage, and verifies that subsequent ticks free the slot and can resume forward progress. Also update the stale assumption in the truncation-loop comment.
The latest revision addresses the three findings in the preceding review: invalid/post-import deletion now uses tombstones, the pinned Dragonboat returns temporary-directory removal errors, and both replica startup paths return inventory errors. I ran the corrupt-export fallback cases and the existing failed-export cleanup retry test successfully on this head, as well as the fault-injection probe above. The prior reviews' broader race evidence and current successful CI were considered; this is a focused independent run, not a full rerun of the package race suite.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes on the latest head. The previous post-import rename failure is fixed by retrying entries at or below the import watermark; the new TestTruncationRetriesPostImportRenameFailure passes on this revision. The earlier payload-corruption, tombstone cleanup, restart, and startup error findings also remain addressed in the code I inspected. One invalid-export path still prevents the promised fallback: when the entire tracked export directory is missing, candidate validation classifies it as invalid, but eviction tries to rename that already-missing path and returns ENOENT on every tick. See the inline P2 finding and exact-head probe below.
Validation: the author's post-import rename retry test, the existing corrupt-export fallback cases, and my isolated restart probe passed on this head. A temporary exact-head probe based on the existing fallback fixture removed the whole newer snapshot directory and ran three ordinary truncation ticks; each returned ENOENT, retained both inventory entries, kept the truncation watermark at 0, and never reached the older export. The local probe is outside the PR tree. Required Ubuntu UT and other CI jobs are still pending at review time, so CI is not yet fully green.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed the latest recovery change and the earlier snapshot export/import handling. The missing-directory case now removes an invalid candidate only after a second check confirms that its source is absent; other removal failures retain the candidate for retry. The repeated-tick regression exercises fallback to the older snapshot, and the ENOENT-while-source-exists case checks that a transient failure does not discard the candidate. I found no remaining blocker in the reviewed changes. Required CI is green on this head; for broader package and race coverage I relied on the author's reported runs and CI rather than rerunning the full suite locally.
🚫 Left the queue · pull request dequeued2 min in the queue, with no time running CI. So far
Reason Pull request #32853 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
To get back in the queue
Tick the box to put this pull request back in the merge queue (same as
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
Fixes #32842
Fixes #32836
What this PR does / why we need it:
.removingtombstones before deletion. Sync the parent directory on both initial cleanup and retries, so a partial deletion or crash remains recoverable.Validation
go mod verifyand matches the source used for earlier full-package validation.pkg/logservicetests pass (142.162s), full package race tests pass (152.021s), and CGo-configuredgo vet ./pkg/logservicepasses after merging upstreammain.go mod verifyand fullpkg/logservicetests passed (127.735s). Dragonboat Add top #23 passed focused ordinary and race tests.mainmerge, fullpkg/logservicetests pass (132.535s), the import/corrupt-export/rename-failure regressions pass 10 race-enabled repetitions, and CGo-configuredgo vet ./pkg/logservicepasses.pkg/logservicetests pass (128.629s), the new fallback and rename controls pass 10 race-enabled repetitions, andgo vet ./pkg/logservicepasses. Focused regressions also pass after merging the latest upstreammain; CI is pending on this head.