The ledger row for the identity rule this change keeps: one name, one
layout identity; no directory but the record's holds a live HEAD. Its
scope: only a refused restore's record (never left the creation phase)
is removed; a served volume's deleted name is never created again. A
guard test proves that name is refused for a plain create, the same
restore request and a new one, with no record and no filer write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the issue number from the shutdown test comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: end the filer walk when the consumer stopped following
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: end the follow when a retried event reports a stop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: check the subscriber is gone before the late event can end it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: never retry a filer call whose consumer stopped following
The walk already stopped on pb.ErrStopFollowing, but RetryOnError still
classified the wrapped error by its cause, so a transport-looking cause
reran the whole filer walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: keep the cursor behind an event whose retry the follow ended
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: close the meta cache after the follow-cancel test joins it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(mount): reproduce the #5289 mount abort on a late metadata event
A metadata event that arrives after metaCache.Shutdown() reaches
glog.Fatalf through FatalOnError, so the mount dumps every goroutine and
exits 255 instead of unmounting cleanly — the signature reported in
issue #5289, still reachable on current master.
The subscriber has no way to stop: its context is rooted at
context.Background() and util.RetryUntil always retries, while unmount
closes the cache underneath it.
glog.Fatalf cannot be intercepted from another package (glog's
logExitFunc is unexported), so the reproduction runs the mount in a child
process and reads its exit code.
* mount,pb: stop following metadata when the cache closes
The mount follows metadata with FatalOnError, so an event that arrives
after metaCache.Shutdown() — which unmount guarantees, since the
subscriber is never stopped — was logged as a fatal and aborted the
process with a goroutine dump.
Report a closed cache as pb.ErrStopFollowing, a class the follow loop
ends on instead of routing through the per-event error modes. It is not
a failed event but the end of the subscription: no later event can land
either. SubscribeMetaEvents then leaves its retry loop rather than
reconnecting onto a store that no longer exists.
Also export the meta_cache sentinel as ErrClosed so consumers can tell a
closed cache from a storage failure.
* mount: end the metadata follow before closing the meta cache
The subscription goroutine had no owner: its context was rooted at
context.Background() and util.RetryUntil retried forever, while unmount
closed the cache underneath it. Every unmount left a window in which a
filer event landed on a closed store, and the mount survived it only
because the previous commit demoted that error.
Give the follow a context the mount owns, and stop it — cancel, then
join — before metaCache.Shutdown() in both teardown paths. MetadataFollowOption
takes a ParentContext so cancelling the caller ends the stream, which is
the ordering the filer already got in #11363 and #11663; the mount had no
equivalent.
Verified that the new assertion catches the ordering on its own: making
stopMetadataFollow a no-op fails it with the subscriber still running,
even with the fatal path already demoted.
* mount,pb: make a cancelled follow a stop, and cover the new seams
Review findings on the previous commits:
Cancelling the follow context surfaced as a bare gRPC Canceled, which
matched neither terminal condition, so every clean unmount logged an
ERROR, ran the retry callback — which wipes every cached listing on the
assumption that events were missed — and slept a second before the loop
stopped itself. Test the context instead of the error text.
Also assert the two new weed/pb seams where they are defined rather than
only through a mount exit code: ErrStopFollowing ends the stream without
reaching the per-event error modes and leaves the cursor behind the
event, and a cancelled ParentContext ends the stream. Publishing the
cancel handle and bumping the WaitGroup happen under one lock, so a
start racing a stop cannot let the join report success too early.
All four new tests were mutation-checked: dropping the early return,
ignoring ParentContext, removing stopMetadataFollow from ClearCacheDir,
and making stopMetadataFollow a no-op each fail their own test.
---------
Co-authored-by: whitefox <whitefox@mayflower.work>
Review follow-up. A fetch answered with anything but 200 (a 404 is
ordinary while a restore target hydrates) drains its body like a delete,
so its connection is reused. Close also closes the blob client's idle
connections, now that the client owns its transport. The idle pool size
is stated as a retention budget, not a limit on requests in flight.
Tests: 404 fetches reuse one connection; Close releases the idle
connection while the server stays up; the upload test forces waves of
eight overlapping requests and carries a default-pool control.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: flag help names the 503 an upload gets after the wait
The filer answers an upload that found no slot within
-inflightUploadDataTimeout with 503 and Retry-After: 1, not 429.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: a restart after a Yandex token refresh may need a new token
The client keeps the refresh token Yandex returns in memory only, and
Yandex does not say whether the stored one survives the rotation, so the
doc no longer promises that a restart keeps working.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read the entry path once per write
A create looks the path up to decide what it makes of the entry: the inode and
crtime to keep, the chunks the write leaves behind, the old side of the metadata
event. The store wrapper looked the same path up again, in
handleUpdateToHardLinks, to learn the hard link the name carried before. Both
reads happen under the same per-path lock, a moment apart, and for a file written
without a hard link the second one decides nothing at all: its result is
discarded. An overwrite pays for it twice over, because that read decodes the row
being replaced -- gunzip included above CountEntryChunksForGzip -- and it is the
row the create already holds.
Neither read shows up as a second find in the store metrics: the wrapper's goes
to the actual store, and FilerStoreCounter counts only FilerStoreWrapper.FindEntry.
The wrapper now takes the caller's word. InsertEntryReplaces and
UpdateEntryReplaces carry the entry a caller read to handleUpdateToHardLinks,
which keeps to it instead of reading the path again. An insert whose lookup found
the path empty goes the way #13006 opened with InsertEntryKnownAbsent, which
rename alone used.
Which word may be taken is the delicate part, so Filer.findEntry reports whether
its answer is what the store holds at the path:
- a lazy fetch from a remote mount serves an object the store does not have and
writes nothing to it, so it says nothing about the row there;
- inside a store transaction a lookup hides an expired S3 entry whose row the
transaction keeps until the commit, and a write replacing it still owes that
entry its hard link -- which is why FindEntryForOverwrite exists;
- where the expiry check deleted the row, the delete dropped its link already, so
an answer of "empty" is honest.
The write also reads the path itself whenever there is a link to take off, for
two reasons. A file with a hard link has its record changed again when the store
refused a commit (changeLinkRecord runs its change up to linkRecordAttempts
times), and each run must judge the name as the store holds it by then. And a row
that carries a link is the row whose link this write drops: plain creates are not
routed to the write owner, so another filer may have replaced the same name
already and dropped that link, and dropping it twice deletes the record under the
file's remaining names. What is trusted is the case with nothing to decide --
no link on either side -- which is an ordinary file write, since a mount makes a
link id only when a file is linked or copied.
The HTTP append path read the entry three times: once to merge with it, once to
prove it had not changed while the chunks were uploaded, and once in the create.
The create takes the recheck's entry now.
A 20-chunk entry on leveldb2 goes from 343 to 286 allocs/op and from 44.6 to
38.3 KiB/op per overwrite, the difference being the decode of the replaced row.
Where the store is reached over the network, the read saved is a round trip per
write.
Tests count the reads one write makes at the store, pin that a dropped link is
dropped once against a row another filer has already replaced, and keep the
create using the entry it is handed. #9645's own guard expected the create's
lookup to be what separates passing existing from passing nil; both are one read
now, so it requires one read either way and checks the crtime came from the entry
passed in.
Issue #5067.
Review of the first version caught one more case. The known-absent shortcut must
not take an entry that carries a link: InsertEntryKnownAbsent counts the name as
joining without reading it, so another filer storing that name for the same link
between this lookup and the write would have it counted twice, and the count
would run one above the names. The regular insert reads the name inside the
change of the record. CreateEntry and ReplaceFileForRename keep the write's own
read for a linked entry; TestNewLinkedNameStillReadsThePath pins it.
* filer: drop issue numbers from the write-read test comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: say a plain-over-plain write can miss a link stored after the read
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: whitefox <whitefox@mayflower.work>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The filer walk told the caller's expiry apart from a filer failure by
ctx.Err() alone. A server-side DeadlineExceeded can reach the client
before the context's own timer runs, so the walk recorded a failure
against each filer and moved on with no budget left, the same race
LookupVolumeIds already guards against.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: retain released lock version watermarks
* fix(lock_manager): scope release records to lease identities
Keep a stable acquisition ID in opaque renewal tokens so release history cannot reject a valid lease from a different primary when generation counters overlap. Preserve earlier releases across new acquisitions and ownership eviction.
Carry the maximum lease expiry with releases, prevent renewals from shortening that bound, reject expired inserts, and reclaim release records after expiry. Track replication and handoff before sending copies so local-only leases need no release records.
Add regressions for fresh-primary failover, equal and lower generation counters, reordered releases and renewals, bounded retention, local-only workloads, ownership eviction, legacy release metadata, and gRPC release handling.
* lock_manager: name the release replay tests after the behavior they check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(lock_manager): serialize lease handoff with local mutations
Hold per-key mutation admission through a fresh lease snapshot, the transfer RPC, and source demotion or removal. A release that wins first suppresses the transfer; a release arriving during handoff waits and is forwarded to the new primary afterward.
Keep incoming replication outside the gate to avoid callback cycles. Retain source authority on transfer errors and apply transfer completion only to the lease that was sent.
Add real gRPC regressions for releases during both handoff branches and replay after release, plus coverage for fresh snapshots, transfer errors, unrelated keys, and replacement leases.
* fix(lock_manager): retry handoffs without retaining renewal authority
Deliver a source-held lease to the current owner before forwarding renewal or unlock. Freeze local authority before sending a transfer, including when the receiver may have committed despite an RPC error. Retry without requiring a membership change, with backoff and shutdown cancellation.
Recheck ownership after a background handoff and preserve the copy until the latest owner receives it. Replicate the effective installed expiry instead of a shorter transfer input.
Replace timing assumptions with a same-key admission contention hook. Cover pre-handoff releases, lost acknowledgements, retry cleanup, owner changes, and effective expiry. Document why identityless legacy releases cannot safely delete slash-format leases with overlapping generation counters.
* test(filer): set up DLM handoff before the peer lock transfer check
Ring-change transfers now go through Dlm.TransferFn, which
SetupDlmReplication installs; without it the lock stays pending on the
old filer and the peer-auth transfer test cannot see it move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(lock_manager): bound the handoff and unlock completion waits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(filer): give the handoff retry expiry subtest a one-second lease
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(lock_manager): serve lock and unlock here when a handoff ends with this node as primary
transferToOwnerLocked now returns the primary it observed after the
handoff. LockWithTimeout and Unlock redirected to the primary read before
the transfer, so a ring that moved back during the handoff sent the client
away from the node that holds the lease.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(lock_manager): bound the admission probes in the handoff tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(filer): keep the holder's renew token while its lock handoff is pending
A failed transfer RPC or a frozen lease answered the lock request with an
error and an empty RenewToken. The client treats that as a rejection and
drops its token, so it can no longer renew the lease once the handoff
completes. Report transfer failures as LockHandoffPending and echo the
caller's token for that error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): return lease expiry from Lock, Unlock and InsertLock
The DLM was the only production caller of these methods and used private
twins (lockWithExpiry, unlock, insertLock) to get the effective expiry.
Return it from the public methods instead and drop the twins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): share the copy acceptance checks between InsertLock and InsertBackupLock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): drive handoff tests through TransferLockToOwner
TransferLock and its helpers were only reachable from tests. Remove them
so the tests exercise the production handoff path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): share the routing and handoff prologue of LockWithTimeout and Unlock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Master <Master@node0.8m510.lpad-pg0.utah.cloudlab.us>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The writer census parses every production file and attributes each write
of ObjectsChecked to its receiver and method (only CASHead), with controls
for another method, a keyed literal and a multiple assignment. New
guards: a check passed in one session is not reused after an abort and a
new session at the same root; CommitPendingSnapshot looks up the root and
segments; the metadata-conflict retry looks up again without a passed
check and may reuse a passed check of the same pair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
blockvolume's chunk layer holds the LayoutRemote inside closeBoundRemote
and layoutBoundRemote, so its assertion for the commit check failed and
the lookups stayed inside the 2 s HEAD update. closeBoundRemote now
forwards CheckCommit with the same binding as CASHead; a remote without it
passes, and its CAS checks inside. Tests go through the provider's attach,
check every optional interface the chunk layer asserts against the
wrapped remote, and cover a pre-check that finds a chunk missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The commit's object check (every new chunk, segment and root written by
the session, unmarked) ran inside the one HEAD update, which the chunk
layer bounds at 2 s; the work grows with the changed chunks, so it capped
the volume size. The chunk layer now asks the remote to run that check
with the cut's context, just before the CAS; the CAS then skips the
lookups only for exactly the session and root that passed. Any other CAS
(another root, another session, the snapshot commit) runs them inside as
before. The session stays open between the two, so no cleaning can begin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resume command (now on its own line), the connect and disconnect
commands and the logs path quote the dir and NQN for a POSIX shell, so a
--dir with a space or a quote gives a line that runs as printed. Tests:
shQuote round-trips through a shell-word split; the printed resume line,
split as a shell splits it, reaches a spaced dir's recorded run, while
the unquoted line does not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run started with --bin records that directory (absolute) in mini.json;
--reuse loads the record before any binary lookup, so a bare --reuse
finds the same blockmaster and blockvolume, and a --bin that differs from
the record is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The planned hand-over ran across two machines on the release candidate (recorded in the measurements, and the lifecycle table's row updated); the forced move was tested with two server identities on one machine and restores from the last cut. v1.0.1 lists sw-block mini first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. weed mini always runs its admin server (-admin.ui=false
only hides the UI): its HTTP and worker gRPC ports are now set,
preflighted and shifted, and its legacy listener pair is off
(-admin.port.legacy=0); mini owns 13 ports. A fresh start records the
run's size, port shift, mode (its weed) and NQN in <dir>/mini.json;
--reuse starts that run again, refusing a flag that differs from the
record, a recorded weed that is gone, and a walstore run while a weed is
found (never a silent change of mode).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-up. weed mini gets -ip.bind=127.0.0.1 (its -ip alone is the
advertised address; the bind defaulted to 0.0.0.0), every listener's port
explicitly (master, volume and filer HTTP and gRPC), all preflighted and
moved by --port-shift, and its S3, WebDAV and admin UI off. --size refuses
an overflowing value. The dir is claimed by one exclusive mkdir (or must
exist with --reuse) and held by a lock for the run, before any write.
Startup and the layout id wait stop at once when any child dies.
Tests: the supported commands pinned value for value, with controls; a
busy weed port; port shift; one mini per dir; weed dying during startup;
the process tests register their bounded cleanup before any assertion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>