mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
9da4e8656cdc79dfc896a2d8709c3b46d76b5b4e
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ec1032d642 |
filer.remote.sync: a source chunk gone for good no longer wedges the write-back (#13220)
* filer.remote.sync: a source chunk gone for good no longer wedges the write-back
An entry whose chunk the volume servers answer 404 for, even with
readDeleted=true, can never be uploaded: the bytes no longer exist in the
cluster. A volume lost with its disk leaves such entries behind (for
example a filer restored from a metadata backup onto a new volume server
while some chunks had not been written back yet). filer.remote.sync
retried the create event forever, every ~2 s, and since a failing event
holds the directory's processed watermark, no later change under the
mount was ever written back again. We hit this in production: one photo's
chunk answered 404 for hours and more than 11,000 later changes waited
behind it.
Now, once the filer confirms the entry is still the one the event
described (the existing supersession check), the upload ends with
errSourceGone when:
- every location answered 404 for sourceGoneGrace (5 min) over
sourceGoneMinAnswers (3) attempts in a row, or
- the master cannot locate the chunk's volume at all ("failed to locate",
the whole volume lost with its disk) for sourceGoneLookupGrace (30 min,
the filer deletion retry's figure for "volume not found").
It logs one ERROR line naming the path, the chunk's fid and the
destination, with a per-process count, and every caller treats the event
as handled so the offset advances. A path found gone is remembered with
its fid (bounded to 10,000), so later events of the same entry are skipped
at once; any other outcome (success, superseded, another error, a failed
supersession lookup) forgets it and starts the grace again, so a volume
server that has not loaded its volume yet, or a stale location, is not
mistaken for lost data.
Only the source decides. The upload body is wrapped in a recorder that
keeps the first error the chunk reader returned, because remote clients
wrap a body read failure in their own errors (the AWS SDK's RequestError
has no Unwrap). The recorder forwards ReadAt and Seek, so s3manager keeps
reading parts in place. A 404, 5xx, timeout or any other error from the
remote itself never reaches the recorder and keeps retrying as before.
A rename of an entry that was written back now deletes the old key only
after the new one is written: when the entry's local data is gone, the old
key keeps the last remote copy (logged) instead of being deleted before an
upload that can never succeed. The gateway's rename path, which deletes
first, does not acknowledge errSourceGone and keeps failing visibly.
util/http:
- GetAuthenticated (the encrypted chunk read) reports a 404 as ErrNotFound,
as the unencrypted read paths already do, with the same error text;
readEncryptedUrl wraps with %w instead of %v and treats a 404 as
retryable, like the plain read, so it tries the other locations.
- A chunk read is ErrNotFound only when no location of the pass failed
differently (NotFoundEverywhere): a 404 from one replica while another is
down, answers 5xx or is throttled does not mean the chunk is gone. This
is applied once in hedgedChunkPass (both RetriedFetchChunkData paths) and
in the manifest's retriedStreamFetchChunkData loop.
Tests:
- filer_remote_sync_gone_test.go: a plain and an encrypted chunk served 404
by a test volume server end in errSourceGone on the third attempt and are
counted once; a remote that answers 404 with readable chunks never does;
the tracker's grace, answer count, reset, fid change and remembered path;
the lookup-miss grace; ReaderAt kept by the recorder; a rename keeps the
old key when the entry is gone and deletes it after the write otherwise.
- TestGetAuthenticatedNotFound; TestRetriedFetchChunkDataNotFoundEverywhere
(plain direct, plain stream, encrypted; a 404 and a 503 in either order
is not ErrNotFound).
- Mutation checks: each fails with readEncryptedUrl back on %v, with the
write error classified instead of the body's read error, with
NotFoundEverywhere dropped from hedgedChunkPass, with the old key deleted
first, and with the recorder hiding ReadAt.
- go vet and go test of weed/util/http, weed/command, weed/filer and
weed/replication/... pass; weed/util/http also with -race.
* filer.remote.sync: renames keep the old key until the new one holds the content; gone is per entry; missing volumes opt-in
- A sighting is counted per entry content (the sorted chunk file ids),
not per failing chunk. An uploader reads the parts of a ReaderAt body in
parallel, so the chunk that fails first changes between attempts; keyed
on it, the grace restarted every time and a large file missing several
chunks held the offset forever. The tracker's `seen` map is bounded, and
the log names the first chunk "and N more" instead of every fid.
- On every rename the old key is deleted only after the new one holds the
content: also when the event's old entry carries no stamp (an upload
whose stamp a rename in between refused leaves an unstamped copy), and
in the superseded branch, where the old key is what uploadCurrentEntry
copies a remote-only entry from. uploadCurrentEntry reports when the
current entry's data is gone, and the old key stays then. A multipart or
system path whose old key cannot be deleted no longer skips the stamp.
- A volume the master cannot locate counts only with
-sourceGoneVolumeMissing=<duration> (default 0: never): a volume server
that is down or in maintenance looks the same, and an entry written off
is not retried. It suits a deployment whose master and volume server run
as one process.
- filer.remote.gateway's rename writes the new key first, deletes the old
object after, and keeps it when the source data is gone.
Tests: TestRetriedWriteFileSourceGoneAcrossChunks (two lost chunks read in
turn), TestSupersededRenameUploadsCurrentEntry "uncached between the check
and the upload" and "current entry's chunks gone: the old key stays",
TestRenameOfGoneEntryKeepsTheOldKey "old entry unstamped",
TestSourceGoneGraceFor (lookup miss off by default, on with the flag);
each fails with its fix undone. The test remote's DeleteFile removes the
object, as a real remote does.
* filer.remote.sync: evidence kinds apart, a gone entry counted once, the copy owns its source's cleanup; gateway keeps the old object on a superseded rename
- Lookup misses and 404s no longer share one run of sightings
(sightingKey = content + grace): with -sourceGoneVolumeMissing set, a few
minutes of "failed to locate" followed by one 404 met the 404 grace with
the misses' start and answers.
- observe reports whether this call found the entry gone; a replayed event
of an entry already gone is skipped without another log line or count.
- A superseded rename whose current entry is remote-only leaves the old key
to completeRemoteOnlyRename, which removes its source only while it is
the object the stamp describes; an unconditional delete after it could
remove a replacement.
- filer.remote.gateway: a superseded rename keeps the old object (logged)
instead of deleting it before the superseding event has written the new
key.
Tests: TestSourceGoneTrackerCountsOnceAndKeepsEvidenceApart,
TestSupersededRenameUploadsCurrentEntry "the old key replaced during the
copy"; each fails with its fix undone. The gateway change has no test of its
own (its rename path needs a reachable filer).
* filer.remote.sync: drop -sourceGoneVolumeMissing, a lookup miss keeps retrying
A volume the master cannot locate looks the same whether it was lost or
its server is down, so no default can write such an entry off safely, and
a flag for the one-process layout is not worth carrying. Only a 404 from
every location counts as gone; a lookup miss retries as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.gateway: a superseded rename settles its old object
A rename the filer has moved past kept the renamed-from object for good,
so every rename followed by a delete or a rewrite before the gateway
reached it left an orphan on the remote. Settle it the way
filer.remote.sync's uploadCurrentEntry does: copy from it when the entry
has become remote-only, and otherwise delete it, since it no longer holds
the entry's content.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.sync, filer.remote.gateway: a superseded rename copied from a later rename's source settles its own old key
When the entry became remote-only through another rename onto it, the copy
reads that rename's source and removes it, and nothing read or removed the
event's own old key any more. Delete it then, in both commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.gateway: reset cached remote clients after the superseded-rename test
A cached client kept the previous run's recorder, so the test failed under
-count above one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|