A stuck worker or a Close that never returns is a prompt test failure at
the child's bound, with a control that leaves a worker stuck; the Close
worker is joined on every path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- a page is stamped with the position its content includes, and the WAL
is synced through it before the page is written (the header's G too)
- the write's version bump and its applied position move under the
record's lock, together
- every fill holds its chunk (A or P on the page) until one mark round
makes the blocks durable in the store's bits; a later write keeps it
- an evict writes the page holding the chunk before the bits clear, also
on a retry that finds the chunk absent in memory
- the concurrency tests bound every wait and join their workers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- attach calls upgradeChunkRecord (presence saved first for a fresh attach)
instead of a second upgrade: log-only writes are seeded, a marked store
is rebuilt from its bits, never from engine state
- a page's position is clamped to the last completed WAL sync, and a
clean stop syncs the WAL before its final pages
- the attach refuses if the store closed while the upgrade had released
its barrier
- an evict clears the store's bits only after its absent page is durable;
fill-mark batches and evicts are serialized (markMu)
- a marked store never parses a leftover .chunkpresence
- a final page failure is the result of the layer's and the store's Close
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The HEAD entry's conditional keys are swb.layout.gen and swb.layout.volume,
written by LayoutStore.UpdateHead; the integration tests named in the
workspace design were replaced by the layout ones. The manifest perf test
no longer exists, so its command is removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: turn a panic in an RPC into an error
The broker's gRPC servers had no recovery, so a nil dereference in any
handler took the whole process down. Once the broker runs inside
another server, that process is the host.
* mq broker: guard the filer set
The master's peer updates and the startup peer listing both write the
filers map and currentFiler from different goroutines, and every filer
call reads currentFiler. Two writers on the map at startup is a fatal
concurrent map write.
* mq broker: answer balancer requests before the balancer lock exists
The balancer lock is created only once the broker has found a filer,
while the gRPC server already serves. Every lookup, configure, publish
and balance request dereferenced it, so an early request crashed the
broker. Those requests now answer Unavailable until a balancer is
elected.
Ownership is the lock's unexpired lease instead of the owner name it
last saw, so a broker whose renewals have failed stops acting as
balancer once the lease runs out. A lapsed lease can still name this
broker, so proxying refuses to send a request to itself.
* mq broker: follow the filer lock ring
The balancer lock client was seeded with the first filer the broker
found and never given the ring, so it kept dialing that filer after it
left and no broker could become balancer. The broker now takes the
master's lock ring updates the way S3 gateways and mounts do, and the
master sends brokers the ring snapshot on connect.
* mq: never pick a partition's leader as its follower
pickBrokersExcluded ignored the leader it was told to exclude. With one
broker, the first assignment repair made that broker its own follower,
and it then replicated every publish to itself.
A dead follower that has no replacement is now dropped and counted as a
change, so the cleared name is saved; picking the leader had hidden
that.
* mq: keep a partition's leader unless a live broker replaces it
The repair cleared the leader of any partition whose leader it did not
see, even with no broker to take over, and the cleared assignment was
cached. With an empty broker set every leader went blank. A leader now
moves only to a live broker, the only live follower is promoted when it
is all that is left, and a follower that names its own leader is
replaced.
* mq broker: only a settled balancer repairs assignments
Every broker repaired topic assignments on a cache miss, but only the
balancer tracks which brokers are live. Any other broker saw an empty
set, cleared the topic's leaders, and could not load a partition it
did own, so a publish to it dereferenced a nil partition.
A newly elected balancer also waits 30 seconds, long enough for every
broker to notice the change and reconnect, before it treats a broker
it has not heard from as gone.
* mq broker: refuse a publish for a partition not assigned here
When the balancer named this broker as leader but its own copy of the
topic config did not, the partition lookup returned nil and the
publish dereferenced it. It now answers not-leader, and the publisher
looks the partition up again.
* mq broker: compare the publish leader as an address
The leader check built "ip:port" with Sprintf and compared strings,
while broker addresses are joined with JoinHostPort. On IPv6 the
brackets never matched and every publish was refused as not-leader.
* mq broker: flush partitions on stop
The broker had no Stop. Its loops ran on context.Background, and the
standalone command registered nothing for SIGTERM, so every restart
dropped the publishes still in the open flush window.
Stop now cancels the broker's loops, releases the balancer lock, and
waits until every partition has flushed. The command calls it on
interrupt before stopping its gRPC servers. The startup peer listing,
which blocked the constructor until a master answered, now runs in the
background with the balancer election.
* mq topic: flush partitions added or retired while stopping
Shutdown took one snapshot of the partition list, so a partition a
publish created after the snapshot was never flushed, and one that idle
cleanup had just retired was not waited on. Adding a partition now
fails once Shutdown starts, Shutdown waits out an idle cleanup pass in
progress, and every retired partition is waited on until its last
flush.
* mq broker: release the balancer lock once on stop
Stop and the balancer election could both release the lock when a stop
landed just as the lock was published, and a second LiveLock.Stop
closes its channel again and panics. Each path now takes the lock out
with Swap, so only one releases it.
* mq broker: forget the buffered ring version on a master change
Before the balancer lock client exists, the broker keeps the last ring
it got. A master change then reset nothing, so the client attached with
the old master's version and refused the new master's lower one.
* mq broker: restart the settle window when the balancer lease is regained
The window started when the lock owner's name changed. A balancer that
lost a renewal and got the lease back still had the same name, so it
skipped the wait and could repair assignments before brokers
reconnected. The window now counts from the first sight of the lease's
generation, which changes on every fresh acquisition and stays put on
renewal.
* mq broker: expire configs cached while the balancer settles
A balancer reading a topic during its settle window skipped the repair
and then cached the config for the full 30 seconds, so a dead leader
was served well past the window. Those entries now expire at the
settle deadline.
* mq topic: wait for drained partitions on shutdown
A partition removed by a drain or by its last client leaving was shut
down but not tracked, so a stop right after a resize could exit before
its final flush. Every removal now retires the partition through the
manager, and Shutdown waits on the set of retiring partitions instead
of a WaitGroup that a late removal could Add to while Wait ran.
* mq broker: update the settle window's lease and start together
The lease generation and its start were two atomics written one after
the other, so a concurrent reader could pair a regained lease's new
generation with the old start and see the window as already over. They
are now read and written under one lock.
* mq broker: refuse an assignment while stopping
A partition assigned after shutdown started was shut down, but the
handler still answered success, so the balancer recorded an assignment
this broker never installed. It now answers Unavailable.
* mq topic: signal a subscriber to stop only once
Shutdown leaves partitions registered, so a drain that arrives while the
broker flushes shuts the same partition down again, and closing a still
registered subscriber's stop channel a second time panicked.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: bound flush retries once stopping
Stop waits for every partition's last flush, and a flush retried a failing
write forever, so a broker whose filer or volumes were unreachable never
exited on SIGTERM. In weed server it also held back the filer and volume
shutdown hooks, which run after it. Like the filer's metadata log, a flush
now gives up 15s into Stop and drops the window instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq.broker: flush before closing the localhost listener too
The localhost server's stop hook was registered after the broker's, so it
ran first and cut loopback clients before the partitions flushed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq topic: gofmt local_manager.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: end a shutdown flush stalled in a filer call
The shutdown budget was checked only after a failed append returned, and
the entry lookup and update ran under context.Background(), so a filer
that accepted the call and never answered still held Stop open. Flushes
now append under a context that Stop cancels once the budget runs out,
as the filer does for its metadata log. Every window after a dropped one
then drops too, so a later success cannot advance the watermark or tell
the follower to discard a window that never reached the filer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq topic: leave a partition to Shutdown once it starts
RemoveLocalPartition detached a partition before registering it as
retiring, so a Shutdown snapshot taken in between missed it and returned
before its last flush. Once Shutdown starts, removal now reports false and
the partition stays registered for Shutdown to retire, as idle cleanup
already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: refuse an assignment for a hosted partition while stopping
Only a new partition was refused once Shutdown started. A partition the
broker already hosted stays registered after Shutdown retires it, so its
assignment was acknowledged although the broker no longer serves it. Both
paths now answer Unavailable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: expire a settling balancer's config from when it was validated
The expiry was computed when the config was cached. A lookup that skipped
validation just before the settle deadline and cached the config just after
it kept the unrepaired assignments for the full TTL. The expiry now counts
from the time of validation, so such a config expires at the deadline.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: stop waiting on an upload once the flush budget ends
Cancelling the flush context ended retries and the filer metadata calls,
but not a volume assignment or upload already in flight. Those ran on
their own timeouts and retries, so a filer or volume server that never
answered held Stop past the budget, for minutes in the worst case. The
upload now runs on its own copy of the window, and the flush stops
waiting for it when the context ends.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* operation: return the assignment proof of an upload
A filer serving a scoped token returns an assignment proof with
AssignVolume and stores a new chunk in an entry only when the request
presents that proof in chunk_auth. UploadWithRetry dropped it, so a
client had no way to commit the chunks it uploaded.
UploadResult.AssignAuth now carries the proof of the assignment the data
was finally stored under. A proof from an assignment the upload abandoned
after a failed attempt is never returned. The field is not serialized and
stays empty when the filer sends none, so existing callers are unchanged.
* mount: keep assignment proofs until the filer stores their chunks
A mount with a scoped filer token was refused whenever it wrote new
chunks: the filer asks for the assignment proof of every chunk the stored
entry does not hold, and the mount never kept it.
The mount now keeps the proof of every chunk it uploads and attaches the
proofs of the chunks a request names to each create, update and append
it sends, over the mutation stream and over unary calls, on every
attempt. A proof is released only once a filer acknowledged an entry that
names the chunk, or a manifest that holds it. A failed, refused or timed
out commit releases nothing, since it may have been stored: the retry
still carries the proof, and a filer ignores proofs for chunks it holds.
Proofs are stateless, so a commit retried on another filer of the cluster
is accepted there.
The store is bounded. When it is full an upload waits for commits to make
room before it is assigned a file id, and fails after a minute instead of
evicting a proof a pending commit still needs. Only proofs well past their
expiry, which a filer refuses anyway, are dropped to make room.
Without a filer token the mount keeps no store: its requests and chunk
lists are as before. A token without path grants is given no proofs, so
nothing is attached either.
* mount: keep chunk lists flat with a filer token file
A filer serving a scoped token stores no new chunk in an entry that holds
manifests, so once a mount folded a file's small chunks into a manifest,
every later write to that file was refused. A mount with a filer token now
keeps chunk lists flat; mounts without one fold as before.
* mount: test the unscoped-token path with a signed token
GenJwtForFilerScope returns an empty token when it is given no path
grants, so both cases of TestUnscopedMountRequestsCarryNoProofs ran a
tokenless mount. Sign an unscoped filer token instead and check that it
is not empty, so the test covers a mount holding a token the filer issues
no proofs for.
* mount: fold chunk lists unless the filer scopes the mount's token
A mount with -filer.tokenFile kept every chunk list flat, also when the
token is an unscoped one the filer issues no proofs for. Such a mount
stopped folding chunks into manifests, so its small-chunk runs were never
folded and, on FoundationDB, a file past about 1000 chunks no longer fit
its entry. Keep lists flat only while the current token has path grants
or a method list, which the filer scopes; fold as before otherwise.
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>
The draft v1.1 store format runs only in lab builds and in this package's
tests (chunkV11Format). The mutation hook passes the write's store
position, so the chunk record knows the position through which it has
applied every write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: keep writes available when the replica placement cannot be satisfied
With a placement such as 200 on exactly three data centers, losing one data
center stops all writes: every volume misses a copy and leaves the writable
list, and volume growth cannot find three data centers.
Add master.replication.degraded_growth_min_copies (0 = off). When the
topology no longer has enough data centers, racks or servers for a placement,
the master grows volumes with fewer copies, never below that number. A lack
of free space never triggers it.
These volumes keep the requested placement in their super block and are
writable while the master flags them as degraded; lookups report the copies
they need, so volume servers accept writes to them. Once the topology can
hold the placement again the flag is cleared: they turn read-only until
volume.fix.replication adds the missing copies. The flag is in memory only,
so a master restart has the same safe effect.
Refs #13177
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: tighten degraded volume growth after review
- A degraded volume is writable only with exactly the copies it was grown
with: losing one turns it read-only, so a copy that comes back has missed
no write, and it is not writable before all its copies are registered.
- Use the first relaxed placement the topology can hold and stop there when
it lacks free slots, so full disks never drop more copies.
- Try every relaxed placement, ordered by copies, then data centers, then
racks (011 can fall back to 010, not only 001).
- Data nodes in maintenance mode do not count when checking the topology.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: tie degraded writability to the original servers
- A degraded volume is writable only on exactly the servers it was grown
on: a replacement copy no longer stands in for a missing original one.
- Lookups report the degraded copy count only in that exact state, so a
volume server never relaxes its check when the layout would not.
- When a relaxed placement fails to find slots, try the other placements
with as many copies (for example in the requested data center) before
giving up, still never dropping copies for lack of space.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: copy min_writable_copies into the master.proto copy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: let a degraded volume replicate with the master's min_writable_copies
Mirrors getRemoteReplications: lookup_volume also returns the lookup's
min_writable_copies, and do_replicated_request uses it instead of the
placement's copy count when it is lower.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: test the degraded replicated write through the admin router
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: grow degraded volumes without a setting
Degraded growth no longer needs master.replication.degraded_growth_min_copies:
it always applies when the topology cannot hold a placement, never below two
copies. Lookups skip the degraded scan until a volume was grown degraded.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: leave refused servers out of the degraded slot search
findDegradedSlots cleared option.refused, so a retry could pick the server
that just refused the allocation. Search without the refused servers first
and fall back to them only when nothing else fits, as findAndGrow does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: document that a degraded volume losing every copy stays read-only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: warn about under-replicated and misplaced volumes on the dashboard
The dashboard health line now counts the volumes volume.fix.replication would
repair, using the same placement checks, so volumes grown degraded while a
data center is down show up until they are repaired.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: spread degraded copies over racks and servers when data centers are missing
A 200 volume with a single data center left found no degraded placement:
only per-dimension reductions were tried, and 100 needs two data centers.
Try every placement with fewer copies and no more data centers, so the
remaining copies go to other racks or servers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: report min_writable_copies only for the locations it is returned with
LookupVolume read the locations and the degraded minimum in two steps, so
a replica set change in between could pair the minimum with locations it
does not hold for. Count the minimum only when the returned locations are
exactly the servers the volume was grown on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
* mount: keep an entry whose in-place update is already reflected
A listed entry carries its own commit stamp, so the update event that made
it arrives at exactly that stamp. The removal half passed the strict check
while the write half was fenced, and the entry was deleted and tombstoned.
An in-place update is one change: when its write is fenced, so is the
removal of the same path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: report a cached entry's own commit as its version
FindEntry still versioned a listed entry at the listing floor, below the
commit it carries. An open handle compares invalidations against that
version, so a delayed event the cache fenced out could still replace the
handle's content with the older state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The broker and the Kafka gateway each scanned a partition's files for
the high water mark and counted a maximum only when it was above 0, so
a partition holding one message still read as empty. Both now share
mq.OffsetRange, which tracks whether a range was found apart from its
value.
* feat: set GOMEMLIMIT from cgroup memory limit via automemlimit
* weed: set the memory limit before dispatch and report it through glog
The blank import ran memlimit.Set in an init with slog.Default, so every
weed command, including weed version and weed shell, wrote to stderr
outside glog, and macOS and Windows printed "failed to set GOMEMLIMIT:
cgroups is not supported" each time. Call memlimit.Set before running the
command instead, and log the resulting limit or a bad AUTOMEMLIMIT value
next to the transparent huge page line of long-running commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: log the -memoryLimitMB override and document the automatic limit
weed mount now starts with 90% of the cgroup memory limit unless GOMEMLIMIT
is set, so -memoryLimitMB=0 no longer means unlimited inside a container.
Say so in the flag help and log the override, which replaces the limit the
startup line reported.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Rajesh Kannapalli <rajesh.kannapalli@broadcom.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A listing snapshot capped at the peers' delivery watermark can trail
entries already in the store. A delayed event older than the listed
version then rolled the entry back, e.g. a completed file to its empty
create, until the newer event arrived. A live entry now counts as
versioned at least at its CommitTsNs.
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix(master): handle capacity changes during volume placement
* topology: test capacity changes during placement deterministically
The maintenance-toggling loops ran for seconds and could pass without
reaching either guard. Drain the secondary rack or data center right
before its slot draw, and feed PickNodesByWeight a node whose reported
capacity changes between reads. Each case fails on the code before the
fix.
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>
* fix(s3): preserve logical part layouts on multipart completion
* s3api: accept a multipart part that is entirely a hole
UploadPartCopy of a range that overlaps no source chunk stores a part
with no chunks but a non-zero size. Completion rejected any chunkless
non-last part as empty, so the upload failed with InvalidPart even
though the part copy succeeded. Reject only parts whose logical size is
zero; the all-hole part now completes as zeros at its position.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: refuse a multipart completion made only of holes
When every completed part is a hole, the object gets a positive size
and no chunks, and GET answers it with InternalError as a data
integrity failure. Reject that completion with InvalidPart instead of
committing an object that cannot be read. Uploads that mix hole-only
parts with data parts still complete.
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>
* s3api: GetPart reads one part of a multipart upload
GET /key?part&partNumber=N&uploadId=X serves the latest attempt of an
open upload's part, or the bytes that part became in the object a
completed upload assembled, including a version that is no longer
latest. x-amz-multipart-upload-status says which. A Range counts
within the part, and a whole part answers 200 even though a completed
part is served as a range of the object.
The route sits ahead of ListParts and claims any ?part request, so a
missing partNumber is InvalidArgument rather than a listing, and the
request resolves to s3:GetObject, not the ListParts grant.
* s3api: reading an open upload's part needs s3:GetIncompleteUpload
AWS gates GetPart on an upload that has not completed behind
s3:GetIncompleteUpload on top of s3:GetObject, so a plain read grant
does not start exposing data its writer has not committed yet. The
action is its own legacy grant too; Read alone does not carry it, Admin
does. A completed upload's part needs only the read grant, plus
s3:GetObjectVersion when it lives in a version.
* s3api: a GetPart request carrying ?uploads is not a multipart listing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: GetPart answers a completed empty part with an empty 200
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>