A primary line is issued for the process at its endpoints and blockvolume
refuses a line that names no process. For a workspace-bound RF1 volume the
product loop's direct path never re-issues a line whose addresses already
match, so a line minted from a hand-ingested observation before the holder
started was never replaced, loop or not. Both tests now start the holder,
wait until blockmaster observes its slot with its process incarnation, and
only then run the product tick that binds, as production orders it.
SWBLOCK_TEST_EARLY_LINE=1 is the control: the line is minted from a
hand-ingested observation before the holder starts, with no product loop,
as before. Native: lease PASS, control FAIL at "unleased host did not adopt
assignment"; move control FAIL at "source did not serve" with the
empty-process refusal.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The refusal is read once and named first, since it is also why the
durable backend refuses. invariants.md M1 Recovering -> Serving and the
Kubernetes failover diagram carry the primary's profile check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the durable backend wired as the status source (as blockvolume
does), status reports the backend's generic stale-primary reason, not the
profile mismatch naming both profiles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestBinaryWorkspaceLeaseOptInOwnsCLEANShutdown minted its line from a
hand-ingested observation before the holder started, like the layout move
test, so the holder refused the line that named no process. Both tests now
share runProductLoop (the lifecycle product loop every 100 ms, as
blockmaster runs it) and blockvolumeUnderTest (the gate's prebuilt binary
when SWBLOCK_TEST_BINS is set). The control is now
SWBLOCK_TEST_NO_PRODUCT_LOOP=1, for both tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A line is issued for the process at its endpoints, and a holder refuses a
line that names another process. The test minted the initial line from a
hand-ingested observation before the source started, so it named no
process and the source refused it ("issued for process <empty>"; source did
not serve). The test now runs the lifecycle product loop as blockmaster
does, which re-issues a line once the process reports itself (the initial
line, and a move's target). LAYOUT_MOVE_NO_PRODUCT_LOOP=1 leaves the loop
off and reproduces the refusal (the control). With SWBLOCK_TEST_BINS set
(a gate run) the test uses that prebuilt blockvolume instead of building a
race-enabled one, so the binary it runs is the one the gate hashed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
INV-WS-REVOKE-ACK-RETRY-001: asked again only after no answer
(DeadlineExceeded, Unavailable), within the lease deadline and the 19 s
closeout; the master answers a repeat of a recorded ACK as recorded while
the line is revoking.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every assignment names blockmaster's ack profile; a primary of a
replicated line whose own --replication-ack is another one is not Healthy
(its status names both), so a lost primary that cannot answer
acknowledged under the master's profile. fencedDecision also holds on
the fencing round's own ProfileMismatch, the evidence it counts.
invariants.md: the M3 promotion-candidate row, the MATCH row's fencing
round, and the new INV-PRIMARY-ACK-PROFILE-001; the Kubernetes design
no longer says best_effort is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The survivors' answers cannot show the profile the lost primary
acknowledged under. Adds AssignmentFact.ack_profile (blockmaster's
profile) with tests: an assignment names the master's profile; a primary
of a replicated line in another profile (or under a master that names
none) does not serve and says why, while its own profile or an RF1 line
serves; and a fencing round answered in another profile publishes
nothing, on both gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
INV-PROMOTE-FRONTIER-BEST-EFFORT-001 now states the hold (it said the
gate promoted the highest-durable candidate) and names the renamed
product-loop test; INV-PROMOTE-ACK-PROFILE-MATCH-001 is new.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The volume answers each promotion probe with its own --replication-ack;
the probe round names every answer whose profile is missing or differs
from blockmaster's (or an unknown master profile), and both gates hold
such a volume before any fencing round (ack_profile_mismatch), as they
hold a best_effort one. One helper (automaticFailoverHold) decides both,
called before the unsupported gate reads its candidates, so a held volume
always shows why. blockmaster refuses an unknown --launcher-replication-ack.
The best_effort product-loop test now expects the hold.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: redact remote rename source from scoped responses
* Preserve scoped remote rename markers
* Consolidate scoped marker replacement coverage
* Refuse scoped whole-entry guards during remote rename
* Keep coded create refusals for guarded scoped writes
* Make scoped subscription batch coverage deterministic
* filer: refuse scoped conditions that compare the remote rename source
IF_EXTENDED_NOT_EQUAL clauses and ExpectedExtended on Create, Update
and DeleteEntry could still compare a guess against the hidden marker,
so a scoped client could confirm the source path it redacts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: refuse scoped condition gates on the remote rename source
An IF_EXTENDED_TIME_ELAPSED gate applies its time check only when the
gate value matches, so a gate on the marker also confirms a guess.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep a pending rename source out of remote copy errors
A failed copy of a pending remote-only rename named the marker's source
location, which the backend error repeats, and rename RPCs return that error
to scoped callers. Log the full error and return one naming only the paths
the caller supplied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: let a scoped local overwrite end a pending remote rename
Scoped replacements kept the hidden rename source marker even though a
scoped entry can never stay remote-only, so the marker was stale on the
local copy and every later scoped IF_ENTRY_EQUAL write was refused. Drop the
preservation and let the overwrite clear the marker as other local writes do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* codespell: ignore poligon only inside URLs
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>
* s3: compare If-None-Match weakly, as the filer and volume servers do
The S3 gateway matched conditional ETags by trimming quotes, so a weak
tag such as W/"etag" in If-None-Match never matched and a revalidating
GET got 200 instead of 304. Move the filer's RFC 9110 matcher to
weed/util and use it in the gateway: weak comparison for If-None-Match,
strong for If-Match. The routed write condition now sets AllowWeak on
IF_ETAG_NOT_MATCH so the check under the object lock agrees with the
gateway's pre-check.
* s3: split write-condition ETag lists the way the gateway matches them
etagList split on every comma and kept empty elements, so the filer's
locked If-None-Match check (now a weak comparison) could match a fragment
of one quoted tag, or an empty element, that the gateway's pre-check
ignores. A PUT with If-None-Match: W/"<etag>,x" passed the pre-check and
then got 412 under the lock. Reuse the gateway's quote-aware splitter and
drop empty elements.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Mansur Akhmadi <10739460+mansur-akhmadi@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3: keep a bucket policy change from aborting its own request
The bucket metadata event re-checks every request in flight on the
bucket, including the PutBucketPolicy, DeleteBucketPolicy or DeleteBucket
request that made the change while it is still answering. A deny-all
policy, or the removal of the policy that granted the requester access,
then closed that request's connection after the change was stored; the
client saw a reset and its retry was denied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: keep re-checking a policy change until it stores it
Exempting the policy-changing actions at admission let a request whose
key was revoked while it read its body still replace or delete the
policy. The request stays tracked now and untracks itself right before
it stores its change; if it was aborted by then, it stores nothing.
DeleteBucket untracks itself before the delete, which also covers the
identity re-check its bucket-scoped action pruning triggers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An ACK call that got no answer (DeadlineExceeded, Unavailable) is made
again until the lease deadline; the master answers a repeat of a recorded
ACK as recorded, so a busy master no longer turns a clean stop into exit
75. The closeout wait becomes 19 s: the units' TimeoutStopSec=30s less
the 5 s drain, the 5 s exit wait and 1 s margin. blockmaster logs each
AckWorkspaceRevoked step's time (lock, HEAD read, recorded, answered).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A first ACK answered DeadlineExceeded or Unavailable (the master busy)
must be asked again, and the repeat's answer completes the stop with
status 0; a refused first ACK stays final (exit 75). A second test checks
the closeout fits the units' TimeoutStopSec with the drain and the exit
wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate reads every frontier rule from blockmaster's
--launcher-replication-ack, but a volume runs its own --replication-ack.
Adds the wire field (ProbeAnswer.ack_profile) and the result fields, with
tests: both gates hold, without fencing, when an answer's profile is
missing or differs from the master's, or the master's is unknown; the
probe round names the mismatch; the volume answers its own profile;
blockmaster refuses an unknown --launcher-replication-ack.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new primary holding every acknowledged write, and a partitioned old
primary's writes being refused, hold for sync-quorum and sync-all. With
best-effort (the default) a write is acknowledged with no replica: an
automatic failover can lose the writes acknowledged last, and a
partitioned old primary keeps accepting writes. The replicated start sets
--launcher-replication-ack sync-quorum, equal to the volumes'
--replication-ack. INV-PROMOTE-UNKNOWN-CURRENT-001's statement names the
fresh heartbeat.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A best_effort volume promises no frontier on a survivor, so the
automatic promotion gate now holds it (blocked event
best_effort_no_automatic_failover) instead of fencing a successor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On both gates a best_effort volume whose primary is ineligible must get no
fencing round, keep its line and show best_effort_no_automatic_failover;
the same setup under sync-quorum fails over (the control). Red: today the
best_effort volume is fenced and failed over. The probe fake gains an ack
profile; the reason constant is added for the test to name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under --cluster-spec with the lifecycle loop on, a primary whose heartbeat
is stale, or that answers not ready, is replaced through a fencing round
when enough replicas answer; a primary with a fresh heartbeat that does not
answer the probe is never replaced automatically. The operator's failover
is for a round that cannot decide (fence_round_incomplete) and for a static
--topology. An old primary cut off from blockmaster but reachable by its
clients can serve reads of its old data until the partition ends; its
writes are refused. INV-PROMOTE-UNKNOWN-CURRENT-001's limits match.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The repository's public-text gate refuses a pull request that adds a line
naming the team runner label, and the separate process-level job added a
second runs-on line. It now runs as the 'process' entry of the existing
job's two-entry matrix (unit | process), under that job's unchanged
runs-on line; each step is gated on matrix.suite, and the job name and
timeout are templated so the two checks keep their names ('go test
(linux)', 'process-level tests (real binaries)') and bounds (40 / 90 min).
The old two-test step stays folded into the named list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docker: let the caller's GODEBUG fips140 setting override the default
entrypoint.sh appended fips140=on after the caller's GODEBUG, and Go
applies the last of repeated settings, so `docker run -e
GODEBUG=fips140=only` ran with fips140=on, and fips140=off stayed on. The
default now goes first.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
spark-submit resolved the Lance bundle and its dependencies through Ivy
from Maven Central only, so a refused Central request failed the run in
seconds with "module not found". --repositories adds the Google mirror
after Central in Ivy's resolver chain.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): sign a fresh write JWT for each replica forward
The primary checks the write JWT when the request arrives, then reads the
body. A body slower than the JWT lifetime (10 s by default) left the
forwarded Authorization header expired, so replicas answered "wrong jwt"
and the write failed with 500. With a write signing key, each forward now
carries a JWT signed right before it, after the replica lookup, for the
base file id the request was authorized for. A raw jwt= query field, which
the replica reads before the header, is no longer forwarded on writes.
Without a signing key the incoming Authorization header passes through as
before. Deletes are unchanged.
Mirrors the Go volume server change in #13028.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): take the replica forward key from the write auth snapshot
The replica JWT key was read from the guard again after the body was
read, so a reload that enabled write signing in between could sign
replica forwards for an upload that was never authenticated. Read it in
the same guard snapshot as the write's JWT check, as Go's PostHandler
does with writeSigningKey.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): drop jwt query fields by decoded name on write forwards
Go's GetJwt decodes query names and reads jwt before the Authorization
header, so a forwarded %6Awt=x would still override the fresh JWT on a Go
replica. Drop every field whose decoded name is jwt from a write forward.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume, operation: refresh the write JWT for replica forwards and filer-proxy retries
A write JWT is checked when a request arrives, but a slow chunk can take longer to stream in than the JWT lives.
The volume server then forwarded the already expired JWT to its replicas, which rejected it with wrong jwt, and the client retried through the filer with its own filer JWT, which by then had expired too.
Only a 401 marked as an expired volume JWT re-minted the filer JWT, so the 500 from the failed replica forward led to retries that could never succeed.
The volume server holds the signing key and has already authorized the request for this file ID, so it signs a fresh JWT for the forward; without a signing key it forwards the incoming one as before.
A filer-proxy upload re-mints its filer JWT before every retry, whatever the previous failure was.
Refs #6220
* volume: mint the replica forward JWT right before each forward
A JWT minted before the uncached master lookup spends part of its lifetime on that lookup, so the replica can still see it expire; minting inside the forward path gives each replica request its full lifetime.
Minting stays unconditional rather than forwarding a still-valid incoming JWT, which could expire in flight and reintroduce the failure.
The cost is a key rotation constraint: a new write signing key must be verify-only on every volume server before any server makes it current.
The base file ID trim moves into one helper so the authorization check, the expiry classification and the mint cannot disagree on which file ID a write JWT covers.
* mount: refuse SSE-KMS and SSE-C objects the native read path cannot decrypt
The native read check only recognized SSE-S3, so objects the S3 gateway
stored with SSE-KMS or SSE-C were read chunk by chunk and the mount
returned their ciphertext with success. Detect every S3 server-side
encryption type, from the object metadata or any chunk, and answer
open, read and copy_file_range with ENOTSUP unless the object is SSE-S3
and -sseS3Read routes it through a gateway.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop S3 encryption markers when a file is truncated to zero
A full truncate removes the encrypted payload, but the object metadata
still named SSE-C, SSE-KMS or SSE-S3, so the plaintext the mount wrote
afterwards was refused on read. Clear those markers in SetAttr and
truncateEntry when the size becomes zero, and reset the handle's cached
classification.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* weed: report the host transparent huge page policy at startup
Go maps the heap with MADV_HUGEPAGE, so the host THP policy applies to a
SeaweedFS process whether or not the operator asked for it, and the advice in
the Go GC guide depends on the heap size. Operators had no way to see which
mode a node actually runs in.
Log enabled/defrag/khugepaged.max_ptes_none once at startup from the
long-running commands, and print the Go toolchain in `weed version` so a
support bundle identifies the runtime that produced the binary. Nothing
changes the policy: THP is host-wide, and GODEBUG=disablethp=1 remains the
only per-process control.
Refs #5437
* build: declare Go 1.27.4, the toolchain the releases already use
The 4.55 release binaries report go1.27.4 (`go version -m` on the published
tarball), while go.mod still said 1.26.6, the Dockerfiles pinned golang:1.26,
and the release workflows left the Go version to the action default of "the
latest stable at build time". A source build, a container and a downloaded
tarball therefore ran different toolchains from the same tag, and the next
release could silently pick up another one.
Set the go directive to 1.27.4 in the root module and in the four modules that
build in CI, bump the 16 Dockerfiles, and pin goversion: 1.27.4 in the 16
release and dev action steps.
`go mod tidy` now emits the two require blocks Go 1.27 expects; no dependency
version changed. Go 1.27's gofmt realigns 8 files.
* weed mini: report the THP policy after quieting stderr
The startup line ran from the dispatch point before runMini applied
quietMiniLogs, so every weed mini start on Linux printed it to stderr,
which mini keeps for the welcome banner, warnings and errors. Log it
from runMini after quietMiniLogs so it lands in the log file only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report whether the Go heap can use huge pages
The runtime advises only GC metadata with MADV_HUGEPAGE and leaves the
heap arenas to the host default, so under enabled=madvise the heap stays
on small pages. The log still printed go_heap_disabled=false there, which
reads as "the heap uses THP". Report go_heap_thp, true only under
enabled=always without GODEBUG=disablethp, and drop the struct comment
that said the heap is mapped with MADV_HUGEPAGE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: count an inherited PR_SET_THP_DISABLE in go_heap_thp
A launcher can disable THP for the process with prctl, and children
inherit it, so enabled=always alone does not mean the heap gets huge
pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: read GODEBUG disablethp the way the runtime does
The runtime applies GODEBUG left to right, so with
disablethp=1,disablethp=0 the heap keeps THP, while the helper stopped at
the first disablethp=1. The helper also missed other nonzero values such
as disablethp=2, which the runtime treats as disabled, and trimmed spaces
around keys, which the runtime keeps. Take the last disablethp with an
integer value, treat any nonzero value as disabled, and match keys
exactly. The parser now takes the GODEBUG string, so it is tested without
changing the environment.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: honor per-size THP policies in go_heap_thp
Since Linux 6.8 each anonymous huge page size has its own policy in
hugepages-<size>kB/enabled, and only "inherit" follows the top-level
knob. A 64kB size set to "always" gives the unadvised heap huge pages
under a top-level "madvise" or "never", and a 2048kB size set to "never"
takes them away under "always", but the log judged only the top-level
value. Read the per-size policies and report go_heap_thp=true when any
size reaches the heap. Under a top-level "never", the "disabled by the
host" line is now printed only when no size reaches the heap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report go_heap_thp=unknown when the process setting is unreadable
If PR_GET_THP_DISABLE fails, for example because a seccomp profile
rejects it, the process THP setting is not known, but the log treated it
as allowed and could print go_heap_thp=true. Print go_heap_thp=unknown
in that case. It stays false when the host or GODEBUG already rules out
heap huge pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: report go_heap_thp=unknown when a per-size THP policy is unreadable
An unreadable hugepages-<size>kB/enabled was skipped, so the log could
say the host disabled THP while that size allowed it. Keep it as an
empty mode and report unknown unless a readable size already allows
huge pages.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: take the Go version from go.mod in tests and releases
posix-compliance pinned GO_VERSION 1.26 and built go 1.27.4 modules only
through the GOTOOLCHAIN auto-switch; nine workflows used go-version ^1.26 and
the kafka jobs ran in golang:1.26-alpine. Read the version from go.mod with
go-version-file, as the other setup-go steps already do, moving checkout ahead
of setup-go where it came after so the file exists. The posix report takes the
version from the setup-go output.
The release and dev builds pinned goversion 1.27.4 in 16 places. The pinned
go-release-action reads the go directive when goversion is go.mod, so the
binaries now follow go.mod without a second copy of the version.
* weed: report the THP policy from every long-running command
mount, worker, iam, master.follower, the filer sync/backup/remote/replicate
daemons and the mq agent and kafka gateway keep serving after startup like
the commands already listed; mount is likely where heap size matters most.
fuse is not listed: its first process starts a child with the same arguments
and waits, so logging at dispatch would print the line twice. It logs in
runFuse just before handing over to runMount, which only the child reaches.
---------
Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* util: one admission rule for upload limits
* operation: mark gateway fan-out holder writes as client traffic
* volume: bound upload admission, limit gateway holder writes, 503 on timeout
* volume: charge unknown-length uploads half the budget, document client wait cap
* s3, filer: admit uploads by inFlight+size and charge unknown lengths a chunk
* s3: answer a volume overload as SlowDown with Retry-After
* operation: cut an upload whose body crawls below the minimum rate on any host
* operation: make the slow-commit deadline test honour the request context
* s3: stop chunk uploads when the client goes away
* operation: treat a body deadline cut as back-pressure, not a same-holder retry
A body that crawls past the body deadline returns from retriedUploadData at
once, like an overload, and counts toward the single reassign the chunk loop
and the filer retry gate give back-pressure. A watchdog cut keeps its retry on
a fresh conn. Both still match ErrUploadStalled and stay reassignable.
* operation: apply the body deadline only to uploads that opt in
UploadOption.BodyDeadline and ChunkedUploadOption.BodyDeadline turn the
body deadline on; S3 chunk uploads (relay and fan-out) and the filer's chunk
loop set it. Mount, filer.sync, filer.copy and UploadWithRetry keep the stall
watchdog only, as before the deadline existed.
* s3, operation: check a chunk cancelled with its client is deleted from every holder
A volume commits on a context that ignores the cancel, so a chunk whose
caller went away after sending the body may still land. The chunk loop
already deletes the fid from every holder after a failed attempt; pin that
for the relay and fan-out paths and for an S3 PUT whose client goes away.
* s3: count a request's declared bytes in the circuit breaker byte limits
The per-bucket and global byte counters go back to the declared length (an
unknown length counts one chunk), so a bucket bytes limit still rejects a
single PUT larger than it. Only the upload budget uses the capped gateway
charge.
* s3: answer copy chunk overloads as SlowDown, tidy the client-gone checks
CopyObject and UploadPartCopy map a volume overload or an exhausted stall to
SlowDown, as PutObject does. The client-gone log check matches the mapper's
context.Canceled test, the truncated-body case drops a check the first case
already makes, and the Retry-After test reads the headers actually sent.
* filer, volume: clamp the filer charge chunk, set the upload gauge under the lock
A filer with -maxMB 0 charges its default chunk size instead of nothing. The
volume server sets its in-flight upload gauge inside the critical section.
The upload limit tests wait until the waiter is parked before releasing,
check handleUploadRequest gives its charge back, and use CI-safe bounds.
* volume: cap the Rust server's client upload-slot wait at 5s
Same cap as the Go volume server's volumeClientUploadWaitCap, so a gateway's
body deadline never fires before the 503.
* operation: reflow the body deadline comment
* volume(rs): count a gateway's src=client holder write against the upload limit
Mirrors operation.IsReplicaForward: only a primary-to-replica forward
skips the upload budget; a gateway's ?type=replicate&src=client fan-out
waits like any client write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): admit uploads by inFlight+size, reserved atomically
Mirrors the Go volume server's waitForUploadSlot: an upload is admitted
by util.UploadAdmits (idle server, or inFlight + size within the limit)
and reserves its bytes in the same step, so concurrent waiters cannot
all pass one check. Primary-to-replica forwards and unlimited servers
are counted but never refused. UploadLimitCond counts once per waiting
upload, and the wake-up is armed before each check so a release in
between is not missed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): charge an unknown-length upload against the upload limit
Mirrors the Go volume server's uploadCharge: a chunked upload without
Content-Length reserves one file's worth of budget, at most half the
limit and at least 1 byte, instead of 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): a zero -inflightUploadDataTimeout waits the 5s client cap
The Go volume server now reads 0 as the 5s cap (its flag help says so);
the Rust server used a 2s wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): close a rejected large or unknown-length HTTP/1 upload
Mirrors the Go volume server's uploadRejectCloseThreshold: the 503 for
a body over 256 KiB, or one without a length, carries Connection: close
instead of keeping the connection for a body nobody reads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): drop src from a primary's replica forward
A client upload carrying src=client kept it on the forward, so replicas
treated the forward as gateway fan-out and could refuse it after the
primary had already appended. Go's ReplicatedWrite builds a fresh query.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): keep the upload admission CAS buildable on rust 1.91.1
Atomic try_update is stable only since 1.95.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): refuse an upload the in-flight counter cannot hold
A replica forward added its charge with fetch_add, so a Content-Length
near i64::MAX wrapped the shared counter negative and let later client
uploads past admission. The forward now reserves with a checked add and
answers 503 when the size does not fit; the client CAS adds only after
admission passes. With no upload limit the counter only feeds the gauge,
so it keeps wrapping arithmetic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: refuse an upload the in-flight counter cannot hold
A replica forward added its charge unchecked, so a Content-Length near
math.MaxInt64 wrapped inFlightUploadDataSize negative and let later
client uploads past admission. Under the lock the reservation now
checks that the counter can hold the charge and answers 503 otherwise,
matching the Rust volume server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: keep the request body on a rejected upload
Replacing r.Body with http.NoBody hid the server's early close of the
unread body from net/http before Go 1.27, so it skipped the FIN-then-wait
close and reset the connection under a client still sending. Go 1.26.6,
the version go.mod declares, then failed
TestUploadLimit503ReachesGoClientForLargeBody with a write error instead of
the 503.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: compare upload admission without forming inFlight+size
* operation: reassign a chunk after a 429 as after a 503
* s3: do not count a chunk assignment the client cancelled as a filer failure
* filer: charge an upload by its request chunk size, and an inline upload by its whole body
* s3: hold an aws-chunked body to its X-Amz-Decoded-Content-Length
* volume: answer a rejected small-body upload without waiting for its body
* s3: fill the upload budget before testing that a release wakes every waiter
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: drop bucket size gauges on an instance that lost the metrics lock
Only the S3 instance holding the s3.leader lock collects bucket sizes and
quota state, once a minute. An instance that loses the lock and keeps
running never clears what it set. bucketMetricTTLControl drops a bucket's
gauges only after 10 minutes without activity, and every request the
instance serves for the bucket counts as activity. So for the buckets
clients keep using through it, its bucket_size_bytes,
bucket_physical_size_bytes, bucket_object_count, bucket_quota_bytes and
bucket_read_only series stay at the values it collected last, next to the
new holder's current ones. Summing a gauge over instances counts those
buckets twice, and taking the max shows a bucket that has shrunk since at
its old size.
On every tick without the lock, reset these five gauges. Only the
holder's collection sets them, so an instance that never held the lock
loses nothing, and one that lost it stops reporting within a minute.
In a cluster with seven S3 instances, one kept 10 to 14 buckets at their
old values for four days after losing the lock; at one point the max
over instances put a bucket 37 TB above its size.
TestBucketSizeMetricsTickWithoutLockDropsGauges sets the gauges for two
buckets, checks that a tick with the lock leaves them, and that a tick
without it removes all five. Without the reset it fails for each gauge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: shorten the bucket size metrics lock-loss comments
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>
* master: gate operator-only management RPCs on the whitelist
CollectionDelete, DisableVacuum, EnableVacuum, VolumeGrow,
ResumeVolumeGrowth, LeaseAdminToken and ReleaseAdminToken now call
checkGrpcAdminAuth, matching the whitelist their HTTP counterparts
already enforce. VolumeGrow stays open to the in-process growth loop,
and callers on the local gRPC socket of weed server/mini are local.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: admit unknown masters over KeepConnected only from the whitelist
A KeepConnected registration as a master pulls that address into the
raft quorum. Accept it from any caller only for this master and its
-peers; any other master address now needs a whitelisted caller, the
same check RaftAddServer applies.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: test that every RPC is gated or listed with a reason
Port the volume server's coverage test so a new master RPC cannot skip
checkGrpcAdminAuth without an explicit exemption. The proto and AST
helpers now take the proto file and receiver name.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: admit callers on the local gRPC socket
weed server and weed mini route same-host gRPC dials through a unix
socket, whose peer address carries no IP. With -whiteList set the
volume server refused the in-process master's AllocateVolume, so no
volume could be grown. The Rust volume server serves gRPC over TCP only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: match a KeepConnected master against configured peers by gRPC endpoint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: bind the local gRPC socket for the owner only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: warn when a deleted bucket's collection is left on the master
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: bind the local gRPC socket in a private directory before moving it into place
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: report an unconfirmed bucket collection delete as such
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3_objectlock: read a bucket's default retention from its entry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: give uploads into an Object Lock bucket its default retention
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: match uploads against the cleaned buckets folder
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3: do not delay the EOF read in the put stage timing test
TestPutStagesRecordEachStage checks that the storage stage is at least
5ms. That stage is the second chunk's assign wait (20ms) minus the final
read that only returns EOF, which slowReader also delayed by 10ms. When
busy goroutines hold every P, the reader's wakeup can lag the assign's
by as much as a preemption slice, and storage drops below the floor.
slowReader now delays only reads that return data, so the EOF read is
instant and storage covers the whole assign wait.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: keep the EOF read out of the timed body in the put stage test
Skipping the delay on the EOF read still left that read inside
timedBody, so a stall there was subtracted from storage. Feed the upload
through an eight-byte limit instead: the final EOF comes from the limit
reader without reaching the timed body, so storage always covers the
second chunk's full assign wait. slowReader goes back to delaying every
read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: weed fix -verify to resync past damaged regions in .dat
Plain `weed fix` walks .dat by trusting each needle header, so a damaged
region in the middle loses or misindexes everything after it, and a torn
or garbage tail ends up in the index and keeps the volume read-only.
-verify reads every needle, checks structure and CRC32, and on a failure
searches forward at needle alignment for the next verifiable needle. Each
skipped region is reported as zero-fill / garbage / garbage+zeros with its
length, zero windows and the fid of the needle that was hit. The index is
rebuilt from verified needles only (old one kept as .idx.bak); -truncateTail
cuts trailing garbage so the load-time integrity check passes, -dryRun only
reports. Works with the 5BytesOffset build.
* feat: add weed fix.verify, a read-only check of .dat files
Runs the same needle/CRC verification and resync scan as `weed fix -verify`
but never writes: no .idx rebuild, no truncation. Takes folders and/or .dat
files, filters with -collection / -volumeId, prints the damaged regions
(optionally to -report) and exits 0 when clean, 3 when damage was found and
1 when a file could not be verified. The scan options are shared with
`weed fix -verify`.
* feat: weed fix -compact, verify and compact a damaged volume in one pass
-compact implies -verify. While the .dat is scanned, every verified needle
gets an index entry, and from the first damaged region in the middle of the
file the needle bytes are streamed into a new .cpd as well (the intact prefix
before it is copied as one block). The result is a .dat without the damaged
regions and an append-ordered .idx that matches it exactly, so a full volume
scrub no longer complains about the .dat size. The compaction revision is
bumped like a vacuum does.
A volume without damage is left untouched, and damage only at the tail is just
cut off in place, so neither costs a .dat copy. The old .idx is kept as
.idx.bak and the old .dat as .dat.bak (-deleteOriginal removes it). The free
space needed for the new .dat is checked before anything is written, a failing
swap is rolled back, and progress is printed every 30s.
* refactor: reuse backend, super block and throttler code in weed fix -compact
- create the .cpd with backend.CreateVolumeFile and preallocate the bound of
the new .dat; the result is truncated to its real length at the end
- read the super block with super_block.ReadSuperBlock (also in the verifier)
and write the bumped compaction revision with SuperBlock.Bytes()
- throttle the .dat writes with util.WriteThrottler (-compactionMBps)
- fsync the directory before and after swapping the new files in
ReadSuperBlock cannot read a super block with extra data, so such volumes are
rejected with its error instead of being handled by a hand-written parser.
* refactor: drop helpers that duplicate existing code in weed fix -compact / fix.verify
- util.FsyncDir instead of a local fsyncDir
- io.NewOffsetWriter instead of a hand-written WriterAt adapter; the throttle
now sits in one small writer wrapper used for both the prefix copy (via
io.CopyBuffer) and the streamed needles, replacing the manual copy loop
- needle.NewVolumeId instead of strconv for volume ids parsed from file names
* fix: resync in weed fix -verify must not accept payload-less look-alikes
After damage, a few bytes of a needle's tail followed by the next record's
header could parse as a payload-less needle and be confirmed only because the
file ended right after it, so a made-up key got into the index and swallowed
the real delete record behind it.
A payload-less candidate is now accepted without a verifiable successor only
if it is a size-0 tombstone ending exactly at the end of the file (or, with a
set timestamp, leaving less than a header); a set but implausible v3
timestamp rejects it. Anything else needs the next needle to verify.
* test: recovery integration tests for damaged .dat heads (#5674, #12914)
- zero-filled head (aligned and cut next record): all survivors indexed,
region reported as zero-fill, trailing tombstone kept
- plain weed fix stops at the first bad header (#12914 item 1) while
-verify recovers the needles behind it
- a needle rewritten after a damaged region is indexed at its newest copy
- a zeroed superblock fails with an explicit unsupported-version error and
fix.verify counts it as not verifiable (exit 1)
- v1/v2 needle layouts verify cleanly
* fix: reject a super block extra in fix -verify
A super block extra describes an erasure-coded layout; the .dat behind it was
re-striped into .ecXX shards and is not a plain needle file. Scanning it as
one silently produced damage reports instead of telling the operator the file
is out of scope. Return an explicit error instead.
* fix: guard fix -verify/-compact against pending compaction commits and -dir.idx
- refuse to start while a .cpc marker exists: an interrupted vacuum commit is
pending and the volume server must reconcile it first (roll forward/back);
writing a rebuilt .idx or new .cpd/.cpx over that decision would race it
- clear a stale .cpc after a completed swap so it can never be rolled forward
later (defensive; the start guard already refuses this state)
- spell out in the help and print after a rebuild that the index is written
next to the .dat: with a separate -dir.idx directory the .idx must be moved
there and any stale .ldb dropped
- tests: refusal leaves the marker and writes no .idx; a completed swap clears
a marker that slipped past the guard
* refactor: narrow this change to weed fix -verify
Drop weed fix.verify and weed fix -compact from this change; they follow in their own pull requests. -report, -windowMB and -zeroWindow go with them: the scan uses fixed windows and prints its report to stdout.
* fix: weed fix -verify: address review findings
- -maxNeedleSizeMB limits only guesses made while resynchronising; a record
reached at a known boundary may be as large as the file allows
- a v2/v3 record whose parsed fields do not add up to its size, or a live
record without data, is damage: a zero fill over the data length used to
pass as an empty file because the CRC is only checked when there is data
- a stamped v3 delete record found after damage stands on its own when its
time is believable, not older than the last verified record and followed
by zero padding, so a delete before a damaged tail is not lost
- a read error while searching for the next needle fails the run instead of
ending the scan and treating the rest as a garbage tail
- keys whose newest record is damaged while an older copy is indexed are
reported as stale-version warnings
- the rebuilt index is staged as .idx.tmp and swapped in when complete; a
stale .ldb next to it is removed so the volume server rebuilds it
- -ignoreError reports a volume that cannot be verified and goes on
- -truncateTail does not cut a tail it could not read and removes a partial
tail backup
- volume ids are parsed as uint32
- the test fixture stamps every record the way the volume server does
* fix: weed fix -verify: prove deletes found after damage, swap the index safely
- a delete record found while resynchronising must prove itself: a v3 one
needs a believable time not older than the last verified record and zero
padding (every v3 writer stamps deletes); a v1/v2 one needs the following
records to reach data that passes its CRC, or the exact end of the file.
Stray bytes in a zero-filled region used to pass as deletes of live keys.
- the rebuilt index is fsynced before the swap, the previous one is kept as
a hard link, and the new one replaces it in one rename, so a live .idx
exists at every moment
- .sdx and .rdb caches are removed with the .ldb
- -verify exits non-zero when it found damage, like plain fix and -verifyCrc
- with -ignoreError a file name whose volume id does not fit uint32 is
reported and the batch goes on
- the help and the printed hint say that a volume server prefers an .idx
next to the .dat over the one in -dir.idx
* fix: reject weed fix flag combinations -verify cannot honour
-verify -remoteFile skipped an explicit .dat and reported success, -dryRun
and -truncateTail were silently ignored without -verify, and -dryRun -ecx
still rebuilt EC indexes. Check the combinations before any file is touched.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: apply -volumeId before rejecting an out-of-range volume file name
With -volumeId set, an unrelated file such as 4294967296.dat aborted the
run before the filter could skip it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: check the data length before reading a record body in fix -verify
A damaged size field at a known record boundary made the scan allocate and
read a body of that size before rejecting it. Check that the data length
after the header fits the record first, as the resync probe already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: accept a v1/v2 delete chain that reaches the end of the file on its last probe
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: keep an implausible needle timestamp out of the fix -verify resync baseline
The data CRC does not cover the v3 timestamp, so a corrupted one passed and
then rejected every genuine delete record found after later damage. Report
it as a warning instead of using it as the lower bound.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: stop fix -verify on a read error at a known record boundary
An EIO while reading a record was treated like damaged bytes: the scan
resynchronised past the unread record and the rebuilt index dropped it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: sync the fix -verify tail backup before truncating the .dat
A crash right after the truncate could persist it before the backup's data
or directory entry, losing the cut bytes from both files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: let fix -verify -truncateTail retry when a tail backup already exists
After a backup succeeded and the truncate failed, the next run hit the
existing backup and could not get past O_EXCL. Keep the first backup and
save the tail under a new name, as the index backup does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: drop stale index caches before fix -verify swaps in the new index
Removing them after the rename left a window where a crash paired the new
.idx with the old .ldb, whose newer LOG skips the replay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: pin fix -verify fixtures to needle version 3
-verify reads v1 to v3 records, so its fixtures should not follow the
build's current needle version.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: refuse fix -verify on remote-tiered volumes
A remote-tiered volume is read from its remote .dat through the existing
.idx, so rebuilding that index from a local .dat would point it at the
wrong bytes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: pick a free backup name when fix -verify retries within one second
backupName fell back to path.bak.<unix time> without checking it, so a
second retry in the same second reused that name and the exclusive
create (or the .idx hard link) failed. Add a .<n> suffix until the name
is free.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: refuse fix -verify when the volume info cannot be read
An unreadable or unparsable .vif may name a remote tier, so treat it like one
and keep the existing index.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor: pass weed fix -verify options explicitly
* feat: move weed fix -verify into a weed fix.recover command
* docs: weed fix.recover help, point weed fix at it
* fix: keep the volume file helpers below runFix
Leaves the region between VisitNeedle and runFix as on master.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: build fix.recover fixtures at needle version 3
fix.recover reads needle versions 1 to 3, so its tests must not follow
GetCurrentVersion; writeFixTestVolume now takes the version.
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>
* filer: refuse unsafe chunk appends
* filer: report append representation preconditions
* filer: cover cached remote append eviction safety
* filer: cover lazy remote append refusal
* filer: refuse HTTP appends and offset writes onto remote-only entries
An HTTP append or offset write onto a remote-only entry stored the new
chunk with nothing below it, so reads returned zeros where the remote
bytes were and the entry stopped being remote-only. Small appends failed
with a retryable "inline file changed" error instead.
Refuse both with a client error, matching AppendToEntry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: AppendToEntry appends after a sparse tail
AppendToEntry placed new chunks at the end of the existing chunks, so a
file extended past them by a truncate got the appended bytes inside its
logical length instead of after it, and its size did not grow. Use the
entry size, as the HTTP append path does.
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>
* filer_pb: scrub cipher keys from both entries of an event
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* notification: keep chunk cipher keys out of webhook payloads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>