mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
cd0f60a2f0858c07ea202b00ebf8df19e65a10a2
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
96321141cc |
filer.sync: stop deleting versions on transient lookups and in-flight pointers (#13063)
* filer.sync: retry an update whose destination lookup failed transiently FilerSink.UpdateEntry reported every lookup error as a missing entry, so the replicator and filer.sync deleted the destination key and created it again. For a directory, a canceled or unavailable lookup removed it with everything under it. Only a real not-found now lets the caller recreate the key; other lookup errors are returned for retry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: leave a pointer to a recently minted version unrepaired When a versioned read finds a latest pointer whose version file is missing, the self-heal rescanned .versions and then either removed the directory (no version left) or rewrote the pointer to the newest version found. With filer.sync the directory and its pointer can arrive before the version file, so the heal acted on a version still in flight: the local directory removal replicated back and deleted the committed version on the source cluster, and a pointer repair would roll its latest pointer back. While the pointer names a version minted in the last ten minutes, the read now answers from the rescan without persisting anything, and the reconciler skips the key. After that window the heal works as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: retry a failed destination lookup before giving up on an update Returning a transient lookup error leaves the retry to the caller, and filer.replicate hands a failed event to the notification input instead of replaying it. Retry the lookup in place with the shared bounded backoff; a not-found still returns at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: count only the not-found sentinel as a missing destination LookupEntry already maps every miss to filer_pb.ErrNotFound, plain-text ones included. Matching the sentinel's text in any error also counted an Unavailable lookup carrying that text as a miss, which let the caller delete and recreate the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: requeue an in-flight versions pointer for after the grace window The reconciler dropped a key whose pointer named a version still in flight, so nothing revisited it once the window passed. Requeue it for one grace window without counting the skip as an attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: probe the latest version file before deferring an in-flight pointer A recent pointer whose version file is already present needs no repair; deferring it kept the key queued for the whole grace window and used up queue capacity. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: retry an in-flight versions pointer when its grace runs out The reconciler waited a full grace window after the deferral, so a pointer first seen near the end of its grace stayed unrepaired for almost twice as long. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: run the in-flight pointer grace from its local commit too The grace was measured from the version id's mint time on the origin cluster against the local clock, so a peer whose clock ran more than the grace ahead, or a filer.sync backlog longer than the grace, saw a just-synced pointer as stale and could remove or roll back the version. The .versions entry's commit time is stamped by the local filer when the pointer is stored, so it bounds the wait with the local clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: repair a pointerless .versions entry despite a recent commit The in-flight grace protects a pointer whose version file has not arrived yet. A .versions entry with no pointer names no such file, so a recent commit of it must not hold back the rebuild of its pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: hold a stale-pointer repair while the live entry is still in grace The heal checked the grace on the snapshot it took before the scan. A .versions entry stored again with the same pointer during the scan restarts the grace, so check it on the live entry the CAS is conditioned on before persisting the repair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: recheck the live grace before removing an empty .versions The empty-directory cleanup checked the grace on the pre-scan snapshot, so a pointer stored again during the scan could still have its .versions removed. Re-read the entry and leave it while its grace lasts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
79859fc21d |
feat(s3/versioning): grep-able heal logs + scan-anomaly diagnostics + audit cmd (#9468)
* feat(s3/versioning): grep-able heal logs + scan-anomaly diagnostics + audit cmd Three diagnostic additions on top of #9460, all aimed at making the next production incident faster to triage than the one we just spent hours on. 1. [versioning-heal] grep prefix on every heal-related log line, with a small fixed event vocabulary (produced / surfaced / healed / enqueue / drain / retry / gave_up / anomaly / clear_failed / heal_persist_failed / teardown_failed / queue_full). One grep gives operators a single event stream across the produce-to-drain lifecycle. 2. Escalate the "scanned N>0 entries but no valid latest" case in updateLatestVersionAfterDeletion from V(1) Infof to a Warning that names the orphan entries it saw. This is the listing-after-rm inconsistency signature that pinned down 259064a8's failure — it should not be invisible at default log levels. 3. New weed shell command `s3.versions.audit -prefix <path> [-v] [-heal]` that walks .versions/ directories under a prefix and reports the stranded population. With -heal it clears the latest-version pointer in place on stranded directories so subsequent reads return a clean NoSuchKey instead of replaying the 10-retry self-heal loop. * fix(s3/versioning): audit pagination, exclusive categories, ctx-aware retry Address PR review: 1. s3.versions.audit walked only the first 1024-entry page of each .versions/ directory, false-positiving "stranded" on large dirs. Loop until the page returns < 1024 entries, advancing startName. 2. clean and orphan-only categories double-counted when a directory had no pointer and at least one orphan: incremented both. Make them mutually exclusive so report totals sum to versionsDirs. 3. retryFilerOp's worst-case ~6.3s backoff was a bare time.Sleep, non-interruptible by ctx. A server shutdown / client disconnect would wait out the budget per in-flight delete. Thread ctx through deleteSpecificObjectVersion -> repointLatestBeforeDeletion / updateLatestVersionAfterDeletion -> retryFilerOp; backoff now uses a select{<-ctx.Done(), <-timer.C}. HTTP handlers pass r.Context(); gRPC lifecycle handlers pass the stream ctx. New test pins the behavior: cancelling ctx mid-backoff returns ctx.Err() in <500ms instead of blocking ~6.3s. * fix(s3/versioning): clearStale outcome + escape grep-able log fields Two coderabbit follow-ups: 1. Successful pointer clear should suppress `produced`. updateLatestVersionAfterDeletion's transient-rm fallback called clearStaleLatestVersionPointer best-effort, then unconditionally returned retryErr. The caller (deleteSpecificObjectVersion) saw the error and emitted `event=produced` + enqueued the reconciler, even though clearStaleLatestVersionPointer had just driven the pointer to consistency and the next reader would get NoSuchKey via the clean-miss path. Make clearStaleLatestVersionPointer return cleared bool; on success the caller returns nil so neither produced nor the reconciler enqueue fires. Concurrent-writer aborts, re-scan errors, and CAS mismatches still report false so genuinely stranded state keeps surfacing. 2. Escape user-controlled fields in heal log lines. versioningHealInfof / Warningf / Errorf interpolated raw bucket / key / filename / err text into a single-space-separated line. An S3 key (or error string from gRPC) containing whitespace, newlines, or `event=...` could split one event into multiple tokens and spoof fake fields downstream. Sanitize each arg in the helper: safe values pass through; anything with whitespace, quotes, control chars, or backslashes is replaced with its strconv.Quote form. No caller changes — the format strings remain unchanged. Tests pin both behaviors: sanitization table covers the field boundary cases; an end-to-end shape test confirms a key containing `event=spoof` stays inside a single quoted token. |