Commit Graph
16412 Commits
Author SHA1 Message Date
Chris LuandClaude Opus 5.5 2dbc5263bc seaweed-volume: fill a cold EC location cache from a partial lookup
write_back_shard_locations refused a reply placing fewer than the data
shards before writing anything, so a read on a cold cache kept an empty
map and could not fetch a shard directly from a holder the master did
name. A partial now fills only the shards the cache does not know,
leaves the refresh time alone and marks the map stale, as Go does. The
scrub still refuses a partial reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:38:36 -08:00
Chris LuandClaude Opus 5.5 d674199290 storage: fill a cold EC location cache from a partial lookup
A reply placing fewer than the data shards no longer reaches the cache
at all, so a cold cache stays empty and a read cannot go straight to a
shard whose holder is up, as it could before the guard counted placed
shards. Take the holders it names for shards the cache does not know,
without touching known shards or the refresh time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:38:36 -08:00
Chris LuandClaude Opus 5.5 e23c665523 storage: count only placed shards toward an EC lookup's completeness
The master answers every shard slot, so len(ShardIdLocations) is 32
whatever is up, and the guard that should keep a partial reply from
replacing a complete cache never fired. A reply placing fewer than the
data shards now fails the lookup and leaves the cache as it was, as the
Rust server does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:38:36 -08:00
Chris LuandClaude Opus 5.5 190aa130e2 seaweed-volume: a shard the master places nowhere is not a known location
The master answers LookupEcVolume with every shard slot it tracks, so a
shard whose holders are all down comes back with no locations. The cache
kept those entries. They overwrote the cached address of a holder that
was only restarting, counted toward the reply's data-shard guard, which
therefore always passed, and made the map look neither short nor
complete, so it was re-checked only every 7 minutes. Nothing marked it
stale meanwhile: a read never tries a shard with no address.

A shard with no location is now left out of the reply, as Go's
cachedLookupEcShardLocations does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:38:34 -08:00
Chris LuandClaude Opus 5.5 2037af1a37 erasure_coding: report and check the encode run when verifying a shard set (#12893)
* volume: report the encode run in VolumeEcShardsInfo

Go and Rust volume servers now fill EcShardConfig.encode_ts_ns from the
mounted EC volume's .vif, next to the block layout they already report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: keep the source when holders serve different encode runs

VerifyShardsAcrossServers records each holder's encode run, and
RequireAgreedEncodeRun fails when holders that report one disagree. The
encoder checks it before deleting the source volume, so a shard set that
only looks complete by shard ids does not replace the source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: refuse a holder that reports more than one encode run

A holder whose disks serve shards of different encode runs reports
MixedEncodeRuns, and RequireAgreedEncodeRun fails on it even when no
other holder answers or every other holder agrees on one run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: report mixed encode runs across local disks in VolumeEcShardsInfo

The reply listed shards from every disk under the first disk's encode
run. When the shard-bearing disks of a volume hold different nonzero
runs, Go and Rust volume servers now report MixedEncodeRuns instead, so
the source-deletion check sees the conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: refuse an EC shard copy of another encode run than the mounted one

VolumeEcShardsCopy committed the copied .vif and reopened replaced shards
without updating the mounted volume's encode run, so the holder kept
reporting the old run while serving the new bytes. Go and Rust volume
servers now stage the .vif before anything is committed and fail with
FailedPrecondition when it names a nonzero run different from a run this
server mounts for the volume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: list only mounted shards of every disk in Rust VolumeEcShardsInfo

The Rust reply listed every shard slot of the first disk's runtime, with
unmounted slots as size-0 entries, and skipped shards mounted on other
disks. Callers build each holder's shard bits from this list, so a Rust
holder counted as holding shards it did not have. The reply now lists the
mounted shards of every local disk, each id once, as Go does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: check the source encode run of an EC shard copy without a .vif

A copy that leaves out the .vif could still replace a mounted shard with
another encode run's bytes. Fetch the source .vif for the run check in
every copy, and install it only when asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: refuse to serve EC files of a volume held from two encode runs

CopyFile looks each requested file up on its own, so a server that holds
a volume's shards on one disk from one encode run and its .vif on another
disk from a different run would hand a copier mismatched files. Refuse
the copy when the .vif files of this server disagree on a nonzero run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: refuse a rebuild whose holders serve different encode runs

The rebuild groups holders by volume id and collection only. When they
serve two encode runs, the copied shards land beside the first run's
.vif and .ecx and the rebuild regenerates from the mixed set. Before
copying, ask every holder for its run and refuse unless they agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: bound each holder query in the rebuild's encode-run check

A holder that accepts the connection but never answers VolumeEcShardsInfo
kept the rebuild waiting forever. Give each holder its own deadline; one
that times out is skipped like an unreachable holder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: check only the rebuilder and copy sources for the encode run

The rebuild copies each shard from its first listed holder. Extra copies
are never read, so asking them for their run only adds servers that can
stall the check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: do not copy from a source whose encode run went unchecked

A copy source whose VolumeEcShardsInfo query fails or times out has an
unknown run. The copy fence on the rebuilder compares a source's run with
the run the rebuilder mounts, so on a rebuilder that holds none of the
volume's shards nothing checks it, and its shards could join a rebuild of
another run. The rebuild now skips such a source like a failed copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: leave holders of shards the rebuilder has out of the run check

The rebuild uses a shard the rebuilder already holds and never reads its
other listed holders, but the run check still asked the first of them. A
stale replica listed first for such a shard refused a rebuild that would
not touch it. Pick the holders to check the way prepareDataToRecover
picks its copy sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:32:05 -08:00
Chris LuandClaude Opus 5.5 ec87407c0d ec balance: don't let leftover shards of an earlier encode win dedup or move (#12888)
* ecbalancer: keep the majority encode run's copy when removing a duplicate shard

The dedup kept the copy on the node with the most free slots without
comparing copies. When a failed encode left a shard behind and a retry
encoded it again elsewhere, it could keep the stale copy and delete the
fresh one. Nodes now record each disk's encode identity; when a shard's
copies differ, only a copy from the run that holds most of the volume's
shards is kept, and the shard is left alone when no run has a clear
majority or none of its copies is from that run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec.balance, ec_balance: pass each disk's encode identity to the planner

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ecbalancer: keep only a complete encode run's copy, freeze conflicted volumes

A majority counted over a filtered snapshot can pick the wrong run, and a
shard left with conflicting copies could still be moved onto its other
copy by a later phase. Mixed-run duplicates are now resolved only in
favour of the one reported run that has every shard id, counted per disk,
since filters can hide shards but not add them. Otherwise the volume is
frozen: no phase of this plan moves its shards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec_balance: freeze EC volumes that still have a plain replica

Their shards belong to the encoder until the plain replicas are gone. They
stay in the plan's load counts but no phase moves or dedups them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ecbalancer: refuse dedup when an unreported run is also complete

A copy that carries no encode identity may be the newer set, so a second
complete run that does report one cannot be kept over it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ecbalancer: freeze a volume whose shard copies on one node disagree

A shard held on two disks of one node at different encode runs has no
duplicate on another node, so dedup skipped it, and a later move could
take the stale copy and delete the fresh one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:31:31 -08:00
7cc8a8a445 filer: run a file rename again when the store refuses its commit (#12892)
* filer: run a file rename again when the store refuses its commit

TiKV refuses an optimistic transaction's commit when another writer
committed one of its keys after it began. A rename's transaction moves the
source key, so a concurrent write of the file, through another filer for
instance, failed the rename with "move commit error: write conflict".
Standalone writes run again after such a conflict since #12798, but a
rename's transaction belongs to the rename, and it gave up.
StreamRenameEntry also sent the rename's responses before the commit, so
the client had already moved the file locally when the store refused it.

- The TiKV store reports such a refusal as filer.ErrTransactionConflict.
- A file rename runs its transaction again after it, up to five times; the
  new run reads what the other writer stored and moves that. A rename that
  copied or deleted a remote object on the way is not run again.
- On a store whose transactions keep their writes to themselves
  (filer.IsolatingTransaction: SQL, TiKV), a file rename holds its stream
  responses until the commit: a refused rename sends none, and one that
  runs again sends them once. A directory rename still streams its
  children's responses as it moves them, which keeps the client of a long
  rename from timing out, and is not run again.
- Every failed run releases its commit stamps and rolls back, the "is not
  empty" refusal included.

Tests: filer_grpc_server_rename_conflict_test.go, with a store that keeps a
transaction's writes until its commit and can refuse it, and
tikv_store_commit_test.go (-tags tikv). On master the retry, refused-commit
and remote-file tests fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: run a rename again only when its transaction covers every write

With path-specific stores configured, the writes under their prefixes do
not go through the default store's transaction: a parent directory a rename
creates at its destination there stays when the commit is refused, and a
rename run again finds it and announces only the file's move, so peers
replaying the events never learn of the parent.

IsolatingTransaction now holds only when no path-specific store is
configured, and AtomicRenameEntry checks it too before running a rename
again, as StreamRenameEntry does through its held responses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: finish a committed rename before its held responses go out

StreamRenameEntry sent its held responses before the work the commit leaves
(metadata events, chunk deletions, remote copies). A client that stops
reading without closing the stream blocks Send on flow control, and that
work then never ran. It now runs first; the responses still follow the
commit.

A file with a remote object no longer holds its responses: its remote copy
after the commit is part of that work, and the client should not wait for
it. It streams as it moves, as before, and is not run again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: let the store say that its transactions isolate a rename

Whether a rename's responses wait for the commit, and whether it may run
again, was inferred from the context BeginTransaction returned and from
whether any path-specific store was configured. Neither holds up:

- A store may hand back a transaction context that its writes do not use:
  YDB begins a table-service transaction, and its statements run through
  the query service outside it. A store now says so itself, through
  IsolatingTransactionStore, which the TiKV store implements. Any other
  store keeps sending a rename's responses as the entries move and does not
  run it again, as before this PR.
- A path-specific store only matters for the paths it holds.
  Filer.TransactionCovers asks whether the rename's source and destination
  live in the default store: a rename that stays there holds its responses
  and may run again, and one that writes into a path-specific store does
  neither.

A rename that may not run again still must not announce changes before its
commit, so a file with a remote object holds its responses too. So that its
remote copy after the commit does not delay them, the held responses go out
while the rename finishes, and the call returns once both are done.

A held response checks the stream's context, so a rename whose client went
away before its first response is rolled back, as when the responses go
out at once, instead of committed unseen.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* filer: the SQL stores isolate their transactions too

AbstractSqlStore takes the sql.Tx its context carries for every entry call
(getTxOrDB) and every KV call (kvDB, also when KV has a pool of its own),
so the SQL stores built on it meet what IsolatingTransactionStore asks. A
file rename on them holds its responses until the commit again, as it did
before the declaration became explicit; it is never run again, since no
SQL store reports ErrTransactionConflict.

Bucket tables are created and dropped outside the transaction, which a
file rename does not do.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* abstract_sql: check that a transaction's writes take its own handle

sqlmock serves a pool and its transactions from one mock, so the write
expectations also pass for entry writes made through store.DB. Assert that
getTxOrDB and kvDB return the *sql.Tx the context carries.

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>
2026-11-22 10:25:17 -08:00
Chris LuandClaude Opus 5.5 856762b20d volume.fix.replication: keep every needle on copyCount survivors when trimming (#12897)
* volume.fix.replication: keep every needle on copyCount survivors when trimming

The trim refused only needles that no survivor held. When replicas have
diverged, a needle written while one survivor was down could be held only
by the doomed replica and one other survivor, so the trim left it on a
single copy while the volume still looked healthy. Count the survivors
holding each live needle and refuse unless it stays on
min(copyCount, survivors) of them; a delete on any survivor still covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* balancer: list trim candidates best first

PickOneReplicaToDelete and PickOneMisplacedVolume now return the first of
ReplicasToDelete and MisplacedVolumesToDelete, which list every replica
the pick chooses from in the same order, so a caller that refuses the
pick can try the next one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume.fix.replication: trim the next candidate when the pick is short

When the preferred replica would leave a needle short of copies, try the
next candidate in the same preference order instead of skipping the
volume. A replica that missed writes is often the only safe one to
trim, and it need not be the smallest. Index and status errors still
skip the volume.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume.fix.replication: fold survivor indexes into per-needle counts

countUncoveredNeedles kept every survivor's filtered index until the
check ended. Count the survivors holding each needle of the doomed
replica in a byte per needle instead, and release each survivor's index
before reading the next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume.fix.replication: test a rewrite after a delete on one survivor

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:22:18 -08:00
Chris LuandClaude Opus 5.5 8d4ec5252a iam: evaluate credential trust policies with the policy engine (#12895)
* iam: evaluate credential trust policies with the policy engine

AssumeRoleWithCredentials and the Iceberg credential vending path checked
a role's trust policy by scanning for a matching Allow statement only, so
an explicit Deny never took effect. Evaluate the trust policy through
EvaluateTrustPolicy, as AssumeRole and AssumeRoleWithWebIdentity do, so a
matching Deny wins over an Allow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: keep the Federated provider match for credential trust Allows

Matching Allow statements through the shared trust matcher let
{"AWS":"*"}, "*" and empty principal objects admit credential-provider
users, and made Allow conditions fail closed on keys this path does not
supply, such as the vending duration. Keep the exact Federated provider
check for Allow and use the policy engine only to find a matching Deny,
with the requested session duration in the context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:20:57 -08:00
Chris LuandClaude Opus 5.5 04050e781b ci: give recursive cosign signing more than the 3m default timeout (#12896)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:19:54 -08:00
040ff9049c filer: roll back a stream rename refused for a non-empty target (#12886)
* filer: roll back a stream rename refused for a non-empty target

StreamRenameEntry refuses to move a directory onto a non-empty one, but
returned without ending the transaction it had begun. On a SQL store
(MySQL, Postgres and the stores built on them) that transaction keeps its
pooled connection: it was begun under context.Background(), so database/sql
never rolls it back by itself. Every such refusal holds one more connection
for the life of the filer, and once connection_max_open (50 in the scaffold)
are held, store calls wait for a connection that never comes back.

Roll the transaction back before returning, as the function's other
refusals already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: check a stream rename's target directory inside its transaction

The not-empty check listed the target under context.Background(), outside
the transaction the rename had already begun. The SQLite store's main pool
has a single connection, which the transaction holds, so every directory
rename onto an existing directory waited for that connection forever and
the filer's store stopped answering. On a bounded SQL pool, concurrent
renames that each hold a transaction can wedge the same way.

List through the transaction's context, as the child move already does.

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>
2026-11-22 10:18:25 -08:00
Yip LeoandClaude Opus 5.5 78e2a4c2b4 mount: check the next inode number before AllocateInode returns it (#12884)
AllocateInode probes from the number a path hashes to while that number is
taken, but the loop re-checked the number it had just stepped off and then
advanced once more. When the first candidate was taken, it returned the
number after the first free one without looking at it, and that number can
belong to a live file.

The new entry stores the number in its attributes and the mount reports it
as st_ino, so the two files stat as the same file. A writer that replaces a
file with tmp + rename several times a second runs into it: the next temp
file hashes to the number the previous one carried to the target, and GNU mv
refuses the replacement with "are the same file". With readers holding the
replaced file open, 56 of 3446 such replacements failed that way on our
mounts; none did with this change.

Lookup's probe already checks the next number; AllocateInode now does the
same.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:17:25 -08:00
32d4633298 filer: list the metadata log from the scan start, not from midnight (#12885)
* filer: list the metadata log from the scan start, not from midnight

A pass over the persisted metadata log lists the start day's directory
from its first file, then skips the files before the scan start's minute.
Each filer writes up to one log file a minute, so late in the day a pass
reads up to 1440 entries per filer from the filer store to find the few
after the scan start: with three filers and a scan from 12:29, 2254
entries for 6 files.

Every disk pass pays this: SubscribeMetadata and SubscribeLocalMetadata
whenever a subscriber reads from disk (filer.sync, filer.meta.tail or an
S3 gateway resuming from an earlier position, or catching up), and
CollectLogFileRefs for chunk-capable subscribers.

List the start day from the scan start's minute, in the log file
collector and in CollectLogFileRefs. The files before it were skipped
anyway, so a pass reads the same files; later days are still listed from
their beginning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: list the whole log day on a store that does not list by name

Elasticsearch pages a directory by a hash of the entry path, not by name, so
a listing there cannot start at the scan start's minute: an inclusive start
re-reads the first page, and an exclusive one starts at an arbitrary point
of the hash order. Stores now say so through UnorderedListingStore, which
the Elasticsearch store implements, and the log passes list the whole start
day on them, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: ask the store of the log day directory whether it lists by name

The order check looked at the store of SystemLogDir. A path-specific store
can serve a day directory under it, so ask the store that lists the day.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test a log day served by a path-specific unordered store

The stub store now lists the root directory of a path-specific store, which
the translator hands it as "/".

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>
2026-11-22 10:16:24 -08:00
b4f5b1a354 mount: hold a rename's names against this mount's own publications (#12889)
* mount: hold a rename's names against this mount's own publications

A rename of an open file can fail with EIO on a filer store with optimistic
transactions (TiKV). Rename publishes the handle's deferred create first. A
FLUSH of the same handle (a forked child closing the inherited fd, say)
that looked at the dirty flag before that publication waits on the locks,
then publishes the identical entry again while the filer moves the file,
and TiKV refuses the rename's commit on the source key ("write conflict
... reason:Optimistic"). safetensors checkpoints hit this: they write
.tmpXXXXXX and rename it while the fd is still open, and our training jobs
fork a subprocess every second.

- flushMetadataToFiler checks dirtyMetadata again under its locks and
  publishes nothing for a handle another flush has already published.
- Rename holds the publication locks of both names, in path order, across
  the filer call and the local move. A flush, chmod/utimes or xattr change
  of either name through this mount waits for it, then publishes under the
  name the rename left: lockFlushTarget (content flushes, now also the
  periodic flush) and lockNodePublication (attribute changes) resolve the
  name again after the wait. A failed rename restores the target's handle
  before the locks go.

Tests: weedfs_rename_publish_test.go, with a filer that records every
write made while a rename is in flight. On master six of the seven fail,
the incident among them (the deferred create published twice); the one
that passes guards against deadlock between renames. The chmod stress run
fails on master with ENOENT. TestFlushMergeThroughChunkProxy marks its
handle dirty before it flushes: doFlush only flushes a handle with changes,
and the clean handle it used would now publish nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: give up on an attribute change whose node keeps moving

lockNodePublication went ahead on its fourth wait even when the node had
been renamed again meanwhile, and the change went to a name the node no
longer had, without that name's lock. It now returns EAGAIN then, as the
flush path already refuses after its fourth try. The stress tests accept
EAGAIN from a chmod racing back-to-back renames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* mount: test the chmod that gives up on a file that keeps moving

The chmod waits for a name's lock that the test holds shared, so a
shared try fails exactly while the chmod is queued for it; the test
moves the file each time, four times, and expects EAGAIN with nothing
written.

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>
2026-11-22 10:11:42 -08:00
8046d5c78a fix(iceberg): keep concurrent namespace property changes (#12890)
* iceberg: keep concurrent namespace property changes

UpdateNamespaceProperties merged the request into a copy read by
GetNamespace and wrote the whole map back, so when two requests changed
different properties of the same namespace at once, both answered 200
but only one change was kept. Apply the changes inside the
compare-checked write instead, and answer 503 with Retry-After when
every attempt loses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3tables: keep stored namespace properties out of a PropertyChanges answer

UpdateNamespace does not grant GetNamespace, so answering a PropertyChanges
request with the merged map let a caller allowed only to update read every
stored property, even with an empty change. Echo only what was sent, as the
Properties form does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3tables: describe the PropertyChanges form of UpdateNamespace

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>
2026-11-22 10:09:48 -08:00
Chris LuandClaude Opus 5.5 5afeb20ad6 s3: enforce BlockPublicPolicy and RestrictPublicBuckets for bucket policies (#12882)
* s3: refuse a public bucket policy when the bucket blocks public policies

PutBucketPolicy stored and enforced a policy granting access to every
principal even with BlockPublicPolicy set. Check the stored public access
block on the bucket entry that the policy write reads, and answer
AccessDenied for a public policy. A policy counts as public when an Allow
names a wildcard principal (or uses NotPrincipal) and no fixed-value
restricting condition such as aws:SourceIp or aws:SourceVpce narrows it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: keep a public bucket policy from granting anonymous access under RestrictPublicBuckets

With RestrictPublicBuckets set, an anonymous request was still allowed by
a public bucket policy. The bucket policy engine now treats such an Allow
as granting nothing when the bucket restricts public buckets and its policy
is public, so the request falls through to the remaining checks instead of
reading as an explicit deny. A bucket whose configuration cannot be read is
treated as restricted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: write a bucket policy only over the extended attributes it checked

setBucketPolicy rewrote the whole bucket entry it had read, so a public
access block set between the BlockPublicPolicy check and the write was
erased and the public policy stored anyway. Send the read extended
attributes, including an absent public access block, as the update's
expected values, and redo the read and check when they changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: count more policy forms as public

An empty principal list and a principal holding a policy variable can both
match anyone, so they are public. An aws:SourceIp range wider than /8
(IPv4) or /32 (IPv6) no longer restricts a grant. An ARN condition value
with a fixed account, such as an access point ARN with a wildcard name,
does restrict it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: deny anonymous callers outright on a restricted bucket with a public policy

RestrictPublicBuckets limits a bucket with a public policy to callers of
the owning account, so dropping only the policy's own grant left public
ACLs able to serve anonymous reads. While the policy is public, the policy
engine now answers an anonymous request with a deny. It checks before and
after evaluating, so a policy replaced in between cannot let an anonymous
grant through. A bucket without a policy, or with a non-public one, is
unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: count an empty principal string as public

A principal of "" compiles to no principal check, so it matches anyone,
the same as an empty list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: write a bucket policy only over the bucket entry it checked

The policy write replaced the whole bucket entry and asserted only the
public access block key, so a bucket setting first written between the
lookup and the write (versioning, for one) was dropped. Pin the write to
the entry it read; any concurrent change fails it and the lookup retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: judge an IPv4-mapped aws:SourceIp range by its IPv4 prefix

::ffff:0.0.0.0/96 parses as a 128-bit network but matches every IPv4
caller, so it passed the /32 IPv6 bound and a public policy slipped past
BlockPublicPolicy and RestrictPublicBuckets. Apply the IPv4 /8 bound to
mapped ranges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 02:23:12 -08:00
Chris LuandClaude Opus 5.5 8ffce492fd s3: time each stage of an object write (#12883)
* s3: time each stage of an object write

SeaweedFS_s3_request_seconds times the whole handler, so a slow PUT tail
cannot be split into client upload time and server time. putToFiler now
records SeaweedFS_s3_put_stage_seconds{operation,stage} per write:
body_read (blocked on the request body), assign (volume assigns),
chunk_upload (upload time apart from body reads: waiting on chunk
uploads), and metadata (from the uploaded chunks to the committed entry).
operation is PutObject or UploadPart; no per-bucket or per-object labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* grafana: chart the S3 PUT stage p99

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: count body reads made before putToFiler in body_read

mimeDetect reads the first bytes, and a POST upload parses the whole form,
before putToFiler starts, so a slow client showed little body_read time.
track now times every read of the request body, body_read reports the
request's total, and chunk_upload subtracts only the reads made during
the upload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: observe body_read once per request

An archive upload writes one object per member, and every write reported
the same request-wide body read time. The first write to finish now
reports it; the other stages stay per write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: name the non-read upload stage storage

The chunked upload runs volume assigns inside the chunk upload goroutines,
so its time apart from body reads covers assigns and chunk uploads, and
the uploads themselves cannot be timed from outside UploadReaderInChunks.
Call that stage storage; assign stays the summed assign time within it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: record a zero body_read for writes without a body

timeBodyReads attached no timer to bodyless requests, so a zero-byte PUT
or an UploadPartCopy recorded every stage but body_read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3: observe body_read after the handler so it covers every write

An archive request writes several objects from one body. Observing
body_read at the first write's record left out the reads of the later
members. record now only marks the request, and track observes the
request-wide total once the handler returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:59:11 -08:00
Chris LuandClaude Opus 5.5 f3b838e234 ec: encode past deletes a replica missed while it was down (#12879)
* volume_replica: encode past deletes a replica missed

A delete that reaches only some replicas, for example while one is
down, leaves that replica holding the needle live. The encoder's idx
gate then refused the volume forever.

A needle live on one replica and tombstoned on another by a record
appended after that write is a delete the first replica missed.
MissedDeletes finds them; the gate leaves them out of the live-set
comparison and encodes from a replica that holds none of them, so the
EC volume does not bring them back. A tombstone older than the live
write, a needle absent on the other side, and volumes without
AppendAtNs still refuse, as does a volume where every replica missed
some delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: test encoding a volume one replica missed a delete on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: prove a missed delete from one replica's own index

AppendAtNs comes from each server's own clock, and vacuum's makeupDiff
re-stamps tombstones it carries over with the commit time, so comparing
a tombstone's AppendAtNs against another replica's write can order a
later rewrite before an older delete.

Prove the delete instead from the replica that applied it: its .idx
shows the live row the tombstone replaced, and when that record has the
same cookie, CRC and last-modified time as the needle still live on the
other replica, that very write was deleted. Replicated writes share all
three, a rewrite does not. A tombstone with no earlier write row (its
write vacuumed away) proves nothing and still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: test a missed delete with a third replica holding no row

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: never count a needle its own replica deleted as missed

A same-content upload with the same ts after both replicas deleted the
needle matches the deleted write on cookie, CRC and last-modified. The
replica holding it has its own tombstone for the needle before that
live row, which a replica that missed the delete never has, so skip it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: count a missed delete only for a needle written once

An overwrite that keeps cookie, CRC and last-modified, such as a TTL
volume re-append or a client-set ts, also matches the write another
replica deleted. A replica whose own index replaced an earlier row for
the needle, by an overwrite or by its own delete, may hold a write made
after that delete, so it never counts as having missed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* ec: compare capacity replicas first so a clean one is the encode source

When the preferred replica missed a delete, the gate falls back to the
first replica that holds none, and that could be one without the free
slots RequireCapacitySource needs, failing the encode although another
capacity replica was clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: keep the row an offset-0 delete removes as an earlier write

A remote-tier delete writes an offset-0 row and drops the key, so a later
identical rewrite looked written once and could count as a missed delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: refuse a missed delete whose live write is not older than the tombstone

Compaction keeps only the latest row per needle, so a same-meta rewrite
after the delete can lose the earlier row that marked it as rewritten.
Its record still carries its own append time, which then is not older
than the tombstone. The index proof still decides; the clocks only refuse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume_replica: count a missed delete only when both replicas appended the write together

Compaction can drop the rows that show a replica rewrote a needle, and the
tombstone stamp is not a reliable delete time: a vacuum commit stamps
deletes made during the copy with the commit time, and replicas stamp with
their own clocks. A replicated write lands on every replica within the
forwarding time plus clock skew, so the live write and the deleted write
must also be stamped within a minute of each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 00:00:28 -08:00
Chris LuandClaude Opus 5.5 dda0a57584 filer: announce the directories a rename creates at its destination (#12880)
* filer: let a suppressing caller collect the parents it creates

Under suppressed metadata events, ensureParentDirectoryEntry creates
missing parent directories without announcing them and releases their
stamps, since the caller's own event covers only its entry.
WithCreatedParents keeps the suppression and also collects those
directories, with their stamps, so the caller can announce them once its
change commits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: announce the directories a rename creates at its destination

A rename into a path whose parents do not exist yet created them without
metadata events. A peer filer with its own store replays events into that
store and never got the new directories: it found the moved entry by path,
but listing its new parent's parent showed nothing. The rename now
publishes a create event for each new parent ahead of its own event, after
the commit, and releases their stamps if it fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: announce a parent a rename promotes from a file to a directory

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: announce a promoted parent as replacing the file

A parent promoted from a file to a directory was announced as a create,
so a peer whose store does not upsert refused the insert over the file
row it already held and could not move past the event. Announce the
promotion with the file as the old entry, both from a plain create and
from a rename's collected parents, so a peer replays it as a replacement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: keep announcing a promoted parent as a create

filer.sync applies a same-path update through FilerSink.UpdateEntry, and
the destination filer refuses to turn its file into a directory, so an
event carrying the file as OldEntry stalls the sync. Ordinary writes have
always published a promotion as a create; the rename publishes the same.

This reverts commit 85760c084f.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 23:57:55 -08:00
c80bf3afac util/http: stop waiting on a response body the server stalls (#12875)
* util/http: stop waiting on a response body the server stalls

CloseResponse reads the rest of a response body so that the connection
can be reused, and StatusError reads the message a server puts in the
body of a failed request. Neither had a time limit. The client's only
read deadline covers the response headers, so when a server sent its
headers and then stopped sending the body, both blocked until the
request's context ended. Most callers pass a context that never ends.

A chunk read whose replica answered 404 or 500 this way never returned,
so it never got to the next replica. That holds for ReadUrlAsStream and
for the replica fallback of S3 copies.

Both now close the body once 5 seconds have passed. That fails the
blocked read, and the connection is dropped instead of reused. A body
that arrives in time is drained as before, and its connection is still
reused. StatusError reports the status with whatever part of the
message arrived.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* util/http: bound a body read that closing the body cannot interrupt

The limit worked by closing the body, which fails a read blocked on it.
That does not hold when the transport decodes gzip for the caller: in Go
1.26 its decoder reads the gzip header under a lock that Close also
takes. A server that announced gzip and stalled before the gzip header
kept both the read and the Close waiting, so the limit never applied.

Such a response is now read on its own goroutine, and the caller stops
waiting when the time is up. The read and the Close stay behind until
the connection dies. Every other response keeps the cheaper way, with
no goroutine.

StatusError now returns the status alone when the message did not
arrive in time. A partly read message is no longer safe to use, because
the read may still be running.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 21:13:49 -08:00
Chris LuandClaude Opus 5.5 3796162ba6 erasure_coding: clear stale EC shards on every holder the master lists (#12876)
* plugin/worker: look up a volume's EC shard holders on the master

LookupEcVolumeLocations returns every server the master currently lists
for any shard of the volume. The master's "ec volume N not found" answer
means no holders; any other failure is returned.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: clear stale EC shards on every holder the master lists

The encode preflight and the post-distribute rollback cleared stale
shards only on the planned targets and on the EC holders detection saw.
A server that was down at detection and came back with a failed
attempt's shards was outside both, so its shards survived and ended up
beside the new encode: EC balance could later keep that stale copy as a
duplicate.

The cleanup now also asks the master for the volume's current holders
and clears every one of them. A lookup failure counts as a cleanup
failure, so the preflight retries later instead of encoding beside
shards it cannot see. Without a master address the cleanup behaves as
before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: ask every master for the EC shard holders

The execution defaults keep only the first master address, so a follower
there failed every holder lookup and with it the encode preflight. The
plugin handler now hands the task the whole cluster master list, and the
lookup moves on past a master that refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* erasure_coding: refuse the preflight wipe when a regular replica is gone

A replayed job whose earlier run already committed the EC copy and
deleted the source would wipe those shards, now on every holder the
master lists, before failing on the missing source. Check that every
regular replica is still there before clearing anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:13:21 -08:00
Chris LuandClaude Opus 5.5 f8d3722143 shell: refuse a replica trim that would drop a needle no survivor holds (#12878)
* shell: refuse a replica trim that would drop a needle no survivor holds

The -doCheck pass before volume.fix.replication deletes a surplus
replica compares it with each survivor in turn without resurrecting
absent needles, so a needle live on the doomed replica and missing on
every survivor passed the check. Trimming then deleted its only copy if
it was a missed write. Count, across all survivors, the live needles
none of them holds live or deleted, and skip the trim when there are any.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* shell: count a remote-tier survivor's delete as covering the needle

A remote-tier replica records its deletes with offset zero, and the
filtered index load drops those keys, so the trim check saw the needle as
held by no survivor and refused the trim on every run. Walk survivor
indexes unfiltered: any entry for the key covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* shell: keep the trim's final survivor check under test

The coverage check reads each survivor's index a second time, so the
survivor that disappeared after its first index read now failed that
read and the final VolumeStatus check was never reached. Make it
disappear after the second read and require the status check to run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 21:12:33 -08:00
Chris LuandClaude Opus 5.5 95a4113c1e volume(rs): append an EC delete outside the store lock (#12874)
* volume(rs): give the EC deletion journal its own lock

The .ecj append handle and its size move behind a per-volume mutex, Go's
ecjFileAccessLock, shared through an EcJournalAppender that outlives the
store lock that found the volume. Closing or dropping the volume closes
the journal under that lock, and the decode takes it for its catch-up
passes, so an append in flight is either fully read or not at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): append an EC delete outside the store lock

VolumeEcBlobDelete and the local EC delete of the HTTP path held the
store write lock through the journal append and its fsync, on a runtime
worker. On a slow disk a stream of deletes kept the store write-locked,
and readers queued behind the waiting writer, heartbeat collection
included, until the master dropped the server.

They now resolve the volume and its needle under the store read lock,
then append and fsync on a blocking thread under the volume's journal
lock. The decode tail is checked under that lock, which the decode
takes after claiming the tail, so a delete still cannot commit behind
the rebuilt index. A volume closed in between is resolved again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): share a .ecj append lock across disks holding the file

Disks can mount runtimes of one volume that journal into the same .ecj,
each with its own handle and journal lock. With deletes appending
outside the store lock, a delete through one disk could land while
another disk's rebuild folded and replaced the file, or while a new
mount loaded it, and be lost or cached before its rollback.

The ecj registry now hands every holder of a path one append lock.
Appends take it before the disk's journal lock, a mount holds it
through its tail repair and load, and a rebuild holds it through the
fold and every sibling's adoption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): roll a failed .ecj append back to the file's real length

The rollback point was the handle's cached size, which misses records
another disk holding the same journal appended since, so a failed sync
on one disk could truncate a sibling's committed delete. Take the
length from the file itself, under the path's append lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): an EC sync does not wait for a journal append in flight

CopyFile syncs the EC volume under the store read lock, and the .ecj
sync now took the journal lock, so it waited out a delete's fsync with
the store guard held. Every committed append already syncs its own
record, so skip the journal while one holds its lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): repoint sibling .ecj handles when the fold fails after the unlink

A rebuild fold that removed the journal and then failed to reopen it
returned before the sibling disks sharing the .ecj adopted the new file,
and one sibling's failed adoption skipped the rest. A delete parked on
the path lock could then append to the removed inode and be acknowledged,
then lost at restart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: reopen sibling .ecj handles even when the folded mount's reopen fails

RebuildEcxFile unlinks the shared journal; the sibling reopen loop ran
only when the folded mount's own reopen succeeded and stopped at the
first sibling error, leaving the remaining handles on the detached inode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): order the EC delete tail test on the path lock, not sleeps

The delete holds the .ecj path lock exactly while it waits on the
journal lock the test holds, so the store probe and the tail claim wait
for it to be busy, and the commit check waits for it to be free again.
A tail check taken before the journal lock now fails the test every run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume: track the fold outcome without rewriting the rebuild call

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume(rs): find a folded journal's siblings by the registry's path key

The sibling check compared raw .ecj paths, so a runtime reaching the same
journal through a differently spelled index directory shared its append
lock but was not repointed after the fold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 20:39:59 -08:00
Chris LuandClaude Opus 5.5 8be0837c20 s3api: try the next replica when a copied encrypted chunk does not decrypt (#12872)
A copy stores a per-chunk-encrypted chunk's ciphertext as-is, so a replica
whose needle is cut short or diverged became the copied chunk unnoticed.
Open the GCM tag of a whole-needle read and fail that replica when it does
not authenticate; a compressed ciphertext has no expected length to check.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 18:44:57 -08:00
github-actions[bot] 279d2d2c03 docs: regenerate star history chart 2026-11-22 00:34:57 +00:00
Harrison Crosse 88aa5e9ebe s3api: validate x-amz-checksum-* headers on DeleteObjects (#12868)
* s3api: validate x-amz-checksum-* headers on DeleteObjects

* s3api: reject malformed query escapes, non-canonical signed Content-MD5, and test presigned DeleteObjects

* s3api: share canonical Content-MD5 parser and index query keys once
2026-11-21 13:23:42 -08:00
cbce146a63 s3api: keep a long CopyObject/UploadPartCopy alive with whitespace, as AWS does (#12862)
* s3api: keep a long CopyObject/UploadPartCopy alive with whitespace, as AWS does

CopyObject and UploadPartCopy copy every chunk and only then write the
response. On a slow volume disk (~10 MB/s), or when the source is a
remote-only file of a remote-mounted bucket that is fetched first, a copy of
tens of MB sends no byte for 20-30 s. Clients with a low-speed check give up
while the copy finishes: the AWS SDK for C++ (pyarrow, among others) sets
libcurl's CURLOPT_LOW_SPEED_LIMIT to 1 byte/s over a few seconds, and the
abandoned copy leaves an orphan.

AWS S3's documented behaviour for long copies: answer 200 at once, keep the
connection alive with whitespace, then send <CopyObjectResult> (or an
<Error> document) in the body. This does the same:

- Once every check that refuses with its own status has run (auth, missing
  source, preconditions, invalid arguments, ACL and lock headers, the
  remote-cache 503), a copy still running after 1 s commits to 200,
  application/xml and the XML declaration, then sends one space a second,
  flushed, until <CopyObjectResult>/<CopyPartResult> (checksum in the body)
  or an <Error> with the code the handler would have answered. A copy that
  ends sooner answers byte for byte as before.
- Armed before a remote-only source is fetched into the cluster, which is
  the slow part on a remote-mounted bucket.
- Never kept alive: the metadata-only self-copy; a destination with
  versioning Enabled (x-amz-version-id is known only after the copy); a part
  copy whose upload or request carries SSE (its response headers are known
  only after the copy).
- One goroutine owns the ResponseWriter from arming until halt() returns;
  a client that leaves ends it without touching the copy.
- s3err gains StartStreamingResponse, ErrorResponseFor and EncodeXMLBody,
  shared with WriteErrorResponse.

Accepted: a slow failure is 200 + <Error>, as on AWS, and the request is
counted as 200.

Tests: s3api_object_handlers_copy_keepalive_test.go (slow success and
failure, fast unchanged, a refusal keeps its status, part copy, versioned
destination, SSE-C part, checksum in the body, remote fill covered, client
gone under -race, slow lookup then bad tag = 400, self-copy 412 under the
lock, part range on a remote-only source). With the keep-alive forced off,
the slow-copy tests fail.

* s3api: send a block of spaces per copy keep-alive tick

libcurl rounds its measured rate down, so one byte a second sits right
at the AWS SDK for C++'s 1 byte/s low-speed limit and jitter can trip it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: audit a kept-alive copy error at the 200 it was sent with

Once the keep-alive has sent 200, the <Error> rides in that response, so
the access log records 200 and the error code, as AWS server access logs do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: fill a conditional remote-only copy source before the keep-alive

A source condition read the filled entry only after the keep-alive had
committed 200, so a slow fill turned its 412 (or the 400 of a malformed
date) into an <Error> inside a 200. With any x-amz-copy-source-if-*
header the fill runs first, as it did before the keep-alive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: fill a remote-only self-copy that moves data under the keep-alive

Only a self-copy that can stay metadata-only needs its source filled
before the keep-alive; one that re-encrypts takes the data path, so its
fill is the slow part the keep-alive is for. A fill changes no
encryption state, so the unfilled entry decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: test that the copy keep-alive reaches a client mid-copy

A ResponseRecorder keeps every write, flushed or not; over a real
connection the declaration and the spaces must arrive while the copy is
still held.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: bound the copy keep-alive streaming test with a request deadline

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>
2026-11-21 13:05:04 -08:00
Chris LuandClaude Opus 5.5 40fe40556c filer.meta.backup: list large etcd directories without the 3s request deadline, skip excluded subtrees (#12870)
* filer/etcd: list a directory without the request deadline

etcd counts every key left in a range even when the request is limited,
so one page of a directory costs time that grows with the entries after
it: about 0.3 s at the start of a 4 million entry directory on an idle
local etcd, against 1.6 ms near its end. The 3 s request_timeout therefore
fails listings of large directories, which a long walk such as
filer.meta.backup reaches page after page, with "list <dir> : context
deadline exceeded". Listings keep the caller's context like
DeleteFolderChildren; keepalive still ends a call to a member that stops
answering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer_pb: let a TraverseDfs callback skip a directory's subtree

fn returning fs.SkipDir for a directory leaves its subtree unlisted; the
directory is still reported as walked, so a resumed walk passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.meta.backup: do not walk directories the path filter leaves out

The walk listed every directory and dropped excluded entries one by one,
so -excludePrefixes could not keep it out of a directory: a huge or
failing excluded directory was still listed page by page. A directory
that is not included and has no include prefix under it is now skipped
whole.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.meta.backup: resume outside a directory the path filter leaves out

A walk saved before the filter skipped directories, or before the filter
changed, can hold a position inside a directory the walk now leaves out.
Resuming there entered the directory without asking the filter and listed
it. The resume position moves to the topmost such directory, which a
resumed walk treats as done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer.meta.backup: skip the walk when the path filter leaves out its root

The root of the walk is never handed to the callback, so a -filerDir the
filter leaves out was still listed. Nothing under it would be backed up,
so the walk now ends before it starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 11:23:36 -08:00
Chris LuandClaude Opus 5.5 f6d2a42265 s3api: authenticate unsigned requests by a verified client certificate (#12871)
* iam: let an identity name the client certificates it authenticates with

An Identity gets a list of CertificateMatch entries: a URI SAN, a DNS SAN
and a subject CN, every field set having to equal the certificate's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: authenticate an unsigned request by its verified client certificate

With -tlsVerifyClientCert the gateway verifies every client certificate,
but the certificate took no part in naming the identity. A request that
carries no signature or token now authenticates as the identity whose
certificates match the leaf of the chain the gateway verified, and goes
through the same authorization as a signed request from that identity.
Only a verified chain counts. A signature or token still decides the
identity on its own, a certificate matching a disabled identity or more
than one identity is refused, and a certificate matching none leaves the
request anonymous as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: keep certificate identities off the anonymous read paths

AuthWithPublicRead and the deferred anonymous object read classified a
request by its headers alone, so an unsigned request authenticated by its
client certificate would have been authorized as the anonymous principal:
a GET in a private bucket was refused. They now treat a request whose
certificate names an identity like a signed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: keep a user's certificate mappings when the dashboard edits it

UpdateObjectStoreUser and UpdateUserPolicies save a rebuilt identity, which
left out the certificates, so editing a user's email or policies ended
their certificate authentication.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* credential/postgres: store a user's certificate mappings

The PostgreSQL credential store keeps each identity field it knows in its
own column, so certificates were dropped on save and a user configured
there could not authenticate by certificate. Users get a certificates
JSONB column, added to existing tables like policy_names, and every user
query reads or writes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 11:07:24 -08:00
48f9a1f891 s3api: read a copy's source chunk from another replica when one cannot serve it (#12865)
* s3api: read a copy's source chunk from another replica when one cannot serve it

CopyObject and UploadPartCopy looked up the source volume and always read
from the first location the lookup returned. When that replica could not
serve the chunk (it was down, or it was missing a needle the other replicas
hold), the copy failed with 500 even though the object was fully readable:
GET falls back to the other replicas, copy did not.

Keep every location from the lookup and try them in order:

- the streaming path opens the source on the first replica that answers
  with the chunk. It only moves to the next replica before any byte has
  been forwarded to the destination.
- the buffered path (encrypted or rewritten chunks) retries the whole
  download on the next replica and discards a partial read.

When no replica can serve the chunk the error lists what each one answered.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* s3api: try the next replica when a buffered copy read comes back short

A replica holding a shorter needle answers the range clamped, with a
clean end, so the download looked complete and the copy kept the short
data instead of reading the healthy replica. Plaintext reads now need the
full requested length; cipher chunks are still checked by decryption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: skip a replica whose streamed copy source is shorter than the chunk

The streaming path checked only the status, so a replica holding a shorter
needle had its clamped range forwarded and the destination stored a short
chunk. An uncompressed response that declares fewer bytes than requested
now moves on to the next replica before anything is written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
2026-11-21 11:05:18 -08:00
Chris LuandClaude Opus 5.5 0aca7d1d6c ci: install Caddy from the pinned GitHub release (#12864)
caddyserver.com/api/download now answers 401 without a login or API
key, so the awscli-over-https job failed in Setup Caddy on every run.
Download the v2.11.9 release tarball instead and verify it against the
release's SHA-512 checksums.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 11:02:34 -08:00
cf00eae537 filer: end retried deletions of chunks on volumes the master no longer knows (#12860)
* filer: end retried deletions of chunks on volumes the master no longer knows

The deletion lookup read volume locations from the client's cache only. A
chunk on a volume the cluster no longer has (a dropped collection, a removed
bucket) found no location, so no volume server was asked, no deletion result
came back, and the retry queue re-queued it "to avoid loss". The durable
deletion ledger keeps such ids and reloads them with a fresh retry count on
every restart, so MaxRetryAttempts never ends them: on one deployment 2,337 chunks
on 159 deleted volumes were retried 2-4 times an hour for days, ~7,000
warnings an hour.

The retry loop's lookup now asks the master about the volumes the cache does
not know. A location found is used. A "volume id N not found" answer is not
proof on its own (a live volume whose server is away answers the same, and so
does a follower's cold cache), so it only starts a streak on the retry item:
once the master has answered it for VolumeGoneGrace (30 min) over at least
VolumeGoneMinAnswers (3) retries in a row, the chunk counts as deleted with
its volume and leaves the queue and the ledger. Any other outcome, a failure
to ask included, resets the streak and keeps the id retried as before. The
hot deletion loop and the remote-cache flush keep the cache-only lookup.

* filer: hold a volume-gone deletion for MaxRetryDelay before dropping it

A volume server that is down for longer than half an hour gets the same
"not found" answer from the master as a deleted volume, so the 30 minute
grace dropped pending deletions of chunks that come back with the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test the answer count once the volume-gone grace has passed

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>
2026-11-21 11:00:51 -08:00
Harrison Crosse c9fb00a5d2 s3api: return NoSuchBucket for conditional requests on a missing bucket (#12861)
* s3api: return NoSuchBucket for conditional requests on a missing bucket

* s3api: preserve bucket-name validation for non-If-Match conditional PUTs
2026-11-21 10:48:36 -08:00
Chris LuandClaude Opus 5.5 e3946a35ee filer: keep a directory created while a nested create fills in its parent (#12858)
* filer: fill in a missing parent only where no directory appeared meanwhile

A nested create fills in a missing parent directory by looking it up and
then inserting a plain directory row. A directory created at that path in
between, such as an S3 directory marker carrying its content type and
ETag, was overwritten by the upsert and lost its marker. The parent's
insert and a directory create now re-check the path under a per-path lock
before inserting, so neither replaces the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test a directory created while its parent is filled in

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: keep writes inside a store transaction out of the directory lock

A transaction holds its store connection until it commits, and SQLite has
only one. A rename creating its destination directory inside one would
wait for the directory lock while a nested create holding that lock waits
for the connection, so transactional writes no longer take it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test a directory create that waits for its parent's insert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 10:44:57 -08:00
70ed252dd6 shell: mask every remote secret in remote.configure's listing (#12856)
* shell: mask every remote secret in remote.configure's listing

remote.configure without arguments lists the configured remotes and replaces
their secrets with stars, but the list was incomplete: the Azure account key,
the Backblaze application key, the Baidu secret key (the access key was masked
in its place) and the Contabo secret key were printed in clear, and so were
inline gcs service account credentials (the field holds a file path or the
JSON itself, private key included).

Move the masking into maskRemoteConfSecrets, which covers every secret field
of RemoteConf, and test it. An unset secret stays empty, so an Azure remote
that authenticates with Entra ID still lists an empty key; a gcs credentials
file path stays listed.

* shell: compare each masked remote secret with its full-length mask

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>
2026-11-21 10:41:05 -08:00
Chris LuandClaude Opus 5.5 14631d530b filer: refuse a forwarded conditional write on a filer that is not its owner (#12857)
* filer: refuse a forwarded conditional write on a non-owner

A filer applied any routed write a ring peer forwarded, even when its
own ring named another filer as the write owner. While two filers'
rings disagree (a cooling-off window closing at different times, or a
filer that installed the ring without the prior snapshot), each could
apply a conditional write of the same entry under its own path lock,
and both callers saw success.

The receiver now refuses such a forward with Unavailable carrying a
NOT_WRITE_OWNER reason, so the sender can tell nothing was applied.
Refusing rather than re-forwarding keeps the one-hop bound.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: re-route a forward the owner refused as not its own

A refused forward applied nothing, and the two rings converge once a
ring update reaches the lagging filer or a cooling-off window closes.
The sender now routes the write again by its own ring, with backoff,
until shortly after its latest window ends, and surfaces the refusal
only after that. A write whose owner turns out to be this filer is
applied locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test forwarded conditional updates between two filers

Two filers on one store, each serving gRPC with its own ring: while
the receiver's ring names the sender as the owner, the forward is
refused and the entry is untouched; once the receiver's cooling-off
window closes, the sender's retried forward applies once and a second
update with the same expectation fails its condition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: keep retrying a refused forward through a new ring change

The retry deadline was taken from the cooling-off window seen at the
first refusal. A ring change arriving during the retries opens a new
window, in which the two rings can still disagree, so the deadline is
now recomputed after every refusal, capped at 15 s from the first one
so a ring that keeps changing cannot hold a request indefinitely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: surface a refused forward rather than apply it locally

A caller can check the entry before routing: an HTTP append verifies
its snapshot under its locks and then commits locally without a
condition. Once a forward is refused, the retries wait, and if this
filer's ring then names itself, a local apply would act on that stale
check and could overwrite an entry replaced meanwhile. The refusal now
surfaces in that case, and the caller retries the whole request.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 10:40:22 -08:00
Chris LuandClaude Opus 5.5 ebd90c3a45 fips140=only: SHA-256 in place of MD5 and SHA-1 so the server starts and serves S3 (#12855)
* util: SHA-256 stands in for MD5 and SHA-1 under fips140=only

GODEBUG=fips140=only panics on MD5 and SHA-1. NewMd5 and NewSha1 return
those hashes as before, and under fips140=only SHA-256 cut to the same
size, so digests keep their length. Md5, HashStringToLong and HashToInt32
use NewMd5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer stores: hash directory keys with NewMd5 and NewSha1

leveldb2, leveldb3, rocksdb and arangodb hash directory keys with MD5,
tikv with SHA-1, which GODEBUG=fips140=only refuses, so the filer
panicked at startup. They now use util.NewMd5 and util.NewSha1.

Keys made under fips140=only differ from MD5 keys, so leveldb2 and
leveldb3 mark an empty database opened under fips140=only and refuse a
database whose keys are of the other kind instead of showing it empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* operation, volume: no Content-MD5 checks under fips140=only

Under GODEBUG=fips140=only the uploader's digest is not an MD5, so it is
no longer sent as Content-MD5, which volume servers outside that mode
would reject; the digest still becomes the chunk ETag. A Go volume
server in that mode keeps a client's Content-MD5 unchecked instead of
panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api, filer: ETags and content digests with util.NewMd5

ETags, entry Md5 attributes and chunk digests now use util.Md5 and
util.NewMd5, so under GODEBUG=fips140=only they are SHA-256 cut to 16
bytes instead of panicking. That digest cannot check a client's
Content-MD5, so in that mode Content-MD5 is accepted unchecked, and the
filer stops returning Content-MD5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api, iam, master: SHA-1 names with util.NewSha1

Multipart upload ids, IAM policy ids, the OIDC provider, audit and
session revocation file names, and the master's read-only copy dir hash
names with SHA-1. They now use util.NewSha1, which GODEBUG=fips140=only
turns into truncated SHA-256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* postgres, oidc, update: refuse MD5 and SHA-1 checks under fips140=only

PostgreSQL md5 authentication, OIDC TLS thumbprints (SHA-1 by
definition) and weed update's MD5 check of the download cannot run
under GODEBUG=fips140=only. They now fail with an error saying so
instead of panicking.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: no empty-body MD5 when Content-MD5 is not checked

Under fips140=only a bodyless signed request still reached md5.Sum(nil)
before the nil check and panicked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: empty copy part ETag from the digest it stores

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* util: skip the native MD5 test under fips140=only

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3sink: no Content-MD5 under fips140=only

The entry's Md5 attribute is truncated SHA-256 there, which an S3
destination checking Content-MD5 would reject.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: move OIDC provider and revocation records to this mode's name

The record names hash the ARN or JTI with util.NewSha1, which differs
under GODEBUG=fips140=only. On the first use of a filer, each store
renames records whose name does not match the one derived from their
content, so lookups, revocation checks and deletes find records written
in the other mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: test the rename with the names each fips140 mode derives

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* iam: rename a record only if it is unchanged, under its new name's lock

Two processes renaming after a mode switch could both list a record; if
one renamed it and the provider was then deleted, the other wrote it
back. The rename is now one filer transaction locked on the new name,
like the stores' conditional writes, that requires the old entry to be
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 10:38:38 -08:00
949952f2b6 filer: take a hard link off only after the store dropped the name (#12853)
* filer: take a hard link off only after the store dropped the name

Deleting one name of a hard-linked file took the name off the file's link
count (DeleteHardLink: the shared record read, its count less one written
back, in writes of their own) before the store deleted the name. When the
store then refused the delete (a TiKV write conflict, a database timeout),
or the filer stopped in between, the name stayed with the count already one
short. Each time the delete was sent again it took one more off: a client
retrying, or rm run again after the error. At zero the record went, and that
delete, having read a count of one, deleted the chunks. The file's other
names were left with no record and with their chunks deleted. Without a
retry, the next delete of another name of the file did the same.

A name now comes off the count once the store no longer holds it
(FilerStoreWrapper.dropLink). A refused delete leaves the name and the count
as they were, and the delete sent again takes it off once.

- DeleteEntry and DeleteOneEntry delete the name, then drop its link.
- InsertEntry and UpdateEntry over a name of another hard-linked file write
  the new entry, then drop the replaced name's link (handleUpdateToHardLinks
  now returns it instead of dropping it).
- A recursive delete drops its hard-linked children's links after
  DeleteFolderChildren deleted them, not while listing them.
- A link that cannot be dropped after the delete or the write is logged and
  fails neither (a write failed before): the count stays one too high, and
  the record and the chunks outlive the file's last name instead of going
  before it.

Inside a store transaction (a rename) the order changes nothing.

Tests: filer_hardlink_delete_test.go, and through the DeleteEntry handler
filer_grpc_server_hardlink_delete_test.go. With the old order the refused
delete, write and recursive delete each take a link off, and the delete sent
again queues chunk 3,0c03 for deletion while /dir/other.txt reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: delete a hard-linked name's chunks only once its file's record is gone

DeleteEntryMetaAndData deleted the chunks of a hard-linked name when the
link count it read before the delete was one or less. Another filer can
link the file under a new name in between: the count misses that name, the
record, which counts it, outlives the delete, and the chunks went while the
new name read them.

Now the count read before must leave no other name and the file's record
must be gone after the delete (lastLinkDropped); a recursive delete already
asks for the record. The count stays in: one name deleted at once through
two filers is taken off twice, and the record goes while another name still
holds the file. When both deletes read the count before either took a link
off, the count still shows that name and the chunks stay. Where the two
disagree the chunks leak rather than go.

Tests: TestDeleteEntryKeepsChunksOfLinkAddedMeanwhile fails with the count
alone, TestDeleteEntryTwiceAtOnceKeepsChunks with the record alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: delete a recursive delete's hard-linked names one by one, as a single delete does

A recursive delete listed a folder's hard-linked names, had
DeleteFolderChildren delete them with the other children, and then took
their links off and asked whether each record was gone. Found in review:

- A store that deletes a folder's children in batches (TiKV) can fail after
  some of them. The names it deleted are gone, their links were never taken
  off, and the delete run again no longer lists them, so their counts stay
  high and the file's chunks are never freed.
- Two filers deleting the same folder at once both take the link of each
  hard-linked name off. The second finds the record gone and deletes the
  chunks while a name outside the folder still reads them (as on master).
- The listed entries, chunk lists included, were kept until the folder's
  children were deleted.

A hard-linked child now goes as it is listed, the way a single delete takes
a name (deleteLinkedName): its entry read again for the current count, the
name deleted by the store, then its link taken off (dropLink), and its
chunks queued only when it was the last link (lastLinkDropped: the count
read left no other name and the record is gone). DeleteFolderChildren takes
the other children. Names of one file in two folders of the tree still free
the chunks once, with the last of them.

The link of a hard-linked child now comes off whether or not the delete
removes data, as it already did for a single delete. OnHardLinkIdsFunc and
maybeDeleteHardLinks, which took links off only with the data, are gone.

Tests: TestRecursiveDeleteFailingAfterItsLinkedChildTookItsLinkOff and
TestRecursiveDeletesAtOnceKeepChunksOfANameOutside fail with the previous
commit; the latter also fails when deleteLinkedName asks for the record
alone. TestRecursiveDeleteOfEveryNameDeletesChunksOnce covers the names of
one file in two folders of the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: delete a recursive delete's last-link chunks as the link goes

deleteLinkedName queued the chunks of a file whose last link it took off
with the folder's other chunks, which are deleted only once the whole folder
delete has succeeded. When a later child, a listing or DeleteFolderChildren
failed, the delete returned first and those chunks stayed for good: their
name and record were gone, so no retry could find them. Found in review.

They are now deleted when the link goes, through DeleteChunks with the
child's path, as a single delete deletes them.

Test: TestRecursiveDeleteFailingAfterALastLinkWentDeletesItsChunks fails
with the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: free a swept hard-linked child's chunks only when its last link went

The replay sweep freed a hard-linked child's chunks once the shared record
was gone. One name deleted at the same time through another filer takes the
link off twice, so the record goes while another name still reads the file.
Use lastLinkDropped with the count read under the child's lock, as the
single and recursive deletes do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test store hands out a copy of an entry, as a real store does

Returning the stored entry let a later lookup overwrite the link count an
earlier lookup handed to its caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: look a hard-linked name up again before taking its link off

A delete read the name, and another filer deleted the same name and took
its link off before this delete read the count. The count then already
lacked the name, the second delete took the link off again, the record
went with another name left, and the chunks were deleted. A hard-linked
name is now deleted through DeleteEntry, which looks the name up after
the count was read and skips the link when the name is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: report a failed lookup from a store delete instead of success

DeleteEntry took any lookup error for a name already gone, so the delete
reported success, the name stayed, and the caller sent a delete event.
Only a missing name is a no-op now.

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>
2026-11-20 21:21:00 -08:00
Chris LuandClaude Opus 5.5 f7bd0ad802 storage: measure the search lock-hold budget in rounds (#12854)
A stall of a loaded host (a goroutine not scheduled for most of a
second) made one search and one foreground write go over the 250 ms
budget, failing the test though every search held the lock for about
20 ms. Measure in five 500 ms rounds and pass once a round stays within
the budget: every search scans the tombstone run, so a slow search still
fails every round.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 20:37:19 -08:00
Chris LuandClaude Opus 5.5 3bc6161401 helm: opt-in HTTPS for the volume servers' data port (#12843)
* helm: render volume server HTTPS in security.toml

global.seaweedfs.volumeHttps.enabled sets [https.volume] to the volume
certificate and turns on [https.client] with the client certificate and the
chart CA, so the volume data port is no longer plaintext under
enableSecurity. The option fails without enableSecurity.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: add the volume service names to the volume certificate for HTTPS

Volume servers register as <pod>.<volume service>.<namespace>, and HTTPS
clients verify that name, which none of the certificate's wildcards cover.
With volume HTTPS on, the certificate also lists every volume group's
service.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: probe volume servers over HTTPS when they serve it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: reject volume HTTPS for the all-in-one deployment

Its volume server registers by pod IP, so HTTPS clients could not verify
the volume certificate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm CI: check the volume server HTTPS rendering and its guards

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: document volume server HTTPS

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: copy chunks for cp.from through the shared HTTP client

The copy built a bare client and plain http:// chunk URLs, so with
[https.client] on it could not read from or write to HTTPS volume servers
("source returned status 400"). Use the global client's transport and
redirect policy, and normalize the source and destination URLs to its
scheme.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: restart every security.toml reader when volume HTTPS is toggled

security.toml is mounted with subPath and read once at startup, so on an
upgrade that turns volume HTTPS on, the volume servers restarted with TLS
while filer, S3 and the other clients kept speaking plain HTTP. A
checksum/volume-https pod annotation, rendered only while the option is
on, rolls them all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm CI: check the volume HTTPS rollout annotation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* master: forward to the leader with the masters' own HTTP scheme

A follower took the scheme from [https.client], so with HTTPS clients
toward volume servers and plain-HTTP masters every forwarded request
(/dir/assign, /dir/status, the UI) failed with 502 "first record does not
look like a TLS handshake". Masters share one [https.master] setting, so
use HTTPS exactly when this master serves it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* helm: update the volume HTTPS caveats now that masters forward correctly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: send a read token on the cp.from source chunk GET

With jwt.signing.read set, volume servers refuse unsigned reads, so
cp.from of a chunked file failed with "source returned status 401".
Mint a read token for the chunk on each source attempt, the same way the
filer's own reads do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume (rust): look up volume locations over the master's gRPC port

The lookup used the master's HTTP /dir/lookup with the [https.client]
scheme, so with HTTPS volume servers and plain-HTTP masters every
replicated write, proxied read, remote chunk read and batch delete failed.
Go asks the master's LookupVolume over gRPC; do the same, over one reused
channel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* volume (rust): bound the whole master dial in lookup_volume

connect_channel's connect timeout covers only the TCP connect, so a master
that accepted the connection and stalled in the TLS handshake held every
replicated write, proxied read and remote chunk read that needed a lookup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 19:20:23 -08:00
github-actions[bot] afdb32d228 docs: regenerate star history chart 2026-11-21 00:51:16 +00:00
Martijn HoekstraandClaude Opus 5.5 1c04179953 s3api: refuse SigV2, SSE-C and SHA-1 checksums under fips140=only (#12845)
With GODEBUG=fips140=only, MD5, SHA-1 and HMAC-SHA1 panic, so a request
that uses SigV2 (header, presigned or POST policy), SSE-C (whose customer
key check is MD5) or the SHA-1 flexible checksum panics in the handler and
the client sees a dropped connection. Refuse them before any hashing:

- SigV2: InvalidRequest "The authorization mechanism you have provided is
  not supported. Please use AWS4-HMAC-SHA256." (ErrSignatureVersionNotSupported)
- SSE-C, including copy-source SSE-C headers: NotImplemented
- x-amz-checksum-sha1 (value header, algorithm headers or query, and
  x-amz-trailer): NotImplemented

fips140Enforced is a package variable so tests can turn the refusals on
without running the test binary under fips140=only. Without enforcement
nothing changes.

Refs #12839

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:39:12 -08:00
Chris LuandClaude Opus 5.5 0de9a82dd9 filer: make the stub-backed remote storage tests re-runnable (#12852)
filer: drop cached remote clients when a test registers a stub maker

The remote client cache is keyed by the configuration, so rerunning a
stub-backed test (go test -count>1) got the previous run's stub from the
cache and its counters never moved. Nineteen tests failed on a rerun.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:09:36 -08:00
Chris LuandClaude Opus 5.5 228ccd9eb6 admin: bulk table delete and force namespace delete for S3 Tables (#12851)
* admin: force-delete an S3 Tables namespace with its tables

DELETE /api/s3tables/namespaces?force=true deletes every table in the
namespace, paging through ListTables, before deleting the namespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: offer deleting a namespace's tables in the S3 Tables namespace delete dialog

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: select several S3 Tables tables and delete them at once

The tables list gets a checkbox column with select-all and a Delete
Selected button that deletes each selected table after one confirmation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: clear restored table selections and keep the bulk delete result on screen

Browsers restore checkbox state on reload, which left rows that took the
deleted tables' places selected. The admin alert() is a non-blocking modal,
so reload only after it is closed instead of discarding the failure list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: re-enable the bulk delete confirm button on page load

Firefox restores a button's disabled state across reloads, which left the
confirm button of the next bulk delete disabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: stop a bulk table delete when its dialog is cancelled

Cancel closed the dialog while the remaining deletes kept running. The
loop now stops before the next table and reports how many were deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* admin: say when the S3 Tables list is cut at the list limit

The tables page shows at most the admin list limit, so select-all covers
only the displayed rows; mark a truncated list and name select-all's scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:08:16 -08:00
Chris LuandClaude Opus 5.5 865a7bd988 filer: commit an HTTP append on a non-owner through the entry's owner (#12849)
* filer: commit an HTTP append on a non-owner through the entry's owner

An HTTP append or offset write re-read the entry under its path lock and
cluster lock and then committed with an unconditional upsert. The path
lock is per process and the cluster lock is a lease, so with several
filers on one store a write landing between the re-read and the upsert
was overwritten although both requests were acknowledged.

A filer that is not the entry's write owner now sends the commit to the
owner as a CreateEntry conditioned on the entry it read (IF_ENTRY_EQUAL,
absent when there was none), evaluated under the owner's path lock. The
owner keeps committing locally under that same lock. A failed condition
refuses the append as a changed entry; any other routed error keeps the
uploaded chunks the stored entry references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test an HTTP append racing another filer's append

Two filers on one store share a two-member ring. An append on the
non-owner gets another filer's append injected at the store after each
of its reads of the entry in turn; it must either keep both appends or
be refused. Without the routed conditional commit, injections after the
re-read are overwritten.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: keep the chunks of a forwarded append whose outcome is unknown

The owner may have committed before its reply was lost, and with
separate per-filer stores the local lookup may not see that commit yet,
so deleting the chunks it does not find can strip a committed append.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: keep fsync appends on the local commit

A per-request fsync is a local context mark that a forwarded CreateEntry
cannot carry, so the owner would store the append without flushing.
Storage-rule fsync is still applied on the owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: normalize the stored entry too when matching IF_ENTRY_EQUAL

A store that keeps the entry as given (the JSON-backed ones) returns
FileSize zero beside chunks, while the expected entry was normalized to
the chunk extent, so an unchanged entry failed the match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: carry a create's fsync request in CreateEntryRequest

The per-request fsync is a context mark on the receiving filer, so a
create forwarded to another filer lost it. CreateEntry now applies the
request's fsync flag to its store write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: route fsync appends to the owner with the fsync flag

A fsync append on a non-owner committed locally without a condition, so
it could still overwrite a write the owner committed after its re-read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test an offset write on a store that keeps FileSize as given

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: start an append at the entry's full size

A store that keeps the entry as given can return FileSize zero beside
chunks, so the append chunks were placed at offset zero over the
existing bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* filer: test an append on a store that keeps FileSize as given

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:07:18 -08:00
Chris LuandClaude Opus 5.5 137e4aeede s3api: keep the write condition on the lock fallback create (#12846)
* s3api: keep the write condition on the lock fallback create

Without a ring the PUT checks its conditional headers at the gateway and
then sends the create unconditionally under the object write lock. That
lock is a short lease, so a paused or slow holder lets a second
conditional writer in, and both writes succeed. Send the reduced
condition with the create so the filer re-checks it under its path lock.
Suspended-versioning writes keep the gateway check, since their condition
names the latest version rather than the create's path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: test two If-None-Match PUTs racing on the lock fallback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: keep the chunks of a fallback create whose outcome is unknown

A conditional create is forwarded by the filer to its ring owner, which
a gateway without a ring may not know, so its landed-check can miss a
commit the owner made before the response was lost. Reclaim the chunks
of such a create only when the filer refused it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: test exact fallback race results and a lost conditional create

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: reclaim the chunks of a fallback create the filer refused

A precondition refusal proves the create never committed, but the
landed-check finds the winning writer's entry and reports the key as
present, so the refused writer's chunks were left orphaned. The
ambiguous-route recovery keeps its own rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: test that the refused fallback writer's chunk is reclaimed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: keep the chunks of a recovery create whose outcome is unknown

The owner can forward the conditional recovery create of an ambiguous
routed PUT to a filer the gateway cannot look up, so the cleanup gate
now follows the condition each create actually sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: test that the fallback race deletes only the refused writer's chunk

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:06:24 -08:00
Chris Lu 0c705ec9f2 pb: client interceptors on every dialed connection (#12834)
AddClientUnaryInterceptor registers an interceptor that runs around every
unary call on a connection opened by GrpcDial. GrpcDial installs one
fixed interceptor that consults the registered list at call time, so one
added later also applies to connections already open and cached. With
none registered it only calls through.

Claude-Session: https://claude.ai/code/session_011Upvag1tiz2pnSB8mS2qtK
2026-11-20 13:05:23 -08:00
037c27582f redis2: let Redis hash the Lua scripts (no SHA-1 at package init) (#12848)
* redis2: let Redis hash the Lua scripts (no SHA-1 at package init)

redis.NewScript computes the script's SHA-1 in Go when the package-level
vars are initialized. redis2 is linked into every weed binary, so under
GODEBUG=fips140=only every subcommand, including `weed version`, panics
before main. NewScriptServerSHA leaves the digest to Redis (SCRIPT LOAD
on first use) and keeps Run's EVALSHA-then-EVAL behaviour.

weed/fips140_only_test.go runs the weed main package's test binary with
fips140=only, so any package init that uses an unapproved algorithm
fails `go test ./weed/...`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* redis2: run the Lua scripts by a pinned digest (no SCRIPT LOAD, no lock)

NewScriptServerSHA gets the digest with SCRIPT LOAD inside ensureHash, which
holds the Script's write lock across the round trip and does not remember a
failed load. Where an ACL denies SCRIPT but allows EVAL, every call retried
SCRIPT LOAD under that lock before falling back to EVAL.

The two scripts are now constants next to their SHA-1 digests, and runScript
sends EVALSHA and falls back to EVAL on NOSCRIPT, the same commands
Script.Run sent on master. No SHA-1 is computed in Go, at init or at run
time. TestScriptDigests checks each pinned digest against its source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* redis2: hash the script digests in the test without FIPS enforcement

TestScriptDigests panicked under GODEBUG=fips140=only, the mode this
change is for, because sha1.Sum is not approved there.

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>
2026-11-20 13:03:47 -08:00
1b209f7717 util, s3api: AES-GCM via NewGCMWithRandomNonce for fips140=only (#12847)
* util: AES-GCM via NewGCMWithRandomNonce in Encrypt/Decrypt

cipher.NewGCM returns an error under GODEBUG=fips140=only ("use of GCM
with arbitrary IVs is not allowed"), so filer -encryptVolumeData cannot
encrypt or decrypt chunks in that mode. NewGCMWithRandomNonce produces the
same nonce(12) || ciphertext || tag layout, so chunks written by earlier
versions still decrypt and older versions can read new chunks; the tests
check both directions against a copy of the previous code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: SSE-S3 DEK and KEK wrapping via NewGCMWithRandomNonce

cipher.NewGCM returns an error under GODEBUG=fips140=only, so SSE-S3
PutObject fails in that mode. NewGCMWithRandomNonce yields the same nonce
and ciphertext+tag bytes: the wrapped KEK keeps its magic || salt || nonce
|| ciphertext+tag layout, and the DEK's nonce and ciphertext are still stored
as separate metadata fields. sealGCMSplit and openGCMSplit split and join
them, with the nonce length as gcmNonceSize, because the random-nonce AEAD's
NonceSize() reports 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* util, s3api: keep AES-GCM working for AES blocks NewGCMWithRandomNonce refuses

cipher.NewGCMWithRandomNonce accepts only the standard library's own
*aes.Block. In a GOEXPERIMENT=boringcrypto build aes.NewCipher returns
BoringCrypto's block instead, so Encrypt, Decrypt and SSE-S3 key wrapping
would fail there. util's newGCMWithRandomNonce falls back to cipher.NewGCM
with a nonce from crypto/rand for such blocks, with the same
nonce || ciphertext || tag output. SSE-S3's KEK wrap and DEK wrapping use no
additional data, so they now go through util.Encrypt and util.Decrypt and
build no AES-GCM of their own; the stored bytes are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* util: keep the GCM fallback test working in boringcrypto builds

cipher.NewGCMWithRandomNonce refuses aes.NewCipher's block in a
GOEXPERIMENT=boringcrypto build, so the test failed there before it
reached the fallback. Compare with cipher.NewGCM and the nonce in front
when the native constructor is unavailable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: build the SSE-S3 sealed buffers with slices.Concat

Summing the input lengths for make() trips CodeQL's
go/allocation-size-overflow on the DEK path, whose inputs come from
stored metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* s3api: draw SSE-S3 key IDs from crypto/rand

The math/rand key ID is serialized next to the wrapped DEK, so CodeQL's
go/insecure-randomness follows it from the metadata JSON into the
AES-GCM open of the DEK.

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>
2026-11-20 13:03:22 -08:00
Chris LuandClaude Opus 5.5 f69cb98042 admin/plugin: extension points for scheduling policy (#12833)
* admin/plugin: extension points for scheduling policy

The lane scheduler decides four things in line: how a lane's job types
are run, whether a proposal becomes a queued job, whether a queued job
starts on the slot reserved for it, and whether a job holds the cluster
admin lock for its whole run. Each now goes through a schedulerExtension
whose default answers exactly as before, so policy can be added without
editing the dispatch loop. The extension can also serve its own gRPC
service beside the worker stream.

Claude-Session: https://claude.ai/code/session_011Upvag1tiz2pnSB8mS2qtK

* admin/plugin: state when runLane may return and when done runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 13:02:14 -08:00