The broker and the Kafka gateway each scanned a partition's files for
the high water mark and counted a maximum only when it was above 0, so
a partition holding one message still read as empty. Both now share
mq.OffsetRange, which tracks whether a range was found apart from its
value.
The flush wrote offset_min/offset_max only when minOffset > 0, using 0
as "no range given". A partition's first window starts at offset 0, so
its file never got a range. A restarted broker derives the high water
mark from those ranges, so a partition whose data was all in its first
file read as empty.
A download closed done and then moved its reservation to the budget's
idle list, so a reader woken by done could ask the budget for room
before the chunk it had just read was evictable.
TestReaderCacheBudgetLendsScratchToHedges failed this way about 1 in
1000 runs under -race ("hedge buffers did not evict the idle chunks").
The download now completes in the budget first.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The stub store kept the caller's entry, which the path translator changes
back after the insert, so TestNameInAPathSpecificStoreCreatedTwiceIsCountedOnce
raced with a lookup under -race.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* webdav: set mtime when a file is created
OpenFile created the entry with Mtime 0 and only Close after a Write set
the real time, so an empty PUT, or one truncating a file to empty, left
it at 1970. The "new entry" marker for a failed first upload is now a
field on the file.
* webdav: keep a failed upload from removing another writer's version
With every new entry carrying an mtime, a failed first upload removed
whatever the path held at the first Write, including a version another
writer stored after this open created it. The open now records the
commit stamp of the entry it created, and the first Write keeps the
removal only when the loaded entry still has that stamp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* webdav: check the entry's commit stamp when the upload fails
The first Write's lookup left a gap: a version another writer stored
after it was still removed by a later failed flush. Flushes only append
chunks locally, so the stored entry keeps the create's stamp until
Close; the failed flush now reads it then and removes it only while it
still has that stamp.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: reset the circuit breaker when its config is deleted
The delete handler parsed an empty file, which always fails, so the old
limits stayed in place. It now loads an empty config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: read and swap the circuit breaker limits under its lock
A config change or delete replaced Enabled and the limitations map while
requests read them without a lock. The swap now holds the breaker's
write lock, and requests read both under the read lock that
loadCounterAndCompare already took for the counters.
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>
* filer.sync: save the sync position on the source filer as a replay cursor
The position stays authoritative on the target. The source copy holds the
last position the target checkpoint stored (a fresh sync without one holds
just before the first event it received) and is rewritten hourly while the
sync runs, even when the position does not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: do not replicate the sync cursors of the source
A target never holds cursors that describe the source's log. A rename into
or out of the cursor directory replicates the ordinary side.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* metadata log purge: keep the logs a filer.sync still needs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: describe the sync in its source cursor
The source cursor is informational: besides the position it records the
source and target filers and paths, exclusions, host, version, when the
sync started, whether the position is a target checkpoint, and the
processed and failed event times, for display in admin tools. The
target checkpoint stays authoritative.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: save the first sync cursor when the first event arrives and retry failed saves
A fresh sync only saved its cursor on the next minute tick, and a failed
save still pushed the next attempt out by an hour, leaving the purge
without a cursor while the sync replayed old log days.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.backup: do not seed the source's sync cursors in the initial snapshot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* metadata log purge: say that a position not saved for 7 days stops holding the log
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.backup test: lock the recording sink for concurrent snapshot workers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: leave the sync cursors out of the metadata log gap check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* security: filer token source read from a file
FilerTokenFile is the token source of a client that holds a pre-issued
filer token rather than a signing key. It reads the file on every call,
so an atomic replacement that keeps size and mtime takes effect on the
next attempt, and trims surrounding whitespace. A missing, unreadable,
empty or malformed file fails the call: there is no fallback to anonymous
or admin authority, and errors name the path but not the contents.
FilerTokenClaims decodes a token's claims without a key, and
FilerTokenGrantCovers compares two grants, so a client can plan
reconnects before expiry and know when a replacement narrows what it
may see.
* mount: -filer.tokenFile authorizes filer calls with a pre-issued token
A mount that should not hold a filer signing key can now present a
token issued for it. -filer.tokenFile (or -o filer.tokenFile=) names the
file; it is read for every filer gRPC attempt, so a replaced file takes
effect on the next call or retry without a restart, and a missing or
empty file fails the call locally.
The source reaches every filer client the mount builds: the startup
handshake, each attempt of WithFilerClient, the volume location client,
the SSE-S3 reader's configuration call, the peer registrar dial and the
lock client. It is attached per call, never to the cached channel, and
never to master, volume or peer mount RPCs.
The filer refuses MountRegister, MountList and distributed locks to
scoped tokens, so the mount refuses to start when -filer.tokenFile is
combined with -peer.enable or -dlm instead of failing at run time.
Server-side copy_file_range signs its filer HTTP request with the HTTP
key, not this token, and is unsupported with it.
Without the flag the mount behaves as before.
* mount: resubscribe metadata with a replaced filer token
A metadata subscription keeps the authority it opened with, so a mount
reading -filer.tokenFile would follow with the old token until the filer
ended the stream at expiry, and every such end took the gap path that
distrusts all cached listings.
SubscribeMetaEvents now takes the credentials of each attempt. The mount
opens each subscription with the token current at that moment and
watches the file; once it holds a different token the attempt ends and
the follow resubscribes at once from its checkpoint. This planned
resubscribe is not a gap: cached listings stay, unless the new grant may
show less than the old one or either token cannot be decoded, in which
case they are read again so nothing the old grant showed outlives it.
The filer walk treats a resubscribe like a stopped follow, so the same
attempt is not replayed on the next filer. Without a token file nothing
changes.
* mount: hand the mutation stream over to a replaced filer token
The mutation stream keeps the token it opened with, and a filer refuses
to send on a scoped stream once that token has expired. A mutation
applied at that moment loses its reply, the mount reads that as a
transport failure, and the unary fallback sends it again.
The stream now opens with a snapshot of the token source. Before
admitting a request it checks the source: when the file holds another
token, or the stream's token would expire before a reply could come
back, the stream is retired. New requests wait while the admitted ones
are answered, the stream is half-closed so the filer finishes it, and a
successor opens with the new token. The waits give up only after
filerRPCWait without a response, so a rename that keeps answering is not
cut short. A request is never resent by the handover: one still
unanswered when the wait gives up fails as on any lost stream, as
before.
A token too close to expiry to open a stream with is refused before
anything is sent, so the request goes out once as a unary call, which
the filer checks when it starts. Without a token file nothing changes.
* mount: review fixes for the filer token file
- A distrust of cached listings now also discards the directory builds in
flight, in the meta cache's apply loop: such a build publishes nothing,
its entries are wiped and the visit lists the directory again, so a
listing read under a grant that has since narrowed is never cached after
the distrust. The cached flags are reset again in the loop, after any
build that completed before it.
- Retiring the mutation stream runs in the background, and a request that
waits for the retirement gives up on its own context, unadmitted.
- With a token file and no filer signing key, server-side whole-file copy
is not tried: its filer HTTP request would go out unsigned and fail as
ambiguous. The copy streams through the chunk path instead.
- On Windows the token file is opened with delete sharing, so a renewer
can replace it by rename while a read holds it open; the missing-file
test checks os.ErrNotExist instead of Unix wording.
* mount: review fixes for the mutation stream handover
A request admitted to the mutation stream with just over one RPC wait
left on its token could wait behind a slow send until that margin was
gone; its reply could then be refused at expiry and the request was
resent over unary. The send loop now checks the margin again right
before sending and holds back a request that no longer has it, which is
safe to send over unary because the filer never saw it. A sent request
whose reply is lost while the token has one RPC wait or less left now
fails with EIO instead of a transport error: the filer may have applied
it, so it is not resent. Losses with the margin intact fall back to
unary as before.
A newly opened stream now admits its first request through the same
checks as an open one, so a token file replaced, or a token that neared
expiry, while the stream opened is caught before anything is sent.
A retirement keeps a cancel handle for its stream. Close uses it, so
unmount no longer waits for admitted requests to be answered, and a
waiter that gives up on a retiring stream stops it as it would stop an
open one, so a request still queued there is never sent after that
waiter fell back to unary. An ordinary rotation still drains admitted
requests.
* mount: drop kernel listings when the filer token's grant narrows
A replacement token whose grant may not cover the old one already
distrusts the mount's own cached listings. The kernel kept its own copy:
OpenDir sets FOPEN_CACHE_DIR | FOPEN_KEEP_CACHE, so a directory still
reachable under the new grant was listed again from the page cache with
names the new grant may hide, until something else invalidated it.
On a narrowed or undecodable grant the mount now also notifies the
kernel for every directory inode it holds, from the subscription
goroutine as the metadata apply path already does, so the next readdir
reaches the mount. A readdir already under way on an open handle still
finishes from what it read.
* mount: drop kernel listings after a subscription gap too
distrustCachedListings serves both the narrowed-grant path and the gap
path. A gap can lose the very events that would have dropped the kernel's
cached listings one directory at a time, and with FOPEN_KEEP_CACHE on
OpenDir the kernel then serves those listings on every reopen. Move the
kernel drop into distrustCachedListings so both paths get it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: optionally answer NoSuchBucket to a denied signed request on a missing bucket
## Problem
AWS S3 answers 404 NoSuchBucket to an authenticated caller that is denied on a bucket that does not exist. SeaweedFS answers 403 AccessDenied. S3-compatibility test suites run by data platforms (which create, probe and clean up buckets with a scoped key) flag the difference, and a client that maps 404 to "create it" or "skip it" takes the 403 for a permissions problem instead.
Answering 404 tells every authenticated identity whether a bucket name exists, which a multi-tenant deployment may not want, so the default stays 403.
## Fix
A new option, off by default: `-s3.noSuchBucketWhenDenied` on `weed server`, `weed filer` and `weed mini`, `-noSuchBucketWhenDenied` on `weed s3` (`S3ApiServerOption.NoSuchBucketWhenDenied`).
With it set, `refineDenial` extends `refineDenialForBucketName` (400 InvalidBucketName) with the NoSuchBucket answer, in `Auth`, `AuthPostPolicy` and the POST policy handler:
- only after authentication succeeded with a signature or a token (signed, presigned, V2, streaming signed, streaming-unsigned with a signed header, JWT). The anonymous identity keeps 403 under any auth type, so an anonymous caller still learns nothing about which buckets exist;
- a bucket-level PUT (CreateBucket, configuring a bucket) keeps 403, as AWS answers a refused create;
- the lookup goes through the bucket config cache, which the authorization path has usually just filled, so a denied request rarely costs a filer lookup; a failed lookup is "unknown" and keeps 403;
- an allowed request never looks a bucket up.
`Auth` now keeps the auth type it used to discard; the POST policy handler, which verifies the form signature itself, passes `authTypeSigned`.
With the option off nothing changes.
## Tests
`weed/s3api/auth_no_such_bucket_test.go`:
- `TestRefineDenialThroughAuth`: through `iam.Auth`, a signed caller denied on another identity's existing bucket gets 403 and on a missing bucket 404 (GET, PUT, a signed streaming-unsigned PUT); a bucket-level PUT stays 403; the caller's own bucket is allowed with no lookup.
- `TestRefineDenialAnonymousLearnsNothing`: anonymous requests answer 403 for a missing and an existing bucket alike and never drive a lookup.
- `TestRefineDenialRules`: presigned and JWT callers, failed authentication, allowed requests, a missing bucket name, a failed lookup, and the option off (no lookup wired) all keep their answer.
- `TestPostPolicyDeniedNoSuchBucket`: a verified browser POST form denied on a missing bucket answers NoSuchBucket; a bad signature stays SignatureDoesNotMatch; an existing bucket stays AccessDenied.
`TestRefineDenialThroughAuth`, `TestRefineDenialRules` and `TestPostPolicyDeniedNoSuchBucket` fail without the NoSuchBucket answer. `go vet` reports nothing in the touched files; `go test ./weed/s3api/ ./weed/command/`: ok. `go build ./weed`: ok.
* s3api: count streaming-unsigned as signed only with a SigV4 or JWT credential
A client-certificate identity that streamed its body unsigned answered
NoSuchBucket on a denied missing bucket, while the same request without
the body-encoding header answered 403.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: tell the anonymous identity by name, without the unlocked pointer read
isAnonymousIdentity compared against iam.identityAnonymous without iam.m,
racing a configuration reload. The configured anonymous identity always
has the anonymous name and account, which the check already covers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* command: keep allowBackslashInKeyUsage's doc comment on its const
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: answer NoSuchBucket to a denied request on a missing bucket by default
AWS S3 answers it this way, so drop the -s3.noSuchBucketWhenDenied flag
and always wire the bucket lookup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: answer NoSuchBucket to a client-certificate identity too
The AWS answer now goes to every authenticated identity, so it no
longer depends on how the caller authenticated. The anonymous identity
keeps 403, as anonymous object reads mask a missing bucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: fold the NoSuchBucket answer into refineDenialForBucketName
One refinement for the bucket a denied request names: 400 for a
malformed name, 404 for a missing one. The anonymous read paths keep
their answer, since the anonymous identity never gets the 404.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: warn when the source metadata log no longer covers the sync
A sync replays the source's metadata log from its saved position, or from
the oldest log file when it has none. Once older log days are purged, a
position older than the log silently skips the purged changes, and a fresh
sync never copies entries whose last change was purged, so the target ends
up incomplete without any sign of it.
At start, compare the position with the oldest log file the source keeps;
for a fresh sync, look for a child of the source path whose last change
(commit time, or mtime for entries without one) predates the log, and log
a warning naming it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: skip excluded and multipart upload entries in the log gap check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: run the log gap check without delaying the subscription
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3 backend: HTTP/1.1 client defaults for disable_http2
## Problem
`disable_http2` (#11897) keeps the cloud tier's S3 client on HTTP/1.1, so every tier upload and range read gets a connection of its own. The rest of the client still has the defaults sized for one multiplexed HTTP/2 connection:
- Go's idle pool keeps only 2 connections per host, so a burst of concurrent range reads redials TLS for almost every request once the burst is over and the next one starts;
- the wait for response headers is the 60 s bound every tier client has;
- the SDK retries 3 times.
On a Ceph RGW-based S3 service, HTTP/2's small flow-control window held tier uploads at 18 MB/s and made 24 concurrent cold scans take 52 s each; on HTTP/1.1 they took 3.7 s each, but only with a larger idle pool, a shorter header bound and more retries for the 503 SlowDown answers that the extra parallelism draws.
## Fix
With `disable_http2 = true` the tier client also gets:
- an idle pool of 100 (`MaxIdleConns` and `MaxIdleConnsPerHost`);
- `ResponseHeaderTimeout` of 30 s;
- `MaxRetries` 5, so the SDK's retryer backs off on 5xx, SlowDown and throttling.
`max_connections` and `idle_connection_timeout_seconds` apply as before. Without `disable_http2` the client is unchanged. The scaffold `master.toml` mentions the defaults.
## Tests
`TestS3BackendHTTP1ClientDefaults` in `weed/storage/backend/s3_backend/s3_sessions_test.go`: with `disable_http2` the transport has the idle pool and the 30 s header bound, and the client 5 retries; without it (and with `max_connections` set) the client keeps the SDK's retries, the default idle pool and `s3ReadTimeout`. It fails without the change.
`go vet ./weed/storage/backend/s3_backend/` and `go test ./weed/storage/backend/s3_backend/`: ok. `go build ./weed`: ok.
* s3 backend: keep the larger idle pool for every tier client
A tier client on a plain http:// endpoint, or on a TLS service that offers
no HTTP/2, speaks HTTP/1.1 without disable_http2 and had the same 2 idle
connections per host, so each burst of concurrent reads redialed. HTTP/2
keeps one connection, so the pool size does not change it. The header
bound and retries stay with disable_http2.
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>
* iceberg: parse each table metadata version once and encode the load response once
Under an Iceberg commit load, about half of the S3/Iceberg server's CPU went into the JSON of the same metadata document. A writer loads a table and then commits to it, and each request parsed the stored metadata again (`table.ParseMetadataBytes`, 17% of CPU in a profile). The load then marshalled it, `json.Marshal` compacted and validated the whole document again around the `json.RawMessage` inside `MarshalJSON`, and the response encoder did that once more around the result (8%). The cost grows with a table's snapshot history.
Changes:
- `tableMetadataCache` keeps the parsed form (and, lazily, the rendered response form) of recently read metadata documents, keyed by bucket and metadata location and bounded at 64 MiB (an entry is charged 6x its source size; a document over a quarter of the bound is never cached). An entry is used only when the stored bytes are byte-identical to the bytes it was parsed from, so a hit returns exactly what parsing would; the key only finds the candidate, and a parse error is never cached. Load table, commit table and commit transaction read through it.
- The parsed metadata is shared read-only between requests: iceberg-go guards its lazily decoded snapshots with its own `sync.Once` and lock, and the metadata builder copies what it changes (`TestMetadataCacheSharedEntryUnderConcurrency`, run with `-race`).
- A table commit remembers the version it stored (parsed from exactly those bytes), so the next load of it is a hit, and drops the version it replaced; a transaction commit drops the versions it replaced.
- `LoadTableResult.MarshalJSON` assembles the response around the rendered metadata instead of re-encoding it as a `RawMessage`, and `writeLoadResult` writes those bytes without the encoder's extra pass. The rendering is used only while `Metadata` is still the cache entry's own parsed metadata; a filtered (`?snapshots=refs`) or replaced `Metadata` is marshalled as before. An encoding failure is now a 500 rather than an empty 200.
The response bytes are the same as before: `TestLoadTableResultMarshalBytes` compares them with the previous encoding, including HTML and U+2028 escaping, with and without a metadata location, config and storage credentials. `TestMetadataCacheHitsOnlyIdenticalBytes` covers the byte check, parse errors, eviction and the commit remember/forget path.
Measured on one server at 8 concurrent writers, about 20 commits/s, CPU sampled over 20 s: 30.0 s before, 21.7 s after.
`go vet ./weed/s3api/iceberg`, `go test ./weed/s3api/iceberg` and `go test -race -run 'MetadataCache|LoadTableResult' ./weed/s3api/iceberg` pass; `go build ./weed` builds.
* iceberg: the shared-entry concurrency test shares one entry
The test started from an empty cache, so each worker could miss and parse
its own copy, and it passed without readers and builders ever sharing an
object. The entry is now parsed before the workers start, and each worker
checks that it was handed that entry. A cache that returns a fresh copy now
fails the test.
* iceberg: keep the snapshots=refs check inline and log the parse error directly
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: shorten the metadata cache comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: refuse a non-recursive delete of a bucket that has children
A non-recursive delete of a folder that has children fails with
ErrNonEmptyFolder: doBatchDeleteFolderMetaAndData lists the folder's
first page and refuses. For a bucket on a store that keeps each bucket
apart (leveldb3, the SQL stores with bucket tables, ArangoDB, YDB with
bucket tables), it skipped that listing, because such a store drops a
deleted bucket's children in one call and a recursive delete needs no
walk. The non-recursive delete then went through: DeleteFolderChildren
dropped the bucket's objects, the bucket entry was deleted, and
DeleteEntryMetaAndData deleted the bucket's collection, so the objects'
volumes went with them.
rmdir on a weed mount, fs.rm without -r and a filer HTTP DELETE without
recursive=true each send such a delete. On the other stores the same
request is refused.
A non-recursive delete now lists a bucket on these stores the way it
lists any other folder, and is refused when the bucket has children. An
empty bucket is still dropped by the store, which frees what the store
keeps per bucket, and a recursive delete still drops a bucket without a
walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: say why a non-recursive bucket delete still sweeps
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>
* s3tables, iceberg, lance: the catalog assigns every new location; an existing name answers only a reader
A REST create without a location gets <ns>/<name>-<uuid> (#12475) and a
location another record holds is refused (#12473), but a location a
client names is still taken: the REST create's location field and
warehouse property, S3 Tables CreateTable and CreateView with a
MetadataLocation, the Lance declare's location. A free location a client
picks can be one another caller holds staged write credentials for
(stage markers are not claims), or files no record claims any more.
Separately, CreateTable of a name that already holds a table returns
that table (ARN, version token, metadata location) to any caller who may
create, including one who may not read it.
- A REST create or create view naming a location (field or property,
stage-create or not, the bare bucket included) is refused with 400
before anything is written; the location is always placeNewEntry's:
<ns>/<name>-<uuid> in the bucket, or under the operator's
ICEBERG_WAREHOUSE (no longer under a client's warehouse property).
- A create commit uses a stage marker only when its assign-uuid matches
the staged table's UUID (PyIceberg and Java send it); any other create
commit is placed at a fresh <name>-<uuid>, never at the bare name path
and never at another caller's staged location. Its updates may not set
another location than the one assigned (400).
- S3 Tables CreateTable and CreateView naming a MetadataLocation are
refused with 400 (ErrClientTableLocation) unless the call is the
process's own (WithCatalogAssignedLocation: the REST create, create
view and create commit at the location they placed; the Lance declare
at the dataset's name path and register at an existing dataset). AWS's
CreateTable takes no location either.
- A Lance declare naming a location is refused with 400 (register is for
existing datasets).
- CreateTable of an existing name answers the table only to a caller who
may GetTable it; a caller who may only create gets 409
TableAlreadyExists and nothing about it.
Tests: TestAClientCreateNamesNoLocation (positive controls: a client
create without a location, the catalog's own create with one),
TestARESTCreateNamesNoLocation, TestACreateCommitCannotSetAnotherLocation,
TestACreateCommitTakesOnlyItsOwnStage (the stager's own commit is the
positive control), TestCreateExistingTableAnswersOnlyAReaderWithIt (a
reader gets the table). Existing tests adapted: the s3tables fixtures and
request helpers run as the catalog's own calls (assignedCtx), as do the
iceberg tests that seed tables through the manager;
iceberg_create_table_conflict_test.go's creates send no location and
newConflictEnv points placeNewEntry at conflictLocation, so its races
still collide on one location; TestCreatePathsRefuseAnotherTablesLocation
expects 400 for the three create paths and 409 for the register;
TestCreateTableWithoutLocationUsesItsOwnDirectory drops the bare-bucket
body; lance TestIcebergTablesAreInvisible seeds its Iceberg table as the
catalog; TestDeclareOfAnExistingTableKeepsItsLocation expects 400 for a
declare naming the index's location; TestDeregisterAndReregisterNeedUpdateTable
(#12552) expects 409 instead of 404 for the register and the declare of
a caller without GetTable: the table stays deregistered and nothing is
vended. Each rule is red with it undone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a create may name a fresh location
A REST CreateTable naming a location (Trino always sends one built from
the namespace location, Spark LOCATION, PyIceberg location=) is accepted
again when nothing is stored under it and no live stage holds it; a used
or staged location answers 400. The check runs after the create's
authorization and before anything is written. A bare-bucket location
still gets the assigned <name>-<uuid>. CreateView always uses the
assigned location: a view holds only metadata files.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* lance: a declare may restate its name path as its location
pylance and other namespace clients may send the location they expect;
the dataset's own name path is accepted, any other location still
answers 400.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a commit cannot set another location on an existing table
CommitTable and CommitTransaction applied a set-location update, so a
table's metadata could name a location outside the directory its record
holds. Such a commit now answers 400 and nothing is written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: the fresh-location check pages through every stage marker
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a fresh location stays apart from stages and tables above or under it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a create checks its location again after claiming it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3tables, iceberg: a live stage holds its location against every create
The catalog counts each live stage-create as a root of the record it
would commit to, so a native create, register, rename or move over a
stage's location is refused. The fresh-location check reads the same
roots, so a stage also backs out of a record that claimed an ancestor
after its first check. A location held by a record or stage answers 409,
as the create gate already did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a create removes only the stages its location covers
A create or commit used to drop every stage marker of its name, which
freed the location of a stage whose credentials were still live.
Expired markers now go with their staged metadata.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: an assigned stage location checks its claim again too
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a stage marker lasts as long as its vended credentials
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: test a create that runs while a stage checks its claim
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a stage holds its location against a create of the same name
A live stage-create now counts under its marker rather than under the
record of its name, so a same-name create over its location is refused
and a stage refuses a same-name table created over its location. Only a
staged commit takes the location its own stage holds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3tables: a stage holds only its location against its own record's create
A live stage keeps the path of the record it would commit to away from
other records' files, but a create of that same record writes it: the
stage then holds only its location against it. A stage at its name path
can commit while a later stage of its name, elsewhere, is live.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: a staged commit's create gate reads its location as a create does
The gate maps a metadata file's location to its table directory, so the
bare location of a stage under a metadata directory resolved to the
namespace and conflicted with the stage's own claim.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg, lance: tests from master create through the catalog's own call
Their creates name a location, which only the catalog's own calls may, and
a caller who may only create gets 409 for an existing name whatever
location its register names.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
A table or view load (and create) answered with `X-Iceberg-Access-Delegation: vended-credentials` carries live S3 session credentials in `config` and `storage-credentials`. The response sends `Vary: X-Iceberg-Access-Delegation` but no `Cache-Control`, so a shared HTTP cache in front of the catalog may store it and hand one caller's table-scoped session to another caller of the same URL that sends the same delegation header. The OAuth token endpoint already answers `Cache-Control: no-store` for the same reason (RFC 6749 §5.1).
`writeLoadResult` sets `Cache-Control: no-store` when the response holds credentials: a non-empty `storage-credentials`, or `s3.access-key-id` / `s3.secret-access-key` / `s3.session-token` in `config` (tables and views, values or pointers). Responses without credentials are unchanged.
`TestVendedLoadAnswerIsNoStore` (vended and not vended, table and view responses): red with the header removed. `go vet ./weed/s3api/iceberg/` and `go test -race ./weed/s3api/iceberg/` pass, and `weed` builds.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg maintenance: worker setting for the row-group size of compacted files
Compaction takes a compacted file's row-group size from the table property `write.parquet.row-group-size-bytes`, and falls back to Iceberg's default, 128 MB, when the table sets none. Most tables set none, and the default target file size is also around 128 MB, so a compacted file usually comes out as a single row group. A reader's column filter (a time range, an id range) can then skip the whole file or nothing inside it.
Setting the property table by table is the only way to change that today. This adds a worker setting, `row_group_size_mb`, that sets the size for tables without the property:
- default 0 = Iceberg's 128 MB, so nothing changes unless an operator sets it;
- the table property still wins over it, so an engine or a user that chose a size keeps it;
- `write.parquet.row-group-limit` (rows) is untouched.
For example, `row_group_size_mb = 64` gives about two row groups per 128 MB compacted file.
Test: `TestRowGroupSizeWorkerSettingAndTableOverride` (the default is 0, the setting is read, a table without the property gets the worker's size, the property wins).
`go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds.
* iceberg maintenance: raise the descriptor version with row_group_size_mb
The admin keeps a stored descriptor unless the new one's version is not
lower. With both at 1, an older worker serving a descriptor refresh during a
rolling upgrade replaced the form and row_group_size_mb disappeared. The
test fails at version 1.
* iceberg maintenance: say row_group_size_mb also caps the spatial row group size
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg maintenance: keep at least one row per row group when a row outgrows the byte size
With an explicit row limit the estimate had no floor, so a byte size
smaller than one row gave 0, which parquet-go takes as no limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg maintenance: say row_group_size_mb only caps a spatial rewrite's row groups
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>
* iceberg: a transaction's rollback never overwrites a later write
CommitTransaction rolls an already flipped table back with an
UpdateTable that names no version token: a commit that landed on the
table after the flip is overwritten, and the transaction's metadata file,
which that commit may build on, is deleted with it. A table that had no
metadata location before the transaction (created without one, never
committed) is not put back at all (an update leaves an empty location as
it is), yet its restore is reported done and the file it still points at
is deleted: the table then fails every load. And when the failing flip
lost a version race, the client was answered 409 CommitFailedException
even though a table left unrestored kept the transaction's change: a
client that refreshes and retries applies it twice.
- The flip records the version token it wrote, and the restore is
conditional on it (it fails, and the file is kept, when anything wrote
since).
- A table that had no metadata location before the transaction is
reported unrestored, so it keeps the transaction's metadata and file.
- When any table is left unrestored the answer is 500
CommitStateUnknownException; a full rollback still answers 409.
Tests: TestARolledBackTransactionNeverOverwritesALaterWrite (a write
before the rollback and one during the restore's write are both kept;
the file stays while referenced) and
TestARolledBackTransactionKeepsTheFileOfATableItCannotRestore (the table
still loads; the flip fails with a version race and the answer is 500).
The test filer (memFiler in iceberg_create_view_test.go) now answers a
lookup with a copy and refuses a conditional UpdateEntry whose
ExpectedExtended no longer holds, as the filer does; without it no
conditional write could fail in these tests. Red with the restore
unconditional, with the no-location table restored, and with 409 for an
unrestored table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: the failing-flip test filer fails only record writes
A storage marker written on a table's own directory carries the record
it read unchanged; failing or counting it moved the injected failure
and the concurrent write off the flip and the restore.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
iceberg: the Iceberg REST catalog keeps off Lance tables
A Lance dataset's catalog record lives in the same table bucket as
Iceberg tables, and the Iceberg REST endpoint serves it as a table:
LoadTable vends write credentials over the dataset's directory to anyone
who may update the table, and CommitTable or CommitTransaction on it
writes Iceberg metadata into the dataset's directory and repoints the
record at it. Reproduced on master: the record's metadataLocation became
finance/vec/metadata/v2.metadata.json, its format still LANCE.
notIcebergTable now refuses a commit and a transaction on a record of
another format with 400, after the commit's authorization; LoadTable
serves a catalog-only record as an empty table (its metadata is never
read as Iceberg) with read-only credentials. A REST create of the name
already answered 409.
Test: TestIcebergRESTKeepsOffLanceTables: an Iceberg table's owner gets
write credentials (positive control), the Lance table read-only ones;
commit and transaction 400; the Lance record unchanged. Red with each of
the three rules undone.
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* lance: a register of a new name needs a Lance dataset at its location
A Lance register of a new name takes any free location in the table's
namespace (#12473 refuses one another record holds), so it can claim an
empty location, or a dropped table's emptied root, in the catalog's
stead.
A register of a name without a record now authorizes the create with its
location (AuthorizeCreateTable: the permission, the namespace check and
the refusal of a claimed location run before anything is read, so a
location in another namespace is answered alike whether it holds a
dataset or not), then refuses with 400 a location holding no Lance
dataset (no _versions/). A name that has a record, readable by the
caller or not (deregistered, or without GetTable), keeps the existing
path: CreateTable answers for it and bringing it back needs UpdateTable
(#12552).
Test: TestRegisterNeedsALanceDataset: an empty location 400; a caller
who may not create 403; a dropped table's root 400; another namespace's
path answers the same with and without a dataset; a written dataset
registers (positive control). Red with the dataset check removed, the
authorization skipped, or the location left out of the authorization;
TestDeregisterAndReregisterNeedUpdateTable is red when the dataset check
also runs for a name that has a record.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* lance: a register of a name with a record keeps the CreateTable path
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* lance: a register needs _versions to be a directory
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
s3: vended credentials list only inside their table's directory
A vended session's s3:ListBucket is conditioned on s3:prefix
{prefix, prefix/*}. The bare table path (ns/t) also matches every
sibling whose name starts with it, so a session vended for ns/t lists the
object names of ns/t2/..., ns/t_x/... and ns/t-<uuid>/... (the catalog's
own placements of other tables).
The condition is now {prefix/, prefix/*}: the table's directory only. A
client listing the table's location without the trailing slash (Java's
S3FileIO.listPrefix(location), used by remove_orphan_files) is refused
with vended credentials; reads, writes and listings of the table's
directory are unaffected.
Test: TestTablePrefixSessionPolicyRestrictsListing now expects the
slash-terminated pair; red with the bare prefix back.
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3tables, lance: an update cannot move a table's or view's root
UpdateTable and UpdateView may move a record to another root (the move is
reserved while it happens: moveCatalogRecord, ExtendedKeyMoving). The old
root is then claimed by no record, although the table's older snapshots
still name files under it: a table registered or created over it loads
them and is vended credentials for them, and its drop purges them.
Reproduced on master: table u moved from ns/udir to ns/u2, an alias
created at ns/udir, the alias dropped: u's first snapshot's data file is
gone.
An update whose metadata location gives the record another root is now
refused with 400 InvalidRequest (ErrLocationMove) before anything is
written. No client path needs a move: a commit writes under the location
the record has (a table created without a location commits at its
assigned directory; a table renamed into another namespace keeps
committing at its directory, #12515). Lance's Overwrite register at
another dataset goes through UpdateTable and is refused the same way; an
Overwrite at the table's own location still works. The move reservation
stays (a reservation a crashed move left is still cleared by the next
update).
Tests: TestUpdateCannotMoveATablesRoot (the move refused, an alias over
the old root refused, the old snapshot's file kept, an update under the
table's own root works). Existing tests adapted to the rule, none
deleted: the UpdateTable refusals of TestLocationOwnedByOneRecord, the
moving subtests of TestLocationRaceBacksOut and
TestMoveReservationLeftBehind expect 400 with nothing written;
TestUpdateAfterRenameAcrossNamespacesRefusesAnotherTablesDirectory and
TestUpdateAfterRenameAcrossNamespacesMayMoveIntoItsNamespace expect
ErrLocationMove; vector_namespace_test.go's UpdateTable keeps the index's
root so its write reaches the fence it tests; lance
TestRegisterOverwriteKeepsTheOldDataset expects 400 for an Overwrite at
another dataset, the location unchanged and the dataset kept. Each
refusal is red with it replaced by the claim check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3tables: a record without a stored location is not renamed
A rename moves the catalog record and leaves the files where they are. A
record with neither a metadata location nor a warehouse location (every
Lance dataset, which lives at its name path; an Iceberg table created at
its name path by an older build) takes the root of its record path, so
after a rename it claims its new, empty name path and the files at the
old one belong to no record: a table created under the old name sits on
them. Reproduced on master: Lance table l renamed to l2, ns.l declared
again, l2's _versions/1.manifest is under the new ns.l.
A rename whose record would claim another root at its destination than
at its source is now refused with 400 InvalidRequest, after the
authorization checks (a caller without rights is answered as before). A
record with a stored location keeps its root and renames as before,
within its namespace or into another. In the vector namespace of a
vector bucket the read-only answer its fence gives stays the answer.
Tests: TestRenameRefusesARecordWithoutAStoredLocation: a Lance dataset
renamed in its namespace and a location-less Iceberg table renamed into
another are refused, both records and the dataset's files stay; a table
with a stored location renames (positive control). Adapted: the rename
subtest of TestLocationRaceBacksOut (its table has no stored location)
expects 400 with nothing written. Red with the refusal removed, and
TestVectorNamespaceIsReadOnlyOverLance/rename_out with the vector
namespace's answer skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Javier de la Torre <jatorre@carto.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: let a client ask for a shorter vended session, with an opt-in floor below 900 s
## Problem
The Iceberg REST catalog vends table-scoped S3 sessions on load and create with one process-wide lifetime, `-iceberg.credentialDurationSeconds` (default 3600). A client has no way to ask for less, and nothing can go below STS's 900 s floor. Some deployments want short sessions for some callers (a one-off read, a session handed to a less trusted process) without shortening them for every client: a process-wide 900 already breaks clients that keep a loaded table object for longer than its session (PyIceberg does not refresh vended credentials; DuckDB, Spark and Trino re-load and are fine).
The Iceberg REST spec has no parameter for a credential lifetime. The precedent is `DurationSeconds` on AWS STS and on Lake Formation's `GetTemporaryGlueTableCredentials`.
## Fix
- **Request header** `X-SeaweedFS-Credential-Duration-Seconds` on a load or create that asks for vended credentials (`X-Iceberg-Access-Delegation: vended-credentials`). A positive whole number of at most 9 digits is passed to the vendor; a missing, malformed, zero, signed or overlong value is ignored without an error, so clients that never send it see no change.
- **It can only shorten a session.** The vended lifetime is `min(asked, configured)`; with no configured duration the ceiling is STS's `TokenDuration`, capped at `MaxSessionLength` as STS caps it. A request at or above the ceiling changes nothing (the configured duration is sent, as before).
- **Floor:** new `-iceberg.credentialMinDurationSeconds` (`-s3.iceberg.credentialMinDurationSeconds` on `weed server` and `weed mini`), **default 900, which keeps today's behaviour exactly.** A request below the floor is raised to it. Values outside 1-900 mean 900, with a warning at startup; the setting can only lower the floor.
- **STS:** `AssumeRoleForPrincipalRequest` gains `MinDurationSeconds`, a per-request floor honoured only within (0, 900]. Only the catalog's vend sets it, and only when the client actually shortened the session: a vend at the configured duration keeps the 900 s floor (so a configured `credentialDurationSeconds` under 900 is still refused), and AssumeRole, AssumeRoleWithWebIdentity, AssumeRoleWithCredentials and every other action keep 900 through the unchanged `validateSessionDurationSeconds`. `MinSessionDurationSeconds` names the 900.
- **Caching:** load answers now send `Vary: X-Iceberg-Access-Delegation, X-SeaweedFS-Credential-Duration-Seconds`, so a cache never hands a session vended for one lifetime to a request that asked for another.
- The client learns the lifetime it got from `s3.session-token-expires-at-ms`, as today. The Lance namespace vend passes 0 (unchanged).
## Tests
- `weed/s3api`: `TestVendDurationRequestOnlyShortensTheSession` (real STS and trust policy; the lifetime read from the session JWT's `exp - iat` and `max_dur`): nothing asked keeps 3600; 120 honoured; 60 at a floor of 60; 7200 capped to 3600; 30 raised to a floor of 60; floor unset, 900 or 1200 keeps 900. `TestVendFloorDoesNotLowerAssumeRole`: with the floor at 60 the vend mints 60 s (positive control) while AssumeRole and AssumeRoleWithCredentials on the same server refuse 60 s. `TestVendDurationRequestRespectsMaxSessionLength`, `TestVendFloorDoesNotAdmitAConfiguredDurationBelow900`.
- `weed/iam/sts`: `TestSessionFloorIsLoweredOnlyForTheRequestThatAsks`.
- `weed/s3api/iceberg`: `TestCredentialDurationHeaderReachesTheVendor` (the accepted and ignored header forms), and the Vary test updated.
- Each rule undone turns its test red (request ignored: `TestVendDurationRequestOnlyShortensTheSession`, `…RespectsMaxSessionLength`; floor applied to every vend: `TestVendFloorDoesNotAdmitAConfiguredDurationBelow900`).
- `go vet` and `go test` of `weed/s3api`, `weed/s3api/iceberg`, `weed/iam/sts`, `weed/iam/integration`, `weed/command` pass, `-race` on `weed/s3api/iceberg`, and `weed` builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: let a shortened vend fit a caller credential with less than 900 s left
A vend the caller shortened below 900 s (with a lower catalog floor)
needs only that floor of the caller's credential to remain, not 900 s.
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>
* iceberg compact: optional spatial clustering of geometry tables
Compaction of an Iceberg v3 table with a geometry column merges files in
manifest order (bin-pack) or by a declared sort order. Neither keeps nearby
geometries together: after a bin-pack every output file and row group spans
the whole extent of the table, so a reader can skip nothing by the geometry
bounds and row-group geospatial statistics. In one measurement a point lookup
on a table of places read 4.59 MB after bin-pack compaction and 0.55 MB after
a spatial one. A declared sort order cannot express this either: Iceberg v3
has no spatial sort transform, a geometry cannot be a sort source, and DuckDB
refuses INSERTs into a table that declares a sort order.
This adds an opt-in spatial order to the compaction job.
Spatial clustering (`spatial_clustering`, off by default). When on, a v3
table with no declared sort order and exactly one top-level geometry column
is rewritten in the Hilbert order of each row's bounding-box centre, whatever
`rewrite_strategy` says (a declared sort order is still honoured, since such a
table does not qualify):
- The 62-bit key (31 bits per axis) is computed from the WKB while the rows
stream through the merge, carried as an extra last column through
parquet-go's sorting writer into a temporary file in `sort_spill_dir`, and
dropped when a plain writer copies the rows to the output. Row lineage is
mapped before the key is added. The grid is the globe for a lon/lat CRS and
the union of the bin's file bounds for a projected one. Null, empty and
unreadable geometries sort last. The key only orders rows; pruning stays on
the geometry bounds, so a poor key costs speed, never results.
- Files are listed by the key of their bound's centre before binning, so the
bins of one partition cover compact areas.
- Row groups target `spatial_row_group_size_mb` (2 MB, capped by the table's
`write.parquet.row-group-size-bytes`, at least 16 rows; an explicit
`write.parquet.row-group-limit` still wins). A row group is what a spatial
filter skips, and a row of a large polygon can be tens of kilobytes.
- A bin the order cannot be laid over (a projected column whose files carry
no bounds, a geometry column the merge cannot find, e.g. after a rename in
files without field ids) is bin-packed in bin-pack row groups.
- The table property `seaweedfs.compaction.spatial-column` names the column
when a table has several, or opts a table out with `none`.
- The snapshot summary records `rewrite-strategy=spatial` and
`spatial-column`, or `binpack` when every bin fell back, and
`spatial-fallback-bins` when some did. The planning
index's config hash covers the new settings.
Open time partitions (`spatial_hold_open_partitions`, default true, and
`spatial_open_partition_grace_minutes`, default 120; both only matter with
spatial clustering on). A spatially ordered partition has every row group
spanning its whole time range. On a day of vehicle positions, "where is every
vehicle now" read 2.51 MB of the spatially compacted day against 0.04 MB of
the files as written, while an area query on a closed day read 2.74 MB
against 19.35 MB. So a day or hour partition is left in write order until it
has ended plus the grace (late batches still land in it), and is ordered in
space after that. The job and detection hold the same bins; the planning
index caches its answer only until the first held partition is released, so
a table nobody writes to after midnight still gets its last day ordered.
Coarser time partitions and the other strategies are unchanged.
`github.com/twpayne/go-geom` (already in the module graph) becomes a direct
requirement for its WKB parser.
Tests:
- spatial_order_test.go: the Hilbert curve, plan resolution (version, sort
order, one or several geometry columns, the property, opt-out), 2,400
scattered points compacted end to end in spatial order with row ids kept
and no key column written, the job setting off as control, nulls last, a
projected CRS with and without file bounds, file ordering, and the
row-group sizing.
- spatial_fallback_test.go: the bin-pack fallback uses bin-pack row groups;
a geometry column the merge cannot find falls back, with the summary
saying so.
- spatial_open_test.go: partition ends for day and hour across the value
types a manifest reader returns and far from 1970; the hold, the grace and
their controls; the planning index release time and config hash; on the
fake filer, a day-partitioned geometry table where the job compacts the
past day in spatial order and leaves today's files, a table of only today
commits nothing, and the index records midnight UTC plus the grace (each
with the hold off as control); spatial clustering is off by default.
- Mutation checks: a constant key fails the spatial order tests; disabling
the hold fails four open-partition tests.
- go vet and go test (also with -race) of weed/worker/tasks/iceberg pass;
go build ./weed passes.
* iceberg compact: give the spatial sort key a name no table column has
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: report spatial order only for bins it wrote
A bin skipped after a read or merge error no longer counts as
spatially ordered in the snapshot summary or the job result.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: do not hold an open partition the spatial order cannot cover
A projected geometry column whose files carry no bounds is bin-packed,
so holding its open day or hour partition only left small files behind.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: do not hold a drop-only bin in an open partition
A bin whose rows are all deleted removes its files and writes nothing, so
there is no spatial rewrite for an open day or hour partition to wait for.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: pack delete-heavy files in the spatial file order
Delete-heavy bins took the table's order while the other bins of a spatial
plan list their files by the Hilbert key of their geometry bounds, so a
partition split into several delete-heavy bins merged overlapping areas.
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>
* pb: power-of-two gRPC buffer tiers up to 1 MB
## Problem
gRPC's default buffer pool has tiers of 256 B, 4 KB, 16 KB, 32 KB and 1 MB, and zeroes a pooled buffer's whole capacity on every `Get`. Every message between 32 KB and 1 MB therefore zeroes 1 MB, in the proto codec's marshal and in every receive. A filer entry that holds a table's Iceberg metadata (inline content, extended attributes) is such a message, several times per commit.
Profiled on `weed mini` under an Iceberg commit load (8 DuckDB writers, one table each, 30 s CPU profile): `runtime.memclrNoHeapPointers` under `sizedBufferPool.Get` was 2.39 s of 30.0 s sampled, 8% of the process's CPU. With the tiers below it is 0.74 s of 22.2 s.
## Fix
`weed/pb` sets the process-wide default pool at init (`experimental.SetDefaultBufferPool`, which gRPC documents as init-time only) to a binary tiered pool with every power of two from 4 KB to 1 MB (plus 256 B), so zeroing is bounded by twice the message size. Buffers are still zeroed; only the tier sizes change. The proto codec reads only the default pool; `NewGrpcServer` and `GrpcDial` also pass the pool as an option (`experimental.BufferPool`, `experimental.WithBufferPool`), because gRPC's own default server and dial options captured the old pool before this package's init ran.
Messages up to 32 KB and above 1 MB use the same tiers as before. Each extra tier is a `sync.Pool`, emptied by the GC like the others.
## Tests
`weed/pb/grpc_buffer_pool_test.go`:
- `TestGrpcBufferPoolIsTheDefault`: the default pool is the tiered one.
- `BenchmarkGrpcBufferPoolGet`: a `Get`+`Put` with gRPC's default tiers against these (Apple M-series, `go test -bench GrpcBufferPool -count 3 ./weed/pb/`):
| message | default tiers | power-of-two tiers |
|---|---|---|
| 40 KB | 9.8–10.1 µs | 0.59–0.71 µs |
| 100 KB | 10.1–10.8 µs | 1.24–1.29 µs |
| 300 KB | 11.1–14.7 µs | 5.6–5.7 µs |
`go vet ./weed/pb/` reports nothing in the touched files; `go test ./weed/pb/`: ok. `go build ./weed`: ok.
* pb: test the buffer capacity each gRPC pool tier hands out
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: rely on the default pool for dials, which read it per connection
grpc's defaultDialOptions() reads mem.DefaultBufferPool() at dial time,
so only the server, whose defaults were captured at grpc's init, needs
the pool passed as an option.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mem: return only slot-sized buffers to the slot pools
Free put any buffer into the slot its capacity rounds up to, so a nil or
odd-capacity buffer made a later Allocate of that slot panic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mem: serve the slots through a Get/Put pool type
SlotPool satisfies gRPC's mem.BufferPool, and Allocate and Free now go
through it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: use the slot pool as gRPC's buffer pool
The slots round up to the next power of two and do not zero, so gRPC
shares buffers with Allocate and no longer clears them on every Get.
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>
* mount: wake an upload parked on a read when the read ends
An upload that finishes while a read holds its chunk waits in its own
goroutine until the read lets go (`for up.IsLocked(index) {
up.readerCountCond.Wait() }`), and only then drops the sealed chunk and
returns its executor slot. The only wake-up came from MaybeReadDataAt,
which a read calls before it lets go of the chunk. UnlockForRead, where
the read does let go, woke nobody. So:
- A read that returns before its dirty-page pass never wakes the
upload. readDataByFileHandleWithContext skips readFromDirtyPages when
the chunk read fails, and the kernel interrupts a FUSE read, which
cancels it, whenever a signal reaches the reading thread.
- A read that does call MaybeReadDataAt wakes the upload while it still
holds the chunk, so the upload goes back to waiting unless the read
releases the chunk before the upload gets the lock back.
Only a later read of the same file then moves the upload on. When none
comes, because the file was closed or is no longer read, the upload
stays parked for good. It keeps its sealed chunk (and its share of
-writeBufferSizeMB, when that is set) and a slot of the
concurrentWriters executor, which every file of the mount shares (128
by default). Once parked uploads hold every slot, each new upload of
the mount waits for one, and writes and flushes behind them hang.
UnlockForRead now broadcasts when the last read of a chunk ends, which
is the only place the condition changes, and MaybeReadDataAt no longer
signals. It broadcasts rather than signals: a read across a chunk
boundary releases two chunks, and an upload may be parked on each.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: wait for the uploads to park instead of sleeping in the wake-up tests
parkUploads slept 100ms and assumed the uploads were waiting on the read
by then. An upload that had not got there yet would find the read gone
and go on without a wake-up, so the tests could pass with the wake-up
missing. It now watches the goroutines' stacks until each upload waits
on readerCountCond, counting out uploads an earlier test left waiting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: leave -cacheMinFreeSpace free on the chunk cache's disk
weed mount sizes its on-disk chunk cache by -cacheCapacityMB alone and
preallocates each cache file in full when it creates it. With a capacity
larger than the free space of the disk holding -cacheDir, the cache takes
that disk down to nothing: the preallocations run until fallocate fails,
and chunk writes fill the rest. The mount's metadata cache (a leveldb
store under -cacheDir) and the swap files of dirty pages (-cacheDirWrite,
which defaults to -cacheDir) live on the same disk, so once it is full
their writes fail with ENOSPC, and writes whose dirty pages spill to
swap return EIO to the application. The same happens when several mounts
share a cache disk and together are configured beyond it.
-cacheMinFreeSpace is the free space the cache leaves on that disk,
written like the volume server's -minFreeSpace: a percentage like 1 or a
size like 10GiB, 1 by default, as for volume servers.
- When the cache opens, its disk layers shrink to the space above the
floor, counting the cache files already in the directory as the cache's
own. With no room the disk tier keeps no files.
- Each new cache file preallocates only what the disk holds above the
floor at that moment, so the files of one cache, or the caches of
several mounts opening together, stop reserving at the floor.
- A chunk write that lands in blocks its file already holds, preallocated
or written, goes ahead as before, even with the disk under the floor.
A write that takes new disk space, into a file a rotation truncated or
where nothing could be preallocated, goes ahead only while the space
above the floor covers it. The disk is read at most once a second, and
the cache counts what it takes in between, so it cannot run past the
floor between readings. A rotation gives the truncated file's blocks
back, so the write after it reads the disk again.
A chunk the cache cannot place is not cached, like any other miss. The
webdav server's cache passes no floor and behaves as before.
* mount: read the cache disk on every write that takes space, leave the index files room
Review follow-ups.
- take reads the disk each time, instead of once a second less what the
cache took since, so a write sees what other mounts sharing the disk
wrote, and what a rotation gave back. It runs only for writes past the
blocks a file already holds, and a statfs costs little next to the
write.
- The index files (.idx and the leveldb maps) grow by a few dozen bytes a
chunk beside the data files that the cache size counts. Sizing leaves
them a sixteenth of the room above the floor.
- The cache's own files count as room by the blocks they hold, so a file
that was preallocated but not yet written when the mount exited counts
in full when the cache reopens.
- weed fuse checks -o cacheMinFreeSpace in the parent as well: the parent
waits for the child's signal, and a child that rejects the value never
sends it.
* mount: keep the resolveCacheDirs doc comment on resolveCacheDirs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: say -cacheMinFreeSpace stops new disk space, not every chunk
Under the floor the cache still fills the blocks its files already hold.
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>
Eviction picked the oldest finished download by the wall clock time it
finished at, and only counted downloads that finished before
time.Now(). A download that finished in the same clock tick as the
eviction didn't count, so the loop fell back to a chunk a stream was
still reading, and two pinned downloads that finished in the same tick
tied. After a wall clock step back, downloads that finished before the
step didn't count either, and with none of them pinned nothing was
evicted and the cache grew past its limit.
Finished downloads now take the next value of a counter on the cache,
which never ties or steps back.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep following the metadata log when the cache refuses an event
The mount applies each event of the filer's metadata log to its local
metadata cache, a leveldb store under -cacheDir. Once that disk is full
every write to the store fails, and an event the cache refuses goes one
of two ways:
- An event the stream delivers fails the follow, which the mount runs
with FatalOnError: glog.Fatalf ends the process, every file open on
the mount goes with it, and the mount does not come back when the disk
has room again.
- An event replayed from the persisted log is returned to the follow
loop, which resubscribes from it and fails on it again: the mount
stays up, but no later event reaches its cache, so its listings stop
changing.
A local change whose apply fails (create, mkdir, unlink, rmdir) drops
its directory's cached listing with InvalidateChildrenCache and goes on.
An event from the log now does the same: the cached listings it
changes, the parents it leaves and enters and a directory it creates,
moves or deletes, are dropped, so the next lookup reads the filer and
the next listing rebuilds them, and the event's kernel invalidations
still go out. The follow goes on. A warning reports the first such
event and then at most one a minute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: handle a refused event in the apply step that refused it
Review of the previous commit found two gaps.
A rename into a directory whose listing is being built applies the part
leaving the source at once and keeps the part entering the building
directory for the build to replay. When the part applied at once was
refused, the other part was not kept, and the build published its
listing without the renamed file. It is now kept whatever happens to
the part applied at once.
The listings a refused event changes were dropped, and its kernel
invalidations sent, by the follow's event function after the apply
returned. By then the apply loop could have taken a later request, such
as this mount's own create of the name a rename left, and the rename's
invalidation would then move the new file. The apply step that fails
now does both before it returns, as it sends the side effects of an
event the store takes, and on the apply loop, which owns buildingDirs
and is the only one to feed the invalidate worker. A local change whose
apply fails gets the same; its caller still drops its directory's
listing as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: fail an unlink the filer did not apply
* mount: hold an unlinked handle's flushes until the filer answers
* mount: mark a rename's replaced handle once the filer answers
* mount: read a draining handle's unlink mark under its lock
Unlink now sets the mark after the delete answers, while a close queued
before it can be draining, so the worker's bare read raced the write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the unlink comment about marking before the delete
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: wait for the close to block on the handle lock in the unlink and rename tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: wait on the handle lock with the untagged helper in the rename close test
waitAttributeReadFrame lives in a !freebsd test file, so the FreeBSD test
build failed on weedfs_rename_publish_test.go.
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>
exit() ends the process with os.Exit, which skips deferred calls, and
glog writes its files only every 30s. A short-lived command such as a
piped weed shell session lost every log line it buffered, including the
daily_run summary of s3.lifecycle.run-shard.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: read remote-only metadata files, and fail a table whose metadata cannot be read
## Problem
In a remote-mounted bucket (`remote.mount` + `filer.remote.sync`), a table's `metadata.json` that is not cached locally is a filer entry holding only its `RemoteEntry`: no inline content, no chunks. The Iceberg REST catalog read metadata files as inline content (and, for a register, chunks), so such a file read as empty bytes, and an empty read was then treated as "no metadata":
- a table stored with its metadata location alone (registered, or created through the S3 Tables API) loaded as an empty table: no schema, no snapshots, and clients read no rows;
- a commit to it was refused on a table UUID mismatch for ever, and a commit without requirements replaced the table's history with an empty one;
- registering such a file failed with `unexpected end of JSON input`.
The same empty stand-ins were served when the file was gone or unreadable, and a synthetic empty table when stored metadata did not parse, with the same consequences.
## Fix
- `loadMetadataFile` (and through it `currentMetadataBytes` and RegisterTable) reads a remote-only file of a mounted bucket: its remote size is checked against a 64 MiB bound before anything is fetched, it is cached into the cluster with `CacheRemoteObjectToLocalCluster` (one retry: a cache can race an uncache or a write-back), then inline content or chunks are read.
- An empty file is `errEmptyMetadataFile`. A staged create's empty placeholder is still treated as absent where the staged commit reads it.
- A location whose file is gone or unreadable, or stored metadata that does not parse, fails load, commit and transaction instead of serving an empty stand-in a writer could commit over. A table created without a location (no metadata yet) still loads as a new empty table, and a catalog-only record (Lance) is never read as Iceberg.
- RegisterTable refuses, before anything is read, a metadata location that is not a file directly in a table's `metadata/` directory (a deeper path was read as the same-named file there), and refuses metadata whose own `location` is not the table location it is registered from (a file copied from another table names that table's files).
- The table UUID a commit or a transaction stores is the base metadata's, not a record's that disagrees with it.
`loadTableMetadataBlob` (used only by the manifest repair) is unchanged.
## Tests
- New `iceberg_register_load_test.go` (inline and remote-only files; a location-only table loads from its file and fails with the file gone; commits and transactions keep the history, and fail leaving the table unchanged when the file is gone; oversized remote files and nested locations refused) and `TestACommitStoresTheBaseMetadatasUUID`. Each rule is red with it undone, except the refusal of an entry still remote-only after two cache calls, which fails closed anyway (it reads as an empty file).
- Adapted: the fixtures of `iceberg_register_table_test.go` (`seedRegistrableMetadata`, `seedOversizedMetadata`) give the metadata the table's own location; `TestLoadTableResultOmitsConfigForCredentialVendingClients` and `seedOwnedTable` store the table with its metadata; `TestBuildLoadTableResultNeverReturnsNilMetadata` now expects an error for a location whose file cannot be read and for unparseable metadata, and keeps the empty-metadata and no-location cases.
- `go vet ./weed/s3api/iceberg/`, `go test -race ./weed/s3api/iceberg/` pass, and `weed` builds.
No unit test reads a chunked `metadata.json` (the in-memory filer has no volume servers); that path was checked against a real cluster with a remote-mounted bucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: refuse commits to catalog-only tables
A Lance table loads as an empty Iceberg table, and a commit built on that
placeholder wrote Iceberg metadata and repointed the record's location
(the Lance dataset root) to it. Both commit paths now answer 400.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: pass the metadata size limit to the remote cache request
The size check ran on the entry the lookup returned. A remote refresh
between the lookup and the cache call could swap in a larger object, which
the filer then downloaded whole. With MaxSize the filer checks the entry
it actually downloads.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: apply the metadata size limit to inline content
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>
* s3tables: say why a write the table bucket layout refuses is refused
## Problem
A table bucket accepts only Iceberg files under `<namespace>/<table>/(data|metadata)/`. A PutObject, CopyObject or CreateMultipartUpload of any other key is refused with a bare 403 AccessDenied, which a client that put a plain file there (a README, a CSV next to the table) reads as a permissions problem and goes looking for a missing grant.
## Fix
Those three refusals now carry a message:
table buckets accept only Iceberg files under <namespace>/<table>/data/ or <namespace>/<table>/metadata/; put other objects in a general purpose bucket
Status and code are unchanged (403 AccessDenied).
The message tells the caller that the bucket is a table bucket, so it goes only to a caller the bucket policy lets write that key (`checkPolicyWithEntry`). A caller the policy denies gets the policy's own refusal, identical to the one for a key the layout accepts, so the answer never tells a table bucket from another bucket to someone who could not write there.
A PUT of the volume verification key that the layout accepts but `volumeVerifyPutAllowed` refuses (outside its window, too large, stored headers) is not a layout refusal and keeps the bare AccessDenied.
## Tests
`weed/s3api/table_bucket_layout_message_test.go`:
- `TestTableBucketLayoutRefusalExplainsItself`: PUT, copy and multipart initiation of `ns/t/data/notes.txt` answer 403 AccessDenied with the message. Fails without the change.
- `TestTableBucketLayoutRefusalIsBareWhenPolicyDenies`: with a bucket policy denying the write, the refusal of a layout-refused key is byte-for-byte the refusal of a valid `.parquet` key.
- `TestTableBucketVerifyRefusalIsNotALayoutRefusal`: a stale verification key keeps the bare refusal.
`go vet ./weed/s3api/` reports nothing in the touched files; `go test ./weed/s3api/`: ok. `go build ./weed`: ok.
* s3api: load the bucket before a layout refusal checks its policy
With authentication off nothing loads the bucket before the handler, so a
stored Deny was not in the engine yet and the first layout-refused write
after a restart got the table-bucket explanation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: apply existing-object tag conditions before a layout refusal explains itself
A Deny on s3:ExistingObjectTag is deferred by the first policy check and
applied only by the later lookup recheck, which the layout refusal skipped,
so a tag-denied writer still learned the bucket is a table bucket.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: name the format-owned directories in the table layout refusal
Table buckets also accept a table format's own _-prefixed directories
(Lance's _versions, _transactions, _indices), so telling a Lance writer that
only Iceberg data/ and metadata/ files are accepted misleads it.
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>
* iceberg maintenance: recognise deletion vectors whose format is written in lowercase
Iceberg maintenance tells a Puffin deletion vector from a Parquet position-delete file by its `file_format`, compared exactly with iceberg-go's constant `PUFFIN`. DuckDB records the format in lowercase, `puffin` (as it records `parquet`, which compaction already compares without case). Such a vector was never taken for a vector:
- the data file it covers was not kept out of compaction bins, and
- the vector itself was handed to the Parquet position-delete reader, which cannot read a Puffin file, so compacting any table holding one failed (and the position-delete rewrite tried to read it the same way).
The fix adds `isPuffin`, a case-insensitive comparison, and uses it at the four places that compared the format.
Test: `TestLowercasePuffinDeletionVector` wraps a deletion-vector entry so its format reads `puffin` (as the Avro reader passes it through) and checks that the data file it covers is excluded and that `collectPositionDeletes` does not try to read the vector. It fails without the change (`dv paths = map[]`).
`go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds.
* iceberg maintenance: apply deletion vectors in compaction; optionally rewrite delete-heavy files
Compaction has no reader for Puffin deletion vectors (DVs), so every data file a vector covers is kept out of compaction for good (`excludeDeletionVectorFiles`). A format-version 3 table that is reloaded with DELETE + INSERT (DuckDB writes a vector hiding all of the old file) keeps the old file and its vector forever, and every reader pays for both. Bins also form only from `min_input_files` small files per partition, so deleted rows never enter the decision.
This builds on #13127 (the case-insensitive `puffin` format check); the first commit on this branch is that PR.
Changes:
- **Vectors are applied.** The vectors of the compaction candidates are read with iceberg-go's `table/dv` (length, magic and CRC checked, and the decoded cardinality checked against the manifest's `record_count`) and joined with the Parquet position deletes the merge already applies. A vector that does not decode keeps its file out of every bin, as before, so a file never merges without its deletes. One Puffin file is read once per run even when it holds several vectors.
- **A consumed vector leaves with its data file.** When the snapshot removes a data file, the delete manifests holding its vector are rewritten (that vector `DELETED`, the other entries `EXISTING`); manifests without one are carried as they are. Vectors are matched by the data file they cover, never by the Puffin file path, because one Puffin file may hold the vectors of several data files (Spark writes them that way) and the vectors of files left in place must stay.
- **A bin whose deletes leave no row writes no empty file**; its files are just removed.
- **New setting `delete_ratio_threshold_percent`** (default 0 = off, so bin selection is unchanged unless set; Iceberg's own `rewrite_data_files` uses 30%). When set, a Parquet file whose vector deletes at least that share of its rows is rewritten in a bin of its own, whatever `min_input_files` says, packed by live bytes up to the target size. A file whose decoded vector deletes exactly positions 0..n-1 is dropped without being read; a manifest count that says "all" with positions that do not is rewritten row by row instead. Only files under the target file size are taken (the merge reads a file whole into memory), except a file dropped unread.
- **Detection reads no vector**: a DV's `record_count` is its cardinality, which is all the ratio needs. With `apply_deletes` off, planning ignores vectors (execution skips tables with deletes then). The planning-index cache key includes the ratio.
Tests (`deletion_vector_test.go`):
- a vector with a lowercase `puffin` format is matched to its data file under either path spelling;
- a merge with a vector and a Parquet position delete: every file merges minus its deleted rows, row ids kept, and the delete files leave the table (ratio off);
- a reloaded table: the wholly deleted file and its vector are dropped without the file being read (it is not even present), the new file untouched;
- ratio past / under / vector not decodable / manifest count says all but positions do not / partly deleted file past the target size left alone;
- two vectors in one Puffin file, only one data file compacted: the other file's vector stays;
- detection with the ratio on and off.
Each was checked red against a mutation of the rule it covers (exact format compare, vectors not applied, vector consumed by Puffin path, size check skipped, whole-file check skipped). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds.
* iceberg compact: check a deletion vector's blob range without overflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg detection: key the cached compaction plan on apply_deletes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg detection: skip a table with deletes while apply_deletes is off
Execution already skips it, so detection proposed a job that never ran.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: a drop-only bin is not held to the sort input cap
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: split delete-heavy bins at the sort input cap
The packer counted live bytes only, so two partly deleted files could
share a bin the sort input cap then dropped on every run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: compare the delete ratio in whole rows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: merge delete-heavy files in the order of their bounds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: read only the vectors of files a bin can take
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg compact: pack a vector whose count and positions disagree by its whole size
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>
* deps: bump parquet-go to v0.33.0
parquet-go v0.33.0 fixes several bugs that Iceberg compaction runs into:
- BOOLEAN columns that Arrow and parquet-mr write with data page v2 are
RLE-encoded. v0.32.0 decoded such runs wrong (a run's value byte expanded
bit by bit, runs taken as multiples of 8 values), so compaction rewrote the
flags wrong, and it wrote its own runs of trues with the value byte 0xFF,
which DuckDB refuses to read ("Payload value bigger than allowed")
(parquet-go/parquet-go#617, fixed by parquet-go/parquet-go#620).
- A column chunk without a dictionary lists the level encoding RLE next to
PLAIN. v0.32.0 took RLE as the column's encoding, so the schema derived from
a non-dictionary INT32 or DATE file could not write ("RLE: cannot encode
INT32 with invalid bit-width=0") and such files never compacted
(parquet-go/parquet-go#603, fixed by parquet-go/parquet-go#611).
- The sorting writer dropped the row groups' geospatial statistics when a
bin fit in its sort buffer, so a sorted rewrite of a geometry table wrote
files without a geometry bound (parquet-go/parquet-go#627, fixed by parquet-go/parquet-go#693 and parquet-go/parquet-go#700).
- A null in a list of required values wrote no value and shifted the rest of
the page (parquet-go/parquet-go#616, fixed by parquet-go/parquet-go#618); a short data page read leftover
values from a pooled buffer instead of failing (parquet-go/parquet-go#624, fixed by
parquet-go/parquet-go#731).
- A geometry or geography column declared without a CRS is now written
without one rather than with OGC:CRS84 spelled out (parquet-go/parquet-go#628, fixed
by parquet-go/parquet-go#688).
Changes that follow from the bump:
- A corrupt data page now fails with an error rather than a panic. The
position and equality delete readers returned that error without the file
name; they now name the file, as the data file merge already does.
- The default-CRS tests built their "spelled out" inputs with
parquet.Geometry(""), which now writes no CRS; they declare OGC:CRS84
explicitly. The footer rewrite in geometry_crs.go is still needed when an
input spells the default out, since the output schema comes from an input.
Tests:
- compact_rle_boolean_test.go with four pyarrow fixtures: two files with
v2-page RLE booleans (with nulls) read back and compacted with every flag
kept, and two non-dictionary INT32/DATE files compacted with every value
kept. All three tests fail on v0.32.0 (3005 of 6000 flags wrong; "no bins
successfully compacted").
- TestCompactSortedGeometryBoundCoversEveryRow only checked a bound when
there was one, so it passed with the statistics dropped. It now requires a
geometry bound on the data file and geometry statistics in the footer; it
fails on v0.32.0 and passes on v0.33.0.
- go vet and go test of every package that imports parquet-go
(weed/admin/dash, weed/mq/logstore, weed/mq/schema, weed/query/engine,
weed/worker/tasks/iceberg) pass; -race on weed/worker/tasks/iceberg and
weed/mq/logstore passes; go build ./weed passes.
* iceberg: fail the Arrow fixture tests on a read error
Both row-reading loops ended on any error, so rows decoded next to an
error could still pass the value checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: check each fixture row comes out of compaction exactly once
A row replaced by a copy of another kept the row count and passed the
value checks, which use the row's own id.
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>
* iceberg maintenance: whole-pass tests of equality deletes on a partitioned table
The equality-delete tests call the pieces (`collectEqualityDeletes`, `eqDeleteGroupsForBin`, `mergeParquetFiles`) one at a time. These run `compactDataFiles` end to end and check what a reader sees after the commit, including the deletes carried for files left uncompacted and the sequence numbers of the merged files. Tests only; no code changes.
The table has three partition specs: 0 unpartitioned, and 1 and 2 both `identity(name)` on the same partition field, so only the spec ID tells their deletes apart. It is written as a writer commits it: one snapshot per data sequence number, its manifests carrying the number and their ADDED entries inheriting it. Its equality deletes come in every scope: partition-scoped, global, by another column, and with keys that live in other partitions or specs. Each test reads the table before and after the pass with its own merge-on-read (each delete applies to data files with a lower data sequence number, under an unpartitioned spec or the same spec and partition) and compares the rows.
- Every two-file bin compacts, bin-packed and sorted; one partition's single file does not. The live rows are unchanged and the deletes are carried for the file left as it was (a merged file given an input's lower sequence number would lose rows to the carried deletes).
- Every file compacts: the rows are unchanged and the deletes leave the table.
- An unreadable partition delete fails the pass, names the file, and commits nothing; once the file is back the table reads as before.
- A delete under a spec the table does not list fails the pass and commits nothing.
Checked red against a mutation of the sequence-number rule (equality deletes applied whatever the sequence numbers): the first two tests fail. `go vet` and `go test ./weed/worker/tasks/iceberg` pass.
* iceberg maintenance: whole-pass table snapshot IDs differ from its sequence numbers
The fixture gave each commit's snapshot the ID of its data sequence number,
so a compaction that read an entry's snapshot ID in place of its sequence
number still kept the right rows. The IDs now count down as the sequence
numbers count up.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg maintenance: a whole-pass name-keyed delete that removes a live row
The only name-keyed delete matched no row, so a pass that ignored deletes
keyed by name still kept the right rows. u1 now holds a "zz" row that a
global name-keyed delete removes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: record the verified credential's expiry in the request context
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: cap a vended table session at the caller's credential expiry
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sts: let a principal session request cap the session's expiry
AssumeRoleForPrincipal takes an absolute NotAfter. issueSession caps both
the credentials and the signed token at it, so a cap computed before the
trust-policy lookup is not stretched by the time that lookup takes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: hand the caller's credential expiry to STS as an absolute cap
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* topology: record when the cluster started
StartedAt rides on MaxVolumeIdCommand; the first non-zero value wins so
replayed or racing entries cannot move it, and the max volume id mirror
file keeps it across raft state loss.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: carry StartedAt through raft apply and snapshots
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: leader records StartedAt once per cluster
The leader records it right after the topology id. A cluster that predates
the record gets the time its first upgraded leader runs. /dir/status shows it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: use current StartedAt values
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* topology: never lower the mirrored max volume id
A mirror rewrite for a StartedAt change could carry a bound older than
one already persisted. Keep the highest bound, and read StartedAt under
the file lock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* topology: let the latest applied StartedAt win
With first-wins, a master that restored an older-version snapshot without
the field could record a second value while the others kept the first.
Following the raft order makes every master converge on the same value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read KV keys a few at a time for a store without batch reads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* abstract_sql: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* redis: read KV keys in one pipeline
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* etcd: read KV keys in read-only transactions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mongodb: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* cassandra: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hbase: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* elastic: read KV keys concurrently
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* arangodb: read KV keys with one request
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* foundationdb: read KV keys in one transaction
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ydb: read KV keys with one query
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* tarantool: send KV reads before waiting for any
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: every filer store reads KV keys in batches
KvBatchGet moves from the optional KvBatchReader onto FilerStore. A listing
now reads the hard link records of its waiting entries together from any
store, a path-specific one included.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* tikv: count only the record reads of a listing in its test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: return every batched key that pads to the same stored row
SQL, MongoDB and YDB pad a short KV key with zero bytes, so "short" and
"short\x00" read the same row. KvBatchGet kept only the last such key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read keys in a plain loop when KvGetEach runs one at a time
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Spark resolved hadoop-aws and the AWS SDK bundle through Ivy from Maven
Central only, so a refused Central request failed the suite with
"module not found" before any test ran. spark.jars.repositories adds the
Google mirror after Central in Ivy's resolver chain.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* tikv: read a key from TiKV once per transaction
Inside one store transaction the filer reads the same key more than once:
a rename looks its source up when it starts and again to delete it, and
its target before the create and again in it. On TiKV a second read cannot
differ from the first. A transaction reads the store as it was when the
transaction began, and its own writes are answered from its buffer. Each
of those reads was still a request to TiKV, because the client keeps what
a batch get read with the transaction's snapshot and not what a get read.
Inside a caller's transaction a key is now read as a batch get of that one
key, and the next read of it is answered from the snapshot. A read outside
a caller's transaction is a transaction of its own and keeps the plain
get.
With the store on the client library's in-process TiKV, a rename of a file
to a new name sends 4 reads instead of 7, and one over an existing file 4
instead of 6.
The tests run the store on that in-process TiKV, which needs
pingcap/goleveldb as an indirect dependency.
* tikv: shorten the comment on the transaction read
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read the hard link records of a listing in batches
A hard-linked entry keeps its attributes and chunks in a record the file's
names share, and a listing reads that record for every hard-linked entry
it lists. It read them one at a time from the callback of the store's
listing: a round trip to the store for each such name, each waiting for
the one before, so a directory of hard-linked files listed far slower than
one of as many plain files.
A store may now say that it reads several KV keys in one round trip
(KvBatchReader). For a listing by such a store the wrapper holds the
entries back from the first hard-linked one on, up to 256 of them, reads
their records together and hands them on. The caller of the listing gets
the same entries in the same order, and the name of the entry it ended
the listing at.
TiKV implements it with the client's batch get. With the store on the
client library's in-process TiKV, the records of a directory of 200
hard-linked names take one batch get instead of 200 gets.
The TiKV tests run the store on that in-process TiKV, which needs
pingcap/goleveldb as an indirect dependency.
* filer: end a listing where its caller ended it, whatever the store met behind
The store goes on past the entry its caller ends the listing at, to the
entries that wait for their records with it, and may fail there. The
listing then returned the store's error, though a caller handed each entry
as it arrived would have stopped the store before it got that far. The
listing now ends at the entry its caller ended it at, and a caller that
fails among the waiting entries gets its own error, not the store's.
The same holds for the step a store takes after it is told to stop, when
the caller ended the listing at an entry the store had already passed. At
the last entry that waited the step's error is still returned, as it is
from a store that hands each entry on as it arrives.
* filer: finish a hard link listing on every return of the listing
The listing hands on the entries that wait from a deferred finish, so a
return path that lists from elsewhere with the same callback hands them on
too. The callback keeps the adjustedEntryFunc shape the prefixed listing
already had.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: pass the reader's context to persisted metadata log listings
The day and minute listings behind ReadPersistedLogBuffer used
context.Background(), so nothing scoped to the subscription reached them.
List through one helper that takes the caller's context.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: aggregated metadata stream reads the log files of peers with their own store
A filer with its own store never holds another filer's persisted
metadata log: log file writes emit no events and the bootstrap traverse
skips the log directory. The aggregated stream read history from the
local log directory and the in-memory aggregate ring only, and the ring
restarts empty, refilled from each peer's saved offset. A subscriber whose
cursor was older than that missed every event a peer recorded before it,
for example the S3 lifecycle worker replaying expirations.
Aggregated reads now also list the log directories of followed peers not
known to share this filer's store, merged by file name, so the existing
ordered reader and chunk-ref path serve their history. Local streams, which
peers aggregate from, stay local.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: bound peer log listings and fail the read when one fails
Each peer listing gets its own deadline, so a peer that stalls mid-listing
cannot hold the read. A failed listing now fails the read instead of
silently hiding that peer's persisted files; peers already retired as
unreachable are left out. Peers are asked from the same start name the
caller uses for its own store instead of the whole directory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep a still-unreachable peer out of log listings after its mark expires
A followed peer that keeps refusing connections is marked removed once, and
the mark is dropped with its resume point an hour later. It was then listed
again and its failing listing ended every aggregated persisted-log read.
Leave out any peer refusing connections for peerUnreachableRemovalAfter,
marked or not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: subscribe tests track their peers on the test filer's store
Aggregated reads now list the log files of followed peers with their own
store. The subscribe tests' peers have no server and share the test
filer's store, so record that instead of dialing them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read a missing path once when a rename or a delete looks it up
A rename looks its target up with FindEntryForOverwrite, and
DeleteEntryMetaAndData looks up the path it deletes the same way. Inside a
store transaction an ordinary lookup hides an expired S3 entry and leaves
its row for the commit. A write over the path still owes that row its
chunks and its hard link, so the store was read again whenever the lookup
came back with nothing.
It comes back with nothing far more often because the store holds nothing
at the path, which is what a rename to a new name finds. The second read
then repeats the first. Filer.findEntry already tells whether its answer
is what the store holds at the path, so the store is read again only for
a row the lookup found and kept from its caller.
Around 20 renames of a file to a new name on leveldb2 the store counter
shows 7 finds per rename before and 6 after.
* filer: shorten the overwrite-lookup comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
An open with O_TRUNC over an existing file stored the empty entry with an
unconditional UpdateEntry. The filer only routes conditional writes to the
path's write owner, so the truncate landed on the filer the mount talks to,
which deleted the chunks it dropped, while a peer's conditional chmod could
still commit at the owner over the entry it had not yet seen truncated. The
owner's write then brought the deleted chunks back into the entry.
The truncate now goes through saveEntryAttributes: guarded by the entry the
open found, routed to the owner, and replayed on the owner's entry when
refused.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume: read security.toml section headers that carry a trailing comment
The volume server's own security.toml parser compared each whole trimmed
line with the section headers it knows, so `[fips] # policy`, valid TOML
that Go's viper reads, fell through to an unknown section and its `mode`
was dropped: Go enforced the mode while weed-volume ran with FIPS mode off
and logged nothing. The same held for `[jwt.signing]` and every other
section. Header lines now have a trailing `#` comment removed before they
are matched.
Refs #13029
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sw-client: require the Extended Master Secret on verified HTTPS in FIPS mode
In FIPS mode only the `insecure_skip_verify` client configuration, which
sw-client builds itself, set `require_ems`. With certificate checks on,
reqwest built the configuration and left `require_ems` at rustls's
default, which is off for a provider that is not FIPS-validated, so a
trusted TLS 1.2 volume server without EMS was accepted where the insecure
path refused it. Go requires EMS in FIPS mode. Both FIPS-mode paths now go
through one rustls configuration built here: certificates checked against
`https.client.ca` or the system roots (loaded with rustls-native-certs, as
reqwest loads them), or not checked with `insecure_skip_verify`, and EMS
required either way. Off mode keeps reqwest's configuration.
Refs #13029
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: refuse a FIPS mode from a security.toml parse that did not read the file
resolve_fips_setting reads security.toml once to check that it can, then
parses it. The parse falls back to defaults when its own read fails and
reports that only in `file_read`, which was not checked, so a file that
became unreadable between the two reads resolved to FIPS mode off. A
parse without `file_read` is now the same FipsModeError::File as a failed
first read.
Refs #13029
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sw-client: refuse a malformed https.client.ca with insecure_skip_verify in FIPS mode
The FIPS-mode insecure_skip_verify configuration never parsed
`https.client.ca`, so a CA file whose certificate does not parse was
accepted there and refused on every other path, where reqwest or the
verified configuration load it. The CA is now parsed, and refused when
malformed, before it is set aside.
Refs #13029
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-vector: lock sw-client's rustls-native-certs dependency
sw-client depends on rustls-native-certs since the FIPS-mode HTTPS
configuration; seaweed-vector depends on sw-client by path, so a --locked
build there refused to update its lockfile. The crate was already locked
in seaweed-vector; only the edge was missing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The outgoing client took reqwest's rustls configuration, which leaves
require_ems at rustls's default: off for a provider that is not
FIPS-validated. A TLS 1.2 peer without EMS was accepted where Go's FIPS
mode refuses it. In FIPS mode the configuration is now built with the same
roots, CA and identity, and require_ems set.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer/posixlock: key lock owners and leases by principal
A lock's owner becomes (Principal, Sid, Owner). The principal is server-side
state, empty for unscoped callers, so owners with equal client-chosen sid and
owner under different principals conflict and never match on unlock, release,
reassertion or coalescing. The session index and leases key on
(Principal, Sid).
Scoped sessions are leased per key from their first acquisition: the lease
ends at the earlier of TTL after the last acquisition or renewal on that key
and Lease.NotAfter. Expired scoped locks are dropped before any operation on
their key as well as by ReapExpired. Unscoped sessions keep their current
whole-session lease, started by the first keepalive.
The handler passes the unscoped session for now, so behaviour is unchanged.
NewManagerWithClock lets tests drive lease boundaries.
* filer: bind scoped POSIX locks to the verified token id
PosixLock trusted the client-supplied sid. GET_LK reports a conflicting
lock's sid and owner, so a scoped caller with a write grant on the same path
could reuse them to unlock or release another holder's lock, keep it alive,
or replace it through a KEEP_ALIVE reassertion. A tokenless request with the
same identity could do the same.
A request admitted for a scoped token now acts for that token's verified jti,
derived in posixLockAuthority from the interceptor's authority. It controls
only the locks it took, whatever sid or owner it names. Its lease on each key
ends at the earlier of the 15s TTL after its last acquisition or renewal and
the token's expiry plus the clock leeway. Each renewal passes admission for
its key, so a narrower token cannot extend keys outside its grant. Tokenless
and unscoped calls keep the unscoped namespace and behaviour, and can no
longer match a scoped lock. Scoped TRY_LOCK and reassertion ranges must be
well-formed read or write ranges, checked before any state changes.
GET_LK, the protobuf and forwarding are unchanged; the principal is never
returned or logged. A renewed token with a new jti is a new owner: the old
locks expire and are reacquired.
* filer/posixlock: release an expired session once, however many ranges it holds
* posix locks: report a lock lost on re-assertion to the mount
A mount whose lease lapsed, for example when its scoped token expired or
was replaced by one with a new id, kept re-asserting locks that another
session had since taken. The filer logged the loss but returned success,
and the mount discarded the reply, so nothing on the mount side showed it.
KEEP_ALIVE now returns the first conflicting lock in the existing
has_conflict and conflict fields, which older mounts ignore. The mount
warns once per key when it learns of a loss and forgets it once a
re-assertion succeeds or the key is no longer held. Writes are not fenced.
* filer/posixlock: drop every expired session's ranges in one pass
* filer/posixlock: renew a scoped session's same-grant leases together
Scoped leases expire per key and a keepalive renewed only the key it named.
A mount renews its keys one keepalive at a time, so with many keys and slow
keepalives a round could outlast the 15s lease and a healthy mount lost
locks; unscoped sessions never had this problem because any keepalive
renews the whole session.
Each scoped lease now records a fingerprint of the verified grants it was
acquired or re-asserted under: a SHA-256 over the sorted, deduplicated
(access level, path) entries. A keepalive, bare or re-assertion, extends
every live lease of the same session (principal and sid) held under the
same fingerprint, each to the request's lease (the earlier of the TTL and
the token's expiry plus leeway). Leases taken under other grants, such as
a narrower token reusing the jti, are still renewed only by name, and a
lease that already ended is not revived before the sweep drops it. No
extra filer lookups; unscoped sessions are unchanged.
* filer/posixlock: bound same-grant renewal and refuse ended-lease grants
A scoped keepalive scanned every key of its session to renew those held
under the same grant, so a mount renewing N keys one by one did N^2 lease
visits per round under the manager's mutex. The scan now runs at most once
per quarter lease TTL per grant; every key under the grant still ends no
earlier than three quarters of a TTL after the latest renewal, and the named
key is always renewed in full.
TryLock now refuses a scoped grant whose lease has already ended, such as a
request admitted just before its token expired that then waited on the
manager, instead of granting a lock the next operation would drop. The filer
returns Unauthenticated, which the mount reports as EIO.
* filer/posixlock: skip same-grant scans by deadline floor, not by time
The scan throttle remembered when a grant was last renewed, not how long
that renewal made its keys last. A replacement token with the same id and
grants but a later expiry could then renew one key while the others kept
ending at the old token's expiry.
Each session now keeps, per grant, the deadline the last scan gave every
live key under it, lowered whenever a key is leased for less. A renewal
skips the scan only while that floor already reaches the earlier of its
own deadline and three quarters of a TTL from now, so a mount renewing
keys one by one still costs linear work.
A keepalive from a session holding no leases records nothing, and a
session's floors go with its last lease, so lock-less keepalives with
changing session ids no longer accumulate state the sweeper never sees.
* filer/posixlock: never move a scoped lease's deadline earlier
Renew, a re-assertion, a same-grant scan and a re-lock all set the key's
deadline to the request's own bound. A request under the old token of a
principal that already renews under a replacement (same id and grants,
later expiry) can land after the replacement's renewal, for example one
of the 32 concurrent keepalives in flight when the mount switched
credentials. It then cut the key back to the old token's expiry, and the
lock was dropped before the next round although the replacement had
renewed it. Keep the later of the current and the requested deadline:
every deadline still comes from an admitted request of the same
principal, so a lease never outlives the latest of its tokens.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer/posixlock: keep each session's index and leases in one map
bySession, lastSeen, leases and floors were four maps keyed by Session that
had to be created and pruned together. They become one sessions map whose
sessionState holds the session's keys (with each key's lease), its last
keepalive and its grant floors, so a session's state is dropped in one place.
The release loop shared by ReapExpired and ReleaseSession becomes releaseOn.
ReleaseSession now also forgets an unscoped session's last keepalive, so a
session it released is not reported again by the next sweep.
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>
* mount: refuse a merge whose local truncate cuts chunks a peer wrote
A flush refused by IF_ENTRY_EQUAL replays the handle's truncate onto the
stored entry. The truncate was made over the handle's base, so a chunk a
peer committed after that base was dropped or clipped silently, losing
data the peer had already fsynced. Like a stale whole-file rewrite over a
peer's chunk change, it now fails the merge. A base chunk the peer only
shortened carries no peer data and is still cut.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep the later mtime and ctime when merging a delayed flush
The merge took every attribute the handle changed from the handle, so a
flush that waited behind a peer's commit moved mtime and ctime back to
the handle's older write. Each time is now merged as one value (seconds
and nanoseconds were merged field by field, so a moved second could take
the peer's nanoseconds): the handle's time stands unless a peer moved it
too and later.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: let a truncate merge pass the handle's own committed chunks
A flush whose commit answer was lost finds its own chunks in the stored
entry while its base is still the older one. Those chunks are the
handle's writes, not a peer's, so they do not refuse the merge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: do not keep a stored copy of a chunk the merge re-adds from the handle
A stored chunk the base lacks but the handle holds is the handle's own
commit whose answer was lost. The merge appends the handle's chunks after
the stored ones, so keeping the stored copy referenced the chunk twice.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: take the manifests of a failed flush's fold for the handle's own chunks
A flush can commit its folded manifests and lose the answer. The handle
reverts to the member chunks and keeps its old base, so the next merge
found the stored manifest, knew neither its file id nor its key, and
refused it as a peer write across the handle's truncate.
The handle now remembers the folds of flushes that failed over its base,
and a merge unfolds them in the stored entry before comparing, so the
members match the handle's chunks. A peer's manifest is still refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: take a retried flush's own stored fold for its own chunks
The client retries a request whose connection dropped, and the first try
may have stored the flush's folded manifests. The retry is then refused
over them before the fold is recorded as failed, and the merge took the
manifest for a peer's write across the handle's truncate. The merge now
unfolds the flush's own fold in the stored entry as well; the condition
still names the entry as stored.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep every fold the filer may hold instead of the last four
Dropping the oldest of four could forget the fold the filer committed,
and the merge then refused that manifest again. A fold is now kept only
when the flush failed without the filer's answer, or when the refusal
lookup shows it stored, so a refused flush no longer adds one, and the
list ends with the base.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep a flush's fold when its first request may have been stored
A precondition verdict on a retried send does not prove the first send
stored nothing, and a failed refusal lookup then hid that it had. The
create now counts the sends of the request that carries the fold and
keeps the fold whenever the flush fails and that request was sent more
than once or never got the filer's answer. That covers both flush paths,
so revert is back to only restoring the chunks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the failed folds a refused create shows were not stored
A refusal means the stored entry moved off the handle's base, so no
request guarded by that base can store another fold. After the refusal
lookup the handle keeps only the folds whose manifests the stored entry
holds, at most one, which bounds the list over a base.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: bound the failed folds a handle keeps over one base
Flushes that keep failing with no filer answer each saved a new fold the
filer may hold, so the list grew for as long as the outage lasted. Once a
handle keeps maxFailedFolds folds over its base, its flushes send their
chunks unfolded for the filer to fold, and no kept fold is dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep the failed folds a refusal lookup does not show
The refusal comes from the file's write owner, but the lookup after it can
read a filer that lags behind and still shows the base. Pruning the folds
against that read forgot a fold the owner had stored, and once its manifest
showed up a pending truncate took it for a peer's chunk on every flush. The
maxFailedFolds limit bounds the list, so the folds stay until the base moves.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the chunks a failed flush sent that the handle has cut since
A flush that commits with its answer lost, then a truncate of the handle,
left the next merge with the handle's own committed chunks in the stored
entry, outside both base and the handle. The truncate check took them for
a peer's writes and refused every later flush over the base. A failed
flush now records the file ids of the chunks it sent that base lacks, and
the merge drops those the handle no longer holds: it cut or replaced them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: copy the failed flush's sent set with a loop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep folding past maxFailedFolds instead of sending chunks unfolded
The filer folds a flat chunk list itself, into manifests the handle does
not know: a lost answer then left one of them across a pending truncate,
and an acknowledged one gave the handle flat chunks under a folded base.
Flushes fold as before, and the handle stops keeping folds past the limit
while it still records the chunks they sent.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: read the stored manifests a refused merge cannot name
A fold changes no content, but a manifest the handle does not know sat in
the stored entry as one chunk: across a pending truncate it refused the
merge, though it can hold the handle's own chunks (a fold it did not keep,
or one the filer made). When the merge is refused, the flush reads those
manifests, replaces them with the chunks they hold and merges again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: hold the chunks the filer stored after a plain acknowledged flush
The filer folds a flat chunk list (the mount's own fold failed), and the
acknowledgement makes the stored entry the base while the handle kept the
flat chunks. A later merge took them for writes of the handle, which can
bring back chunks a peer's truncate removed. As after a merge, the handle
now takes the stored chunks, keeping those attached since the request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep a bounded record per failed flush instead of a growing set
The set of chunk ids failed flushes sent grew with every overwrite while
commits failed, and each failure copied it whole. Each failed flush the
filer may have stored (a send got no verdict) now keeps one record, its
fold and the ids it sent, built once and at most maxFailedFlushes over a
base. Past that, a merge refuses the chunks of a flush it did not keep
that the handle has cut since, as a peer's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: register the chunks a rebase or install gives the handle for reads
A handle that takes the stored chunks after a flush (or a peer's, after a
merge) can get manifests the filer made, and resolving them needs the
file's read token. rebaseEntry and installRewrittenChunks now record the
chunks under the file's path before the read view resolves them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: keep every chunk id a failed flush sent, cap only the folds
Past four failed flushes over one base the handle stopped recording what a
later flush sent. If that flush was stored with its answer lost, a truncate
of its chunks was refused as a peer's write and kept failing after the
filer came back. The ids now go into one set shared by the base's marks,
each kept once and never copied, until the base moves. Only the folds stay
capped: a stored manifest past the cap is read when a refused merge cannot
place it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: fail a flush over a peer's chunk change unless -concurrentWriteMerge
A content flush refused because another mount committed first used to
merge the handle's writes onto the stored entry. That merge now runs
only with the new -concurrentWriteMerge mount option (off by default).
By default a stored chunk change that neither the base nor the handle
holds fails the flush with EIO, and a peer's chunk event no longer
rebases a dirty handle. Attribute-only changes and the handle's own
commits (a lost answer, its own truncate) still merge.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: recognize the shortened references a failed flush sent
A truncate shrinks a base chunk in place, keeping its file id. A failed
flush that may have stored such a reference recorded only file ids base
lacks, so a later truncate saw its own stored reference as a peer's
change and failed with EIO by default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* worker: share the one-filer-per-store selection with other filer jobs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: add a meta_log_purge job that keeps the log past every TTL
The job deletes whole metadata log days once per filer store, keeping
every day that the longest filer.conf TTL, the longest S3 lifecycle rule,
a registered retention floor or a running replay job's cursor still
needs. A floor input that cannot be read stops the run before anything
is deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: register meta_log_purge in the lifecycle lane
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* maintenance: stop purging the metadata log from the default scripts
The meta_log_purge job now deletes old log days, keeping what TTLs,
lifecycle rules and replay jobs still need. fs.log.purge stays for
manual use.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: let an idle filer_ttl rule's read position release the log
filer_ttl no longer needs events up to read_ns, and an idle rule keeps an
old ts_ns while read_ns advances, so the floor follows the later of the
two.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: cap min_retention_days so a huge value cannot overflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: show the min_retention_days limit in the admin form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: give a registered retention floor the store's filer client
A floor that only gets a context cannot tell which cluster or store it
answers for, so it cannot ask that cluster's master or read the store's
own settings. Pass the filer client the job already holds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: keep the log an unfinished lifecycle walk will replay
A cold-start or recovery walk that resumes across runs rewinds its
shard cursor to the walk's start minus the longest lifecycle TTL once it
completes. Until then only its walk checkpoint records that start, so a
walk running for more than a day let the purge delete the creation
events the rewound replay reads. A checkpoint with buckets done or
partly walked now holds the floor at started_ns minus that TTL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: hold the walk start until the checkpoint goes stale
A walk clears its checkpoint in finish() before each of its shards saves
the rewound cursor, so a purge scan that read the old shard cursor and
then the cleared checkpoint saw neither. A cleared checkpoint keeps
started_ns, so every live checkpoint now holds the floor at its start
minus the longest lifecycle TTL. A finished one stops holding once it
has not been saved for cursorStaleAfter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: read walk checkpoints before the shard cursors they rewind
A purge scan that read a shard cursor, then a checkpoint that a later
walk had already replaced, saw neither the earlier walk's hold nor the
rewind its shards saved. A walk replaces its checkpoint only after the
previous walk's rewind is on disk, so reading the checkpoints first
always sees one of the two.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* lifecycle: save a fresh walk's checkpoint at its first progress
A walk that progressed during its first save interval and then stalled
for more than a day had no checkpoint on disk, so the metadata log purge
saw nothing holding the days its completion replays. A fresh walk now
saves on its first finished entry or bucket; a resumed walk already has
its record on disk and keeps the interval.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* lifecycle: rewrite an unchanged shard cursor so its mtime stays fresh
A shard stuck on RETRY_LATER saved identical bytes each pass, and
SaveInsideFiler skips identical content, so the file's mtime aged past
the meta log purge's staleness cutoff while the shard still needed it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: keep the log day a reader from the cursor lists first
Log files are named for their flush start, so a file from just before
midnight holds events after a cursor just past it. The reader backs off
one flush interval before choosing its first day; the purge now does too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: stop the meta log purge on an unreadable lifecycle policy
LoadCompileInputs reports a bucket whose lifecycle XML does not parse
separately from its error, so the purge used the shorter floors and
deleted days that bucket's rules may need once the policy is fixed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: read shard cursors with the replay's loader in the meta log purge
A shard cursor the replay refuses, such as an empty object, decoded as
a zero position and released the purge; it now stops the run instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: saturate the meta log purge's TTL plus a day
A lifecycle TTL near the largest duration wrapped negative once a day
was added, so the purge fell back to the shorter floors; the walk hold
at started_ns minus that TTL likewise dropped below zero and was lost.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: leave disabled lifecycle rules out of the meta log purge floor
AllActivePriorStates activates every compiled rule, so a disabled rule
still held the log for its TTL, and disabling it could not release it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: compute the meta log purge floor in SafeKeepFrom
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: fs.log.purge keeps the logs the meta log purge floor needs unless -force
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: run the fs.log.purge floor test without a master client
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: end a listing at a short page from a store that fills its pages
ListEntries read a directory a page at a time and stopped at the first
empty page, so every listing the caller's limit did not cut ended with
one more scan of the store, from the last name on, that returned
nothing: two scans for a directory smaller than a page.
A page that comes back short of its limit now ends the listing when the
store says it fills its pages (the new optional FullPageListingStore).
leveldb, leveldb2, leveldb3 and TiKV do: they iterate the directory's
keys until the limit is handed over or the keys end. A store that cuts a
page of names to the limit and then drops some (the Redis stores, for a
name whose entry is gone or expired) can end a page short with names
behind it; it does not declare the interface and is asked until a page
comes back empty, as before.
TiKV's listing swallowed an iterator error while it skipped the start
name or an expired entry, and ended the page there. It returns the error
now: a page that ends short must mean the keys ended.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: see through the path translator for a store that fills its pages
A path-specific store is wrapped in FilerStorePathTranslator, which does not
implement FullPageListingStore, so its directories kept the extra empty scan.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep the last listed name when a refill lists nothing
A page that lost entries to expiry is refilled from its last name. A refill
that found nothing returned an empty last name, so the next page of a store
that does not fill its pages started over at the top of the directory and
listed every entry again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: name the stores that fill their pages instead of an interface
A short list of store names in Filer.ListsFullPages replaces the
FullPageListingStore interface, the wrapper method and the per-store
declarations. A path translator reports its backend's name, so it needs
no unwrapping.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* foundationdb: read a listing in batches until it fills the page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* redis: fill a listing page past orphaned and expired members
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* redis2: fill a listing page past orphaned and expired members
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mongodb: report a cursor error that ends a listing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* tarantool: fail a listing on a malformed reply
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: test the last listed name after a refill that lists nothing
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: end a listing at a short page from any store
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rocksdb: build the tests against the current NewFiler
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rocksdb: count only listed entries toward the page limit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rocksdb: return the decode error instead of ending the listing
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>
A listing's snapshot only accounted for this filer's in-flight writes. A peer on the same store can have stamped a write below it that is not committed yet; the listing misses it and the client drops its event as already listed, leaving a stale entry (a mount reads a just-closed file as empty) until the next listing.
* filer, s3: give an entry without chunks the ETag of its inline content
A file written through a mount stores no MD5. With no chunks either (an
empty file, or a small one kept inline) S3 answered HEAD, GET and
listings with an empty ETag, and the filer's HTTP API with the chunk
form for zero chunks, "d41d8cd98f00b204e9800998ecf8427e-0". Both now
answer with the MD5 of the inline content, which for an empty file is
what AWS gives an empty object and what the same file gets once it is
written through S3.
An entry whose size reaches past its inline content (a hole that no
chunk covers) keeps the ETag it had.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: match If-Match on an entry without chunks against its inline-content ETag
The gateway now answers the MD5 of the inline bytes for an entry with no
stored MD5 and no chunks; the filer's conditional check still saw an empty
ETag, so a PUT with If-Match set to the ETag HEAD returned failed with 412.
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>
* filer: count and time the gRPC requests by method
The filer's request metrics cover its HTTP API. The mounts and the S3
gateway reach it over gRPC, so on a cluster used through them the filer
reported its store operations and nothing about the requests behind
them: how many lookups, creates, renames or listings arrive, how long
each kind takes, how many end in an error.
Two metrics for the gRPC port, filled by a unary and a stream
interceptor: SeaweedFS_filer_grpc_request_total{method, code} and
SeaweedFS_filer_grpc_request_seconds{method}. A stream is counted when
it ends, and timed unless the client holds it open (a subscription, a
client stream). A lookup that finds nothing returns ErrNotFound without
a status; it is labelled NotFound rather than Unknown.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: label a call ending in its context's error as gRPC reports it
A handler that returns ctx.Err() reaches the client as Canceled or
DeadlineExceeded; status.Code labelled it Unknown.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: count a health watch without timing it
grpc.health.v1.Health/Watch stays open until the client leaves, so its
duration is the connection's lifetime, like a subscription's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* metrics: dashboard panels for the filer's gRPC requests
Calls, errors by code, and p99/p50 durations by method, in the Filer row.
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>
* filer: grow the metadata log collection on its own, fall back when it is full
metaLog.volumeGrowthCount (default 2) is sent with assigns into the
metadata log collection, so it grows by a few volumes instead of the
master's default growth. When that collection cannot take the piece, the
assign falls back to the collection the log uses without the override, so
a full cluster does not stall the log.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep the metadata log in its own collection by default
metaLog.collection now defaults to filer-meta, so purging old log days
empties whole volumes instead of leaving log chunks scattered across the
default collection's volumes. Setting it to "" keeps the log in the
filer's -collection as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: default -max to 10 to leave room for the metadata log collection
The default collection still grows by 7 volumes; the extra slots keep
the filer's metadata log collection (2 volumes by default) from taking
them. Go and Rust volume servers share the new default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: bound the meta log collection's share of the assign budget
A meta log collection that cannot grow (for example a replication the
cluster cannot place) keeps answering with retryable errors, so the
first assign used the whole shared budget and the fallback was never
tried. Give it 10s, then fall back, and skip it for a minute after a
failure instead of waiting on it at every flush.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: name the default meta log collection so no bucket maps to it
A bucket named filer-meta mapped to the same collection, and deleting
it from the admin page or weed shell drops the collection directly at
the master, taking the metadata log with it. Bucket names cannot
contain "_", and filer group buckets map to "<group>_<bucket>".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: clear the meta log overrides after the viper test
Setting the collection back to its default value kept an explicit
override, so the defaults test passed even without the SetDefault.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: retry the meta log collection once its fallback also fails
The pause after a failed meta collection assign kept pieces on the shared
collection for a full minute even when that assign failed too, so meta
volumes that finished growing stayed unused while every flush failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: pick a default meta log collection no grouped bucket maps to
Filer group "_filer" with bucket "meta" maps to "_filer_meta". The
default now keeps its only "_" in front, and the test checks every
group and bucket split of it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: default the meta log collection to _meta
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep the default meta log collection on bucket delete
A filer that logs elsewhere did not treat _meta as reserved, so deleting a
bucket a storage rule maps to _meta dropped the collection other filers
write their logs to.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: refuse a "dir/" PUT body larger than a directory marker holds
A key ending in "/" whose body had no Content-Length took the marker
branch, was read whole into memory and stored inline in the directory
entry. One declaring more than 1024 bytes took the regular path, which
wrote it to the object "dir/dir".
Both now get EntityTooLarge: a declared length is checked before the
body is read, an unknown one is read at most 1025 bytes. An aws-chunked
body counts by its decoded length.
* s3api: size an aws-chunked "dir/" body without a decoded length as unknown
Without X-Amz-Decoded-Content-Length the marker check fell back to the
encoded Content-Length, whose chunk framing pushed a marker of up to 1024
bytes past the limit. Such a body is now read through the limit instead.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: keep a "dir/" body past a marker as a version in a versioned bucket
A versioning-enabled bucket stores a trailing-slash key larger than a
marker as a versioned object under its .versions directory, so refusing
it broke that write. Only the unversioned and suspended paths, which
would land on "dir/dir", refuse it now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: recheck a large "dir/" PUT against the versioning state its write uses
The size check and the write path each read the versioning state, so
versioning suspended in between sent the body to the suspended path,
which writes "dir/dir".
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>
* webhook: send the bearer token only to the configured endpoint's host
A redirect to another host or port, or from https to http, now gets the
request without the Authorization header.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* webhook: test the token scope across redirects
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* webhook: compare effective ports when scoping the token
An omitted default port and an explicit :443 or :80 are the same
endpoint; http on port 80 upgrading to https on 443 keeps the token.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* worker: add a filer_ttl job that walks filer.conf TTL paths
A filer store without native TTL keeps the rows of expired entries until
something looks them up or lists their directory. The job lists every
TTL path subtree once per filer store, so the filer drops the expired
rows it meets.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: register the filer_ttl job in the lifecycle lane
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: re-check an expired entry under its path lock before a listing deletes it
A listing deleted the expired entries it collected by path after the page
was read, so a write that replaced one in between lost its new row. The
delete now re-reads the row under the lock writers take, and in one
conflict-checked transaction on stores that refuse a commit over another
writer's change; anything but a still-expired row is kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: read each filer store's own filer.conf, chunk-backed included
Filers with separate stores keep separate filer.conf files, so one
filer's rules could hide another store's TTL paths. A config stored in
chunks read as empty. An unreadable config now fails the detection
instead of reading as no rules.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* command: count filer_ttl among the mini default job types
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: resume an unfinished filer_ttl walk from its checkpoint
The walk position is saved in the job's filer store every 30s and at
the first failure, keyed by store signature, and cleared when a pass
completes. The next run skips the prefixes and subtrees already walked,
unless the TTL prefix set changed or the pass is over 7 days old.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: save the filer_ttl checkpoint as soon as a walk fails
The first failure froze the checkpoint but only the end of the run saved it,
so a worker killed while walking later prefixes lost it. stop now saves it at
once; the end of the run saves again only if that save failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: keep a path TTL rule from expiring the filer_ttl checkpoint
A filer.conf TTL rule over /etc/ gave the checkpoint that rule's TTL, so an
interrupted pass could lose its record long before checkpointMaxAge. The
checkpoint is now written with its own TTL of checkpointMaxAge, which the
filer keeps instead of the rule's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: remove a filer_ttl checkpoint the new pass will not resume from
An overwrite keeps the stored entry's Crtime, and the checkpoint's TTL counts
from it, so a pass that replaced a rejected record could lose its own record
before checkpointMaxAge. load now deletes a record it rejects, and the new
pass creates a fresh one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: expire filer_ttl entries from metadata events per TTL rule
Each run replays every filer.conf TTL rule's metadata events from that
rule's cursor up to the run start, and looks up each entry whose TTL has
passed so the filer removes its row. The first entry not yet due holds the
rule's cursor, so a later run replays it. A rule without a cursor, or
whose TTL changed, is listed once to reach rows older than its replay
window. The periodic full walk and its checkpoint are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: re-check an S3-expired entry under its path lock before a listing deletes it
A listing deleted an S3-expired object by the row it had read, so an upload
that replaced it after the page was read was removed. The delete now re-reads
the row under the path lock and removes it only if it is still S3-expired.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: remove an expired row a lookup meets in a conflict-checked transaction
A lookup that met an expired row deleted it by path, so a replacement written
through another filer between the read and the delete was lost, even on
stores that refuse conflicting commits; a failed delete was hidden behind not
found. The lookup now re-reads and deletes through deleteIfExpired and returns
the delete error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: keep a failed filer_ttl lookup that ties a done event
When the first event at a timestamp was done and the second one's lookup
failed, the cursor already stood at that timestamp, so the retry subscribed
after it and skipped the failed event. A failed lookup now holds the cursor
below a tie, as a waiting entry does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: hold a filer_ttl event whose entry the filer still serves
A lookup that returned the live entry counted as done, so when the worker's
clock ran ahead of the filer's near the deadline the event was skipped and
the row stayed. An entry the filer still serves with the same deadline now
holds the cursor like one not yet due.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: keep a path TTL rule from expiring the filer_ttl cursors
The cursors were written without a TTL, so a filer.conf TTL rule covering
/etc/seaweedfs/filer_ttl gave them the rule's TTL and every rule was listed
again once they expired. When a rule covers them they are now written with a
TTL of their own, which the filer keeps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: list a filer_ttl rule again for a live entry its replay cannot reach
A new rule nested under a longer one started its replay one TTL back, so a
live entry the enclosing rule had stamped with its longer TTL, written before
that, was in neither rule's replay: the nested rule now owns it and the
enclosing rule skips it. The listing of a new rule now records the earliest
deadline of such entries, and the rule is listed again then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: hand a removed filer_ttl rule's replay to the rule enclosing it
When a nested rule was removed, its entries became the enclosing rule's, but
that rule's cursor could already be past their events, so they were never
replayed. The enclosing rule now replays from the earlier of both cursors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: list a filer_ttl rule whose unfinished events the filer no longer keeps
When fs.log.purge removed the event of an entry still waiting for its TTL,
the rule's cursor matched, so the rule was never listed and the replay never
met the entry again. A rule whose cursor is older than the oldest kept
metadata log is now listed, and its cursor moves to that log. The cursor also
records how far a replay read with nothing left waiting, so a quiet rule is
not listed just because old logs were purged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* worker: leave S3 lifecycle expiry to the s3_lifecycle job in filer_ttl
An entry whose TTL an S3 lifecycle rule set carries the S3 expiry flag;
s3_lifecycle evaluates and removes it. filer_ttl no longer looks such
entries up, and their deadline no longer holds a TTL rule's cursor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: drop the issue number from the shutdown test comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: end the filer walk when the consumer stopped following
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: end the follow when a retried event reports a stop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: check the subscriber is gone before the late event can end it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: never retry a filer call whose consumer stopped following
The walk already stopped on pb.ErrStopFollowing, but RetryOnError still
classified the wrapped error by its cause, so a transport-looking cause
reran the whole filer walk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: keep the cursor behind an event whose retry the follow ended
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: close the meta cache after the follow-cancel test joins it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(mount): reproduce the #5289 mount abort on a late metadata event
A metadata event that arrives after metaCache.Shutdown() reaches
glog.Fatalf through FatalOnError, so the mount dumps every goroutine and
exits 255 instead of unmounting cleanly — the signature reported in
issue #5289, still reachable on current master.
The subscriber has no way to stop: its context is rooted at
context.Background() and util.RetryUntil always retries, while unmount
closes the cache underneath it.
glog.Fatalf cannot be intercepted from another package (glog's
logExitFunc is unexported), so the reproduction runs the mount in a child
process and reads its exit code.
* mount,pb: stop following metadata when the cache closes
The mount follows metadata with FatalOnError, so an event that arrives
after metaCache.Shutdown() — which unmount guarantees, since the
subscriber is never stopped — was logged as a fatal and aborted the
process with a goroutine dump.
Report a closed cache as pb.ErrStopFollowing, a class the follow loop
ends on instead of routing through the per-event error modes. It is not
a failed event but the end of the subscription: no later event can land
either. SubscribeMetaEvents then leaves its retry loop rather than
reconnecting onto a store that no longer exists.
Also export the meta_cache sentinel as ErrClosed so consumers can tell a
closed cache from a storage failure.
* mount: end the metadata follow before closing the meta cache
The subscription goroutine had no owner: its context was rooted at
context.Background() and util.RetryUntil retried forever, while unmount
closed the cache underneath it. Every unmount left a window in which a
filer event landed on a closed store, and the mount survived it only
because the previous commit demoted that error.
Give the follow a context the mount owns, and stop it — cancel, then
join — before metaCache.Shutdown() in both teardown paths. MetadataFollowOption
takes a ParentContext so cancelling the caller ends the stream, which is
the ordering the filer already got in #11363 and #11663; the mount had no
equivalent.
Verified that the new assertion catches the ordering on its own: making
stopMetadataFollow a no-op fails it with the subscriber still running,
even with the fatal path already demoted.
* mount,pb: make a cancelled follow a stop, and cover the new seams
Review findings on the previous commits:
Cancelling the follow context surfaced as a bare gRPC Canceled, which
matched neither terminal condition, so every clean unmount logged an
ERROR, ran the retry callback — which wipes every cached listing on the
assumption that events were missed — and slept a second before the loop
stopped itself. Test the context instead of the error text.
Also assert the two new weed/pb seams where they are defined rather than
only through a mount exit code: ErrStopFollowing ends the stream without
reaching the per-event error modes and leaves the cursor behind the
event, and a cancelled ParentContext ends the stream. Publishing the
cancel handle and bumping the WaitGroup happen under one lock, so a
start racing a stop cannot let the join report success too early.
All four new tests were mutation-checked: dropping the early return,
ignoring ParentContext, removing stopMetadataFollow from ClearCacheDir,
and making stopMetadataFollow a no-op each fail their own test.
---------
Co-authored-by: whitefox <whitefox@mayflower.work>
* filer: flag help names the 503 an upload gets after the wait
The filer answers an upload that found no slot within
-inflightUploadDataTimeout with 503 and Retry-After: 1, not 429.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs: a restart after a Yandex token refresh may need a new token
The client keeps the refresh token Yandex returns in memory only, and
Yandex does not say whether the stored one survives the rotation, so the
doc no longer promises that a restart keeps working.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: read the entry path once per write
A create looks the path up to decide what it makes of the entry: the inode and
crtime to keep, the chunks the write leaves behind, the old side of the metadata
event. The store wrapper looked the same path up again, in
handleUpdateToHardLinks, to learn the hard link the name carried before. Both
reads happen under the same per-path lock, a moment apart, and for a file written
without a hard link the second one decides nothing at all: its result is
discarded. An overwrite pays for it twice over, because that read decodes the row
being replaced -- gunzip included above CountEntryChunksForGzip -- and it is the
row the create already holds.
Neither read shows up as a second find in the store metrics: the wrapper's goes
to the actual store, and FilerStoreCounter counts only FilerStoreWrapper.FindEntry.
The wrapper now takes the caller's word. InsertEntryReplaces and
UpdateEntryReplaces carry the entry a caller read to handleUpdateToHardLinks,
which keeps to it instead of reading the path again. An insert whose lookup found
the path empty goes the way #13006 opened with InsertEntryKnownAbsent, which
rename alone used.
Which word may be taken is the delicate part, so Filer.findEntry reports whether
its answer is what the store holds at the path:
- a lazy fetch from a remote mount serves an object the store does not have and
writes nothing to it, so it says nothing about the row there;
- inside a store transaction a lookup hides an expired S3 entry whose row the
transaction keeps until the commit, and a write replacing it still owes that
entry its hard link -- which is why FindEntryForOverwrite exists;
- where the expiry check deleted the row, the delete dropped its link already, so
an answer of "empty" is honest.
The write also reads the path itself whenever there is a link to take off, for
two reasons. A file with a hard link has its record changed again when the store
refused a commit (changeLinkRecord runs its change up to linkRecordAttempts
times), and each run must judge the name as the store holds it by then. And a row
that carries a link is the row whose link this write drops: plain creates are not
routed to the write owner, so another filer may have replaced the same name
already and dropped that link, and dropping it twice deletes the record under the
file's remaining names. What is trusted is the case with nothing to decide --
no link on either side -- which is an ordinary file write, since a mount makes a
link id only when a file is linked or copied.
The HTTP append path read the entry three times: once to merge with it, once to
prove it had not changed while the chunks were uploaded, and once in the create.
The create takes the recheck's entry now.
A 20-chunk entry on leveldb2 goes from 343 to 286 allocs/op and from 44.6 to
38.3 KiB/op per overwrite, the difference being the decode of the replaced row.
Where the store is reached over the network, the read saved is a round trip per
write.
Tests count the reads one write makes at the store, pin that a dropped link is
dropped once against a row another filer has already replaced, and keep the
create using the entry it is handed. #9645's own guard expected the create's
lookup to be what separates passing existing from passing nil; both are one read
now, so it requires one read either way and checks the crtime came from the entry
passed in.
Issue #5067.
Review of the first version caught one more case. The known-absent shortcut must
not take an entry that carries a link: InsertEntryKnownAbsent counts the name as
joining without reading it, so another filer storing that name for the same link
between this lookup and the write would have it counted twice, and the count
would run one above the names. The regular insert reads the name inside the
change of the record. CreateEntry and ReplaceFileForRename keep the write's own
read for a linked entry; TestNewLinkedNameStillReadsThePath pins it.
* filer: drop issue numbers from the write-read test comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: say a plain-over-plain write can miss a link stored after the read
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: whitefox <whitefox@mayflower.work>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The filer walk told the caller's expiry apart from a filer failure by
ctx.Err() alone. A server-side DeadlineExceeded can reach the client
before the context's own timer runs, so the walk recorded a failure
against each filer and moved on with no budget left, the same race
LookupVolumeIds already guards against.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* fix: retain released lock version watermarks
* fix(lock_manager): scope release records to lease identities
Keep a stable acquisition ID in opaque renewal tokens so release history cannot reject a valid lease from a different primary when generation counters overlap. Preserve earlier releases across new acquisitions and ownership eviction.
Carry the maximum lease expiry with releases, prevent renewals from shortening that bound, reject expired inserts, and reclaim release records after expiry. Track replication and handoff before sending copies so local-only leases need no release records.
Add regressions for fresh-primary failover, equal and lower generation counters, reordered releases and renewals, bounded retention, local-only workloads, ownership eviction, legacy release metadata, and gRPC release handling.
* lock_manager: name the release replay tests after the behavior they check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(lock_manager): serialize lease handoff with local mutations
Hold per-key mutation admission through a fresh lease snapshot, the transfer RPC, and source demotion or removal. A release that wins first suppresses the transfer; a release arriving during handoff waits and is forwarded to the new primary afterward.
Keep incoming replication outside the gate to avoid callback cycles. Retain source authority on transfer errors and apply transfer completion only to the lease that was sent.
Add real gRPC regressions for releases during both handoff branches and replay after release, plus coverage for fresh snapshots, transfer errors, unrelated keys, and replacement leases.
* fix(lock_manager): retry handoffs without retaining renewal authority
Deliver a source-held lease to the current owner before forwarding renewal or unlock. Freeze local authority before sending a transfer, including when the receiver may have committed despite an RPC error. Retry without requiring a membership change, with backoff and shutdown cancellation.
Recheck ownership after a background handoff and preserve the copy until the latest owner receives it. Replicate the effective installed expiry instead of a shorter transfer input.
Replace timing assumptions with a same-key admission contention hook. Cover pre-handoff releases, lost acknowledgements, retry cleanup, owner changes, and effective expiry. Document why identityless legacy releases cannot safely delete slash-format leases with overlapping generation counters.
* test(filer): set up DLM handoff before the peer lock transfer check
Ring-change transfers now go through Dlm.TransferFn, which
SetupDlmReplication installs; without it the lock stays pending on the
old filer and the peer-auth transfer test cannot see it move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(lock_manager): bound the handoff and unlock completion waits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(filer): give the handoff retry expiry subtest a one-second lease
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(lock_manager): serve lock and unlock here when a handoff ends with this node as primary
transferToOwnerLocked now returns the primary it observed after the
handoff. LockWithTimeout and Unlock redirected to the primary read before
the transfer, so a ring that moved back during the handoff sent the client
away from the node that holds the lease.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(lock_manager): bound the admission probes in the handoff tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix(filer): keep the holder's renew token while its lock handoff is pending
A failed transfer RPC or a frozen lease answered the lock request with an
error and an empty RenewToken. The client treats that as a rejection and
drops its token, so it can no longer renew the lease once the handoff
completes. Report transfer failures as LockHandoffPending and echo the
caller's token for that error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): return lease expiry from Lock, Unlock and InsertLock
The DLM was the only production caller of these methods and used private
twins (lockWithExpiry, unlock, insertLock) to get the effective expiry.
Return it from the public methods instead and drop the twins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): share the copy acceptance checks between InsertLock and InsertBackupLock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): drive handoff tests through TransferLockToOwner
TransferLock and its helpers were only reachable from tests. Remove them
so the tests exercise the production handoff path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* refactor(lock_manager): share the routing and handoff prologue of LockWithTimeout and Unlock
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Master <Master@node0.8m510.lpad-pg0.utah.cloudlab.us>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* mount: store a truncate through an open handle before answering
SetAttr with a new size and an open handle only marked the handle dirty,
so the size reached the filer at the next flush or release. A mount that
died before then brought the old size and data back, and an NFS export
answered SETATTR, which no COMMIT follows, with a size it had not stored.
Flush the handle once the entry locks are released, as a truncate
without a handle saves the entry. The writeback cache still defers it,
except under an NFS export.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: test that a truncate through an open handle is stored
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: refuse a truncate up past the quota before the file grows
The size is now stored before SetAttr answers, so a growth the quota
cannot take was installed and charged, then refused by the flush,
leaving the grown size on the handle. Check the growth first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: compare a truncate's growth with the quota headroom
The used size, the uncommitted writes and the growth were summed in
int64, so a truncate up to near 2^63 wrapped the sum negative and passed
the check. Take the growth as uint64 and compare it with what is left.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume: check the collection name in handlers that build file paths from it
AllocateVolume, VolumeMount, VolumeCopy and the EC rebuild, copy,
delete, mount and to-volume handlers joined the request collection into
volume file paths, so a collection such as "../x" reached files outside
the volume directory. They now apply checkVolumeCollection, as CopyFile
and ReceiveFile already do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: check the collection name in handlers that build file paths from it
Mirrors the Go volume server: allocate_volume, volume_mount, volume_copy
and the EC rebuild, copy, delete, mount and to-volume handlers apply
check_volume_collection, as copy_file and receive_file already do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: check the source's collection before VolumeCopy builds paths from it
VolumeCopy names the destination files after the collection the source
reports in ReadVolumeFileStatus, so that value needs the same check as
the request's collection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: check the source's collection before volume_copy builds paths from it
Mirrors the Go VolumeCopy: the collection the source reports in
ReadVolumeFileStatus names the destination files, so it gets
check_volume_collection too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: stub the source in the VolumeCopy source collection test
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: keep check_volume_collection's doc comment as on master
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The master client marks a master current as soon as the stream opens and
applies the first VolumeLocation afterwards, so GetLocations right after
GetMaster can miss volume 1 on a loaded runner.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(volume_server): wait out a server's disk I/O before calling its SIGINT exit a hang
stopProcess gave every server 10s to exit after SIGINT. On a CI runner
with a busy disk, the fsync in volume close can take longer than that:
the server is in uninterruptible sleep, not hung. Sample the server's
threads from /proc while waiting. Once one has been in D state, allow
up to a minute. A server that never touched the disk still fails at
10s, and the failure now lists its threads' states and wait channels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(volume_server): wait for the sleep child before checking its stop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test(volume_server): reap the SIGINT-ignoring child if it never starts sleeping
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ResolveChunkManifest gained a cutToSpan argument while this test was in
flight, so master stopped compiling weed/server. The test compares chunk
lists, so it resolves every referenced chunk.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: count the failure that creates an EC shard copy failure series
The EC shard copy failure counter exports a collection and reason pair
only once a copy fails, so rate() saw that first value as a baseline and
never showed it. The panel now shows failures per rate interval and adds
the earliest value of a series that did not exist one interval ago.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: count a new EC shard copy failure series from its last value
increase() extrapolates the increments of a series that appears inside
the window, and an instant offset selector loses an old series across a
scrape gap, so the panel could add a whole counter as new failures.
A series with no sample in the day before the window now shows its last
value; every other series shows increase().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: count the first EC shard copy failure after a restart
A restarted volume server exports a failure series again only at its first
failure, so when the same labels had a sample earlier in the day the window
held only the new counter's samples and increase() missed that failure. A
series whose lowest value in the window is below its last value before the
window has been reset since, and now shows its last value; a series back
from a scrape gap keeps its value and still uses increase().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add per-call filer authentication sources and pooled client wrappers
* Authenticate gateway filer calls with per-call admin tokens
* Authenticate shell admin and synchronization filer calls
* Authenticate workers MQ and remaining filer client paths
* Cache filer client signing keys and sign subscriptions with the shared key
Re-reading security.toml on every filer RPC cost about 125us against 8us for
signing. Keep the keys for up to a second, re-reading at once when a WEED_
override or the configuration directory changes. When the file exists but
cannot be read, keep the last keys read, else the startup keys, as
FilerAdminKeys does, so a process without a key stays tokenless. Metadata
subscriptions prefer the shared key, as filer peers do, because older filers
verify subscription admin tokens only with it.
* Authenticate admin-script, maintenance and filer.conf shell paths
Plugin worker admin scripts and master maintenance scripts build their own
shell options and carried no filer token source; fs.configure and
s3.bucket.quota.check read filer.conf without it.
* filer.cat: report a failed read; isolate key overrides in the admin-script test
filer.cat ignored the error from its filer call and exited successfully,
leaving a truncated -output file. Report the error and exit with failure.
The admin-script token test now clears the WEED_ signing-key overrides,
which take precedence over security.toml.
* security: refuse gRPC keys too short to sign; query engine uses client TLS
Under GODEBUG=fips140=only, hmac.New panics on keys under 14 bytes. The
startup check now covers jwt.filer_signing.grpc_key and grpc_previous_key,
and filer client token sources check the keys they read, so a reloaded or
per-endpoint security file with a short key is refused instead of
panicking when the next RPC signs.
The query engine's broker client dialed every master, filer and broker in
plaintext, so the admin token it now sends could cross the network in the
clear. It dials with the grpc.client TLS settings instead, and weed-sql
loads security.toml as weed-db does.
* security: per-endpoint admin tokens ignore WEED_ key overrides
FilerAdminTokenFromFile honored WEED_JWT_FILER_SIGNING_GRPC_KEY and
WEED_JWT_FILER_SIGNING_KEY. Those are process-wide, so filer.sync with
-a.security and -b.security signed both clusters' admin tokens with the
one key, handing each cluster a token valid on the other. A per-endpoint
file now supplies its own keys only.
* weed-sql, weed-db: refuse to start on an unreadable security.toml
Both only warned when security.toml was present but could not be read or
parsed. They then dialed without the grpc.client TLS settings while the
filer token source could still sign admin tokens from WEED_ environment
keys, so the tokens could travel in plaintext. They now exit with an
error that does not quote the file; a missing file is still fine.
* pb: take the filer token source in WithGrpcFilerClient and WithOneOfGrpcFilerClients
Fold WithGrpcFilerClientAuth and WithOneOfGrpcFilerClientsAuth into the
existing helpers instead of keeping two names for each. Callers without a
token source pass nil.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: return the read error from ReadConfiguration
Fold ReadConfigurationWithError into ReadConfiguration. The error is
returned and not logged, since parser errors can quote values; the
existing reload callers already warn when no file was read.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* security: keep the test-only filerAdminToken helper in the test
It had no production caller. The test helper now resolves keys through
filerClientKeysFrom, as the token sources do.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: read security.toml once in LoadSecurityConfigurationOrError
It validated the file, then merged it with a second read whose failure
was ignored and whose parser error was logged. It now merges with one
read and logs nothing from the parser. Viper's search also treats a
directory the process cannot search as holding no file; a candidate
that cannot be checked for lack of permission is now refused too.
* security: verify admin subscription tokens with the gRPC clock leeway
CheckGrpcMetadataSubscription checked admin tokens strictly, while unary
filer calls allow jwt.filer_signing.clock_leeway_seconds. With ten-second
client admin tokens, a subscriber whose clock trailed the filer's by more
than ten seconds was refused with a matching key. It now takes the leeway,
and the filer passes its configured one. The leeway check moves from the
server package to security.IsFilerAdminTokenWithLeeway so both use it.
* util: start without security.toml only when every candidate is confirmed absent
A candidate whose check fails for any reason other than not existing,
such as a symlink loop, is refused like one the process cannot search.
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep a stored manifest when a commit lists its chunks flat
Since #12462 the filer folds a commit's small chunks into manifests
256 at a time, whichever client sent them. A client that keeps its own
chunk list sends every chunk it wrote on each flush and does not take
the folded list back. The Hadoop client is one: SeaweedOutputStream's
hflush and hsync send CreateEntry with the whole list, which the client
folds itself only past 1000 chunks. Once 256 small chunks have piled
up, each flush makes the filer fold the same chunks again into a new
manifest blob, and the manifest of the entry it replaces is deleted:
up to three manifests written and three deleted per flush.
cleanupChunks now puts back, after compacting the list and before
folding it, each manifest of the replaced entry whose chunks the list
holds flat and unchanged (filer.ReuseStoredManifests). The manifest
must span exactly the chunks it holds. A manifest the commit lists
itself, one that cannot be read, one with a chunk changed or missing,
and a hard-linked file's are left alone. MinusChunks counts the kept
manifests as listed, so the commit does not delete them.
That entry has to be the one the commit replaces and deletes against.
UpdateEntry already prepares its chunks under the path lock from
the entry it read there. CreateEntry folded before taking the lock;
it now prepares the chunks under the lock, after its precondition
checks, and reads the replaced entry there when the request has at
least 256 chunks. filer.CreateEntry still deletes the chunks of the
replaced entry that the new list drops, which no longer include the
kept manifests.
TestCommitKeepsTheStoredManifestOfChunksListedFlat (create and update):
the second commit of the same list plus one chunk keeps the manifest,
writes no blob and queues nothing for deletion. It fails on master.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: take the replaced entry in cleanupChunks instead of a cleanupChunksReplacing twin
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: reuse a stored manifest only for its chunks listed in its order
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: keep the stored entry's manifests out of a refused update's cleanup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: do not reuse a manifest whose chunk ties with a chunk outside it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: drop a pull request number from a reuse test comment
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: look up same-timestamp chunks by index in the manifest reuse overlap check
The tie check rescanned the whole commit for every candidate manifest,
so a 102,400-chunk commit with 400 matching manifests ran 40M map
lookups under the path lock. Index the commit's positions by
ModifiedTsNs once and check only the positions sharing a held chunk's
timestamp.
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>
* filer, mount: read a manifest's chunks only within its span
Until #13042, a truncate through a manifest only shortened the manifest
chunk; the chunks it holds stayed whole. Reads resolve those chunks at
their own offsets and sizes, so once such a file grows over the cut again
without writing it, by an extending truncate or a write past the end, the
cut bytes come back where zeros belong. #13042 keeps new truncates from
leaving such manifests, but files a mount truncated between #12462 and
#13042 still have them.
Reproduced with weed mount on a local cluster: a mount from before #13042
appends 700 lines with one close() each, so the first 256 fold into a
manifest, and truncates the file to 100 lines; a mount from current master
then extends it past its old end with ftruncate. The extended range read
8,580 bytes of the cut lines instead of zeros, through that mount and
through the filer.
Reads now cut each manifest's chunks to the manifest's span:
ResolveChunkManifestForRead, used by NonOverlappingVisibleIntervals (filer
and S3 streaming, WebDAV, the mount's merge reads), the S3 ranged reads and
the mount's peer reads, and ChunkGroup for the mount's reads. A manifest
made by MaybeManifestize spans its chunks exactly, so only shortened ones
change. ResolveChunkManifest still returns the chunks whole: MinusChunks,
deletions and the other chunk-list comparisons need every chunk a manifest
references, or the chunks past the cut would never be deleted.
* sw-client: read a manifest's chunks only within its span
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: read a manifest's chunks only within its span
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: drop PR numbers from the manifest span comments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: fold ResolveChunkManifestForRead into ResolveChunkManifest
ResolveChunkManifest takes cutToSpan: the read paths pass true, the
deletion and chunk-list comparison paths pass false.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: cut manifests to their span when flattening an object's chunks
A full-object SSE GET, CopyObject and UploadPartCopy flatten the
source's manifests into a plain chunk list, which drops each manifest's
span, so the chunks a truncate left past a shortened manifest came back
as object data.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: purge a volume.fsck path only for chunks within a manifest's span
A chunk past a shortened manifest's span is still referenced but never
read, so a missing volume under it loses nothing. The purge decision now
uses the span-cut chunks while the inventory keeps every reference.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: cut manifests to their span in fs.distribute_chunks
The entry is rewritten with the resolved chunks as a flat list or a new
manifest that spans them, so chunks past a shortened manifest's span
became readable again. The filer's update still deletes them, since it
compares against the old entry's uncut chunks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: verify only the chunks within a manifest's span in fs.verify
A chunk past a shortened manifest's span is never read, so a missing
needle under it failed the entry and, with -pruneEntries, deleted a file
whose readable bytes were intact.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: mark the chunks past a manifest's span instead of allowing the visible ones
The purge gate now skips only the resolved chunks that the span cut drops,
so chunks that come from outside the manifests keep their purge behavior.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: skip the purge for a missing past-span chunk on a listed volume
volume.fsck -findMissingChunksInFiler queued a path for deletion when a
listed volume's index lacked any chunk the uncut inventory recorded,
including a chunk past a shortened manifest's span that no read reaches.
Record those chunks per path during the filer walk and let only a missing
chunk within the span queue the purge. The path is still reported.
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>
* feat(grpc): serve grpc.health.v1 on every server, add health-check-only client certificates
Every gRPC server built by pb.NewGrpcServer now answers the standard
grpc.health.v1.Health service, so blackbox_exporter's grpc prober,
grpc_health_probe and Kubernetes grpc probes can check SeaweedFS ports.
Check("") reports the server; Check(<service>) reports whether that
service is registered on the port.
grpc.health_check_commonNames lists client certificate common names that
pass the mTLS handshake on every component but may call only the health
service; any other RPC gets PermissionDenied. A monitoring probe can then
check the port and its certificate without a credential that opens the
whole gRPC API.
Fixes#5012
* seaweed-volume: serve grpc.health.v1 on the gRPC port
Mirrors pb.NewGrpcServer registering the health service on every Go
server: the whole server, the volume service and the health service
answer SERVING, other names NotFound.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: confine grpc.health_check_commonNames to the health service
Mirrors the Go healthCheckOnlyTap: a client certificate whose common name
is on [grpc] health_check_commonNames passes the handshake even when
allowed_commonNames is set, and any RPC outside grpc.health.v1.Health is
refused with PermissionDenied. WEED_GRPC_HEALTH_CHECK_COMMONNAMES
overrides the key like the other WEED_GRPC_ settings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-volume: end health watches when the gRPC server shuts down
Graceful shutdown waits for open streams, so a client holding a health
Watch kept the volume server from reaching store close. Clearing the
reported statuses ends every Watch stream once the shutdown signal fires.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* pb: end health watches before gRPC graceful stop
GracefulStop waits on open streams, and Watch held its stream until the
client left, so a connected probe kept volume and admin worker shutdown
from finishing and made filer and S3 wait out their drain timeout.
StopHealthWatches ends those streams; every GracefulStop path calls it
first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* scaffold: point mTLS health probes at an exec probe
The built-in Kubernetes grpc probe sends no client certificate, so it
cannot pass an mTLS port; grpc_health_probe run as an exec probe can.
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>
* java client: read security.toml without an [https.client] section
toml.getBoolean returns null for a missing key, so unboxing it threw a
NullPointerException in the static initializer and every FilerClient
failed with ExceptionInInitializerError when security.toml held only
other sections, such as [grpc] or [jwt.filer_signing].
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: sign filer JWTs and hold [filer.basic_auth] credentials
FilerSecurityContext reads jwt.filer_signing.key, jwt.filer_signing.read.key
(with their expires_after_seconds, defaulting to 10 and 60 like the Go
clients) and [filer.basic_auth] from security.toml, with setters to set
them in code. getFilerAuthorizationHeaderValue returns the credential for a
request to the filer's HTTP port: an HS256 token for the access level,
minted like security.GenJwtForFilerServer, else the filer Basic Auth, else
the existing [basic_auth] value.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: send the filer credential on filer-proxied chunk requests
With volume server access through the filer proxy, chunk reads and writes
address the filer's HTTP port, which checks the filer JWT or Basic Auth
before proxying. The write sent the AssignVolume token instead, which the
filer rejects with "wrong jwt", and reads sent no filer token. Send the
filer credential on proxy URLs only; direct and publicUrl volume requests
keep the volume token. With no filer credential configured, the old
headers are sent unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: take filer JWT keys and Basic Auth from the Hadoop configuration
fs.seaweed.filer.jwt.signing.key, fs.seaweed.filer.jwt.signing.read.key
(and their expires.after.seconds) and fs.seaweed.filer.basic.auth.user /
password override security.toml. The secrets are read with
Configuration.getPassword, so a Hadoop credential provider can hold them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: document a filer secured with JWT or Basic Auth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: fail a chunk fetch that answers a non-2xx status
doFetchOneFullChunkData returned the response body whatever the status,
so a 401 "wrong jwt" or a 404 JSON error was taken as chunk data and
cached. Throw instead, so the fetch tries the next location and reports
the error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client, hdfs3: accept filer Basic Auth with an empty user
The filer turns Basic Auth on whenever the password is set, user empty or
not. The client dropped credentials without a user, so a password-only
filer refused every proxied chunk request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: point the secured filer docs at [https.client]
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client, hdfs3: keep filer credentials on each filer client
The filer JWT keys and [filer.basic_auth] lived in process-wide fields,
so a second filesystem with its own fs.seaweed.filer.* options replaced
the credentials of the first one, and a filesystem without options
inherited the previous overrides. Each FilerClient now copies the
security.toml values into its own FilerCredentials, and chunk reads and
uploads use the credentials of the client that issued them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: let each filer credential option override only its own value
A password-only or token-lifetime-only option in core-site.xml was
ignored or dropped the security.toml user and key. Each option now
replaces just the security.toml value it names.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: show [https.client] for a secured filer and per-option overrides
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: note that [https.client] does not check the filer host name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: check filer tokens against the configured key and lifetime
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: do not follow redirects on filer proxy chunk requests
HttpClient copies the request's Authorization header onto a followed
redirect, even to another origin, so a relayed 3xx would hand the filer
JWT or Basic credential to the redirect target. A 3xx now fails like any
other non-2xx answer and the read moves to the next location.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: close the filer client when credential options fail
A credential provider error or a malformed lifetime option threw out of
the store constructor after the client had opened its gRPC channels,
leaving them open on every failed initialization.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* hdfs3: say the filer HTTP credentials apply only to filerProxy mode
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* java client: pick filer credentials by access mode and filer address
The proxy check matched any URL containing proxyChunkId=, so a volume
url or publicUrl carrying that text would receive the filer JWT or Basic
credential. Only filerProxy-mode URLs that start with this client's own
filer proxy prefix count as filer requests now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer: fold only runs of small chunks that lie end to end
#12462 folds every chunk under 1 MiB into manifests, 256 at a time in
list order. Two things go wrong when those chunks are not plain appends:
- A manifest's chunks are not compacted again. A small chunk that a
later write covers stays stored and referenced after the write hid it.
- weed mount's bloat check sums chunk sizes and counts a manifest by its
span. A manifest over chunks that are not next to each other spans
bytes other chunks hold, so the file looks bloated and the flush reads
it back and stores it again, whole.
With weed mount on a local cluster, a writer that appends 300-byte
records and rewrites a 4 KiB header at the front after each one (open,
two pwrites, close): after 766 records the mount logged "2.0x chunk
bloat detected ... (2 chunks, 475684 stored vs 233896 content),
merging" and rewrote the file, and did it again at 2.5x (1164184 stored
vs 463396 content); 1,600 records cost two whole-file rewrites. Each
rewrite reads and stores the whole file, and the next one comes a few
hundred flushes later. Random small writes fold their overwritten pages
the same way.
Only small chunks that no other chunk overlaps now fold, and only in
runs that lie end to end, so a manifest spans exactly the bytes it
holds. Appends make such runs and fold as before. Chunks between
full-size ones, chunks that overlap others and chunks with a hole
between them stay flat, as they did before #12462. What is left of a
run stays flat until the run grows.
* filer: size the small-chunk fold's result by its input
CodeQL alert 446 (go/allocation-size-overflow) flagged the capacity
len(inputChunks)-len(folded)+len(manifests). It cannot overflow, but the
input's length bounds the result anyway: each manifest takes the place of
SmallChunkManifestBatch chunks.
* admin: keep the volume id on tracked plugin jobs
Volume-scoped jobs carry their volume in the volume_id parameter, but
the in-memory job list drops parameters, so nothing could select a
volume's jobs without reading every job detail file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: filter plugin jobs and activities by volume id
/api/plugin/jobs and /api/plugin/activities accept volume_id, applied
before the limit like the lane filter. Activities follow the tracked
jobs of that volume.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: volume id filter on the plugin monitor
A Volume ID box next to the execution state filter narrows the queue,
execution jobs and activities to that volume's jobs, fetched with the
volume_id API filter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: keep detection scans visible under the volume filter
Detection activities belong to no job, so the volume-filtered activity
window had none of them and the Detection Jobs table went empty. That
table now reads its own job-type window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: accept zero-padded volume ids in the monitor filter
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: drop a monitor refresh that finishes after a newer one
Two refreshes of the same scope can finish out of order; the older one
then replaced the newer rows, with empty lists when its volume-filtered
fetch failed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: keep rows committed for the scope when a plugin monitor refresh fails
A failed request fell back to the rows captured when the refresh started,
so a refresh overlapping one that had already committed the new scope's
rows cleared them. Resolve the fallback when the refresh commits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: validate the monitor volume id before fetching
Out-of-range ids went to the APIs and came back 400. The filter is now
applied only from a valid change event, so the periodic refresh no longer
reads a value still being typed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: volume id filter on the job queue view
The queue renders the volume-scoped rows, but the only filter box sat on
the execution view, so an active filter was invisible and could not be
cleared there. Both views now carry a box kept in sync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: reject unparsable volume id text instead of clearing the filter
A number input holding text like "1e" reports an empty value with
validity.badInput set; treat it as invalid rather than as a cleared box.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* master: report each volume server's last heartbeat time
DataNode.LastSeen only moves when a volume server registers, so nothing
recorded when the master last heard from it. Stamp every processed
heartbeat and carry it in DataNodeInfo.last_heartbeat_ns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: show the master's last heartbeat time for volume servers
The volume server details reported the admin's own clock as the last
heartbeat. Use the time the master reports, and show unknown when the
master does not report one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: carry the last heartbeat time into the volume servers page
GetClusterVolumeServers builds its records from the master's volume list
without the topology conversion, so the details dialog showed unknown.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
handleJobCompleted hands the completion to the dispatcher before it
updates the tracked job, so the test could read the record while it
still said assigned.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* filer.proto: mark a forwarded StreamRenameEntry with is_moved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: send a rename whose source misses locally to the write owner
Exclusive and conditional creates are stored on the path's write owner. With
separate filer stores, a rename sent to another filer before it has replayed
the create found no source and failed, so a mount that flushed a deferred
create and renamed the file right after got EIO. Such a rename now goes to
the source's write owner, which moves the entry and whose events are relayed
to the caller, unless the owner runs on this filer's store. A forwarded
rename is applied only by the filer its own ring names as the owner.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: send an AtomicRenameEntry whose source misses locally to the write owner
The same race reaches the unary rename that S3, WebDAV, SFTP and fs.mv use:
an object or file created through the owner and renamed through another
filer before replication found no source. It is forwarded like the stream
rename, with is_moved bounding it to one hop.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rename: report a missing source as ENOENT
A rename whose source is absent fails with the store's "no entry is found"
error, which neither the filer's errno mapping nor the mount's message
mapping recognized, so the client got EIO instead of ENOENT.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.proto: report a forwarded AtomicRenameEntry's last event position
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: answer a forwarded rename once the owner's events are replayed here
The rename's target is stored on the owner only until this filer replays
it, so an unlink of that name sent here right after the rename would miss
it and report success. The owner now reports the log position of the
rename's last event, and the forwarding filer holds its answer (bounded)
until its stream from the owner has delivered that far.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: refuse a forwarded no-replace rename over a target this filer has
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: wait for an owner this filer no longer follows before answering a forwarded rename
PeersCaughtUpTo counts an untracked peer as caught up. An owner whose
stream was down long enough to be dropped has replayed nothing here, so a
forwarded rename answered then could leave a follow-up unlink through this
filer missing the target. Require the owner to be tracked with a watermark
at or past the rename, still bounded by ownerEventsCatchUpCap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume: report mounted EC shards whose file on disk is gone, replaced or resized
Each EC heartbeat tick stats every mounted shard file and compares it with the
open descriptor: a missing path or a different file is a ghost, a size other
than the mounted one is stale_size. Mismatches are logged per shard and counted
in SeaweedFS_volumeServer_ec_shard_disk_mismatch{reason}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): report mounted EC shards whose file on disk is gone, replaced or resized
Mirror of the Go check: each EC heartbeat tick compares every mounted shard
with its file (missing or another inode = ghost, other size = stale_size),
warns per shard and sets SeaweedFS_volumeServer_ec_shard_disk_mismatch{reason}.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* metrics: chart EC shards that disagree with their file on disk
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): tell a replaced EC shard file apart on non-unix hosts
Without inode numbers, compare the creation and modification times of the
path and of the open handle.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: check mounted EC shards off the heartbeat loop
A stat stuck on a stalled disk no longer holds up heartbeats or shutdown; at
most one check runs at a time.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): check mounted EC shards off the heartbeat loop
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): compare file ids to tell a replaced EC shard file apart on Windows
Timestamps can match on a replacement file. Use the volume serial and
file index from GetFileInformationByHandle there, and dev/inode on
unix, the same identity Go's os.SameFile compares.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): copy mounted EC shard state out before checking the disk
The check held the store read guard across its file system calls, so a
stalled disk kept the guard and a waiting writer could then stall the
heartbeat's own read. Copy each shard's path, size and file id under
the guard and check them after it is released. The id is recorded when
the shard opens, so no extra handle is held for the check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): run the EC shard disk check on a detached thread
Dropping the runtime waits for spawn_blocking tasks, so a stat stuck on
a hung disk could hold up shutdown. A plain thread is not waited on.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): stat the EC shard path instead of opening it
A replacement the server cannot read failed the open and was never
counted as a ghost. Compare device, inode and length from the path's
metadata, as the Go side does with os.Stat; on Windows open it with no
access rights.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): test the EC tick past a stalled disk check
The check thread start takes the check to run, so a test can stall one
after its snapshot and show that a writer still gets the store, the tick
still reports, and no second check starts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: keep VolumeServer int64 counters 8-byte aligned on 32-bit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3: return part checksums in ListParts
UploadPart stores the part's checksum on the part entry and returns it,
but ListParts built each Part from the SDK type, which has no CRC64NVME
field, and never filled the checksum fields. List each part with its
stored checksum so a client can verify an uploaded part after losing the
UploadPart response.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: name the upload's checksum algorithm and type in ListParts
CreateMultipartUpload records the requested checksum algorithm and
type on the upload, but ListParts never reported them. Return both, as
AWS does, when the upload was created with a checksum.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The runner image's package index can name versions the mirrors have
already dropped, so apt-get install fails with a 404 on the first
security update after the image was built.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* admin/maintenance: report whether the running manager queues a task type
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: list the EC balancers that are active at the same time
The plugin ec_balance job, the legacy maintenance manager's ec_balance task
and an admin_script job that runs ec.balance -apply each plan shard moves
from the same topology without knowing about the others.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: log a warning while more than one EC balancer is active
The check runs on the maintenance metrics tick and logs again only when the
set of active balancers changes. The legacy maintenance entry names the
admin.toml switch that turns it off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: warn on the plugin pages when more than one EC balancer is active
The scheduler status API returns the active EC balancers, and the scheduler
banner on the plugin and lane pages lists them when there are two or more.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin/maintenance: count a task type only when a registered worker can run it
Only legacy maintenance workers pull tasks from the legacy queue. With plugin
workers alone, the queued ec_balance tasks never run, so they do not compete
with the plugin ec_balance job.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: parse ec.balance apply flags like the flag package
A value counts only when strconv.ParseBool reads it as true, and a # token
ends the arguments, as it does for the shell command's flag parser.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin/maintenance: skip legacy workers past their heartbeat timeout
A disconnected worker keeps its queue record until the cleanup loop removes
it, so the capability check also requires a heartbeat within the worker
timeout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: count ec.balance only when its flags parse the way the command parses them
An invalid boolean in -apply or -force fails the whole command, the last
value of a flag wins, -force overrides -apply, and parsing stops at the
first non-flag argument.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: share ec.balance's flag set and report whether its arguments apply the plan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: count an admin_script ec.balance only when ec.balance accepts its flags
Unknown flags and invalid values of any flag fail the command before it
can move shards, so they no longer count as an active balancer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell, plugin/worker: move admin_script command tokenizing into the shell package
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: split admin_script ec.balance arguments with the executor's tokenizer
A quoted value with spaces is one argument to ec.balance, so flags after it
are still seen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: report through one lookup whether a command's arguments change the cluster
ec.balance now also rejects an invalid -volumeIds, as its Do does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: report whether volume.balance arguments apply its plan
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: report whether ec.encode accepts its arguments
ec.encode has no dry run, so any accepted invocation changes the cluster.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: report whether volume.vacuum accepts its arguments
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: report overlap for every maintenance work that more than one scheduler runs
The plugin scheduler, the legacy maintenance manager, and an admin_script can
each run volume balance, EC balance, EC encoding, and vacuum. Check all four
from one table and report each work with two or more active runners, in the
log and in the scheduler-status API as maintenance_overlaps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: show each maintenance overlap on the plugin pages
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: count object reads that fail after the status line is sent
A GET whose body breaks after the 200/206 was committed is recorded by
SeaweedFS_s3_request_total as a success and only shows up in the log.
SeaweedFS_s3_read_aborted_total{bucket,cause} counts these reads on the
volume-server, SSE and remote-mount stream paths, split into
client_canceled, deadline_exceeded and read_error, and is dropped with
the other per-bucket series when a bucket is deleted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: plot aborted S3 reads by bucket and cause
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: count aborted reads of inline objects and directory content
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: count gRPC deadline failures as deadline_exceeded aborted reads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: count an aborted read as client_canceled only when its request was canceled
A context.Canceled error under a live request context comes from an
internal cancellation, such as a shared lookup canceled by another
request, so it is recorded as read_error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* admin: inspect an S3 object's versions, retention and chunk volumes
For a bucket and key, collect the base entry and every entry under
<key>.versions, decode version id, delete marker, ETag, client checksum,
Object Lock mode, retain-until, legal hold and the WORM enforcement time,
and map each chunk to its volume. One filtered VolumeList then reports,
per volume, replicas present versus the replica placement, or the EC
shards present and missing against the data shard count.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: serve the S3 object inspection at /api/s3/buckets/{bucket}/objects/inspect
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: add an Inspect Object page for a bucket and key
/object-store/buckets/{bucket}/inspect?key= renders the inspection:
volume health per chunk volume with a link to the volume or EC volume
page, then every version with size, mtime, ETag, client checksum, lock
mode, retain-until, legal hold, WORM time and its chunk file ids.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: link each bucket to the object inspector
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: inspect a key that is also a prefix of other keys
The filer keeps such an object on a directory entry marked as a prefix
object, so the base entry lookup must accept it like a file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: count only S3 version entries as an object's history
A sibling named <key>.versions is history only when it is a directory,
and only children with a version id (attribute or v_ file name, as
VersionIdFromEntry reads them) are versions. Without a base object or
any such version the inspection is not found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: mark the newest version latest when the pointer is missing
When the base object is gone and .versions has no latest pointer (for
example after deleting a current null version), pick the latest with the
S3 gateway's own version ordering, exported as SelectLatestVersionId,
instead of leaving every version noncurrent. A truncated listing marks
none, since it may not hold the newest version.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: report the ETag the S3 gateway returns
Use objectETag, exported as ObjectETag, so remote-only entries show
their remote ETag and entries without a stored ETag or MD5 show the
chunk-derived one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: read the buckets path with the inspection's request context
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: report the filer's logical size for each inspected version
filer.FileSize also covers chunk extents past a stale attribute size and
a newer remote size.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: drop EC shard state once a volume also reports a replica
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: let the latest-version pointer outrank the null-is-latest flag
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: page the inspector's version scan past non-version entries
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: judge an inspected EC volume by its newest encode run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* volume: count failed EC shard copies by reason
Each failed VolumeEcShardsCopy now increments
SeaweedFS_volumeServer_ec_shard_copy_failures_total{collection,reason} and
logs the volume, shards, source and reason. Reasons: source_not_found,
empty_index, no_space, timeout, io_error, other.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* grafana: chart EC shard copy failures by reason
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): count failed EC shard copies by reason
Mirrors the Go volume server: each failed VolumeEcShardsCopy increments
SeaweedFS_volumeServer_ec_shard_copy_failures_total{collection,reason}
with the same reasons and logs the volume, shards, source and reason.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume: classify wrapped gRPC NotFound and DeadlineExceeded copy errors
A source status that the destination wraps as text keeps its code only as
"code = NotFound" (Go) or the code's description (Rust), so match those
too.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rs): record EC copy failures inside the copy task
The copy keeps running after the caller cancels, so its failure is
reported from the spawned task; a join error is reported by the handler.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* master: warn when a volume server registers in the default data center or rack
A volume server started without -dataCenter or -rack lands in
DefaultDataCenter/DefaultRack. Next to servers with explicit placement it
becomes its own failure domain for placement and balancing. Log a warning
when such a server registers while other servers name their data center,
or other racks of the same data center are named.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: warn about volume servers left in the default data center or rack
The Volume Servers page lists the servers that fell back to
DefaultDataCenter or DefaultRack while other servers name theirs, with
their volume and EC shard counts, so the stray failure domain shows up
before placement and balancing act on it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: cluster.check warns about volume servers in the default data center or rack
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: cluster.check prints placement warnings before the capacity checks
A disk type with no free slots made cluster.check return before the
default data center/rack warnings were printed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: list each data center's rack once in the default placement check
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: operation: pass needle pairs through chunked uploads (#12997)
* feat: s3: build Content-Location needle pair from the object path (#12997)
* feat: s3: record object path in needles written by putToFiler (#12997)
* feat: s3: record destination object path in copied chunks (#12997)
* feat: s3: record destination object path in stream-copied chunks (#12997)
* test: s3: pin Content-Location in putToFiler upload options (#12997)
* s3: record no path on copies of volume-encrypted chunks
A chunk written with -encryptVolumeData is copied as ciphertext through
the plain upload path, so the copy sent the destination path in
plaintext next to encrypted data, while PutObject's cipher upload sends
no pairs at all.
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>
* ci: keep dev builds published and document them
The dev release was emptied before every build: the cleanup job deleted
all weed-* assets first, and cancel-in-progress cancelled the build on
the next master push. Build the platforms with one prepare timestamp,
upload first, then prune assets from older builds. Queue runs instead
of cancelling them, and allow manual runs from master only.
Document the dev binaries and the :dev container images in the README
and docker/README.md.
Refs #5009
* ci: key dev build concurrency by ref
A workflow_dispatch from another branch joined the single dev group and
replaced the pending master run before failing its ref guard, so the
newest master commit was never built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* ci: keep newer dev builds when an older run retries
A "Re-run failed jobs" of an older run keeps that run's BUILD_TIME, so
its prune treated a newer complete build as stale and deleted it. Prune
now deletes only assets whose stamp sorts before BUILD_TIME.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The Go volume server re-reads its gRPC and HTTPS cert/key files on
SIGHUP (certreload.ReloadAll). The Rust server built each rustls
ServerConfig with a fixed cert, so a rotated pair only took effect
after a restart. Serve the pair through a resolver that re-reads the
files on SIGHUP and keeps the previous pair when the new files fail to
load.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
TLS certs currently refresh only on the periodic WEED_TLS_CERT_REFRESH_INTERVAL poll (5h by default), so after replacing cert/key files an operator has to wait up to one interval for the new material to be used. SIGHUP already reloads configs and JWT keys, but not TLS.
Replace gRPC's pemfile.Provider with a small certprovider.Provider in weed/security/certreload that keeps the current KeyMaterial, refreshes on the same timer, and can be forced to re-read the files via Reload. A process-wide registry plus grace.OnReload(ReloadAll) makes SIGHUP apply rotated certs immediately to every gRPC and HTTPS server/client.
On parse/read errors the previous material is kept, so a broken rotation does not take the listener down.
Fixes#13056
Co-authored-by: whitefox <whitefox@mayflower.work>
* master: /col/delete requires an explicit collection name
A /col/delete request without a collection parameter, or with an empty
one, read as the empty-named default collection and deleted it. Return
400 instead, and accept collection=_default (the keyword weed shell
uses) to delete the default collection deliberately.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: keep a collection literally named _default addressable by /col/delete
collection=_default now names the empty-named collection. A collection
created with that literal name would have been unreachable, and a request
meant for it would have deleted the default collection instead. Resolve
the keyword to the literal collection when one exists, and refuse the
request when both exist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: /col/delete accepts only the DELETE method
A GET is expected to be safe, yet a bare GET or a link prefetch deleted
the named collection. Any other method now gets 405 with an Allow
header, and the docs, benchmark help and test helpers send DELETE.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: /col/delete accepts _default_ for the default collection
When a collection literally named _default exists next to the default
collection, collection=_default is refused, which left the default
collection with no way to be named. Accept the _default_ spelling that
weed shell collection.delete already takes; it always means the
default collection.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* master: /col/delete keeps a literal _default_ collection addressable
_default_ now resolves like _default: to the literal collection when one
exists, to the default collection otherwise, and refuses the request when
both exist.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* REST_API: /col/delete when both keyword names are literal collections
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>
* filer.sync: retry an update whose destination lookup failed transiently
FilerSink.UpdateEntry reported every lookup error as a missing entry, so
the replicator and filer.sync deleted the destination key and created it
again. For a directory, a canceled or unavailable lookup removed it with
everything under it. Only a real not-found now lets the caller recreate
the key; other lookup errors are returned for retry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: leave a pointer to a recently minted version unrepaired
When a versioned read finds a latest pointer whose version file is
missing, the self-heal rescanned .versions and then either removed the
directory (no version left) or rewrote the pointer to the newest version
found. With filer.sync the directory and its pointer can arrive before
the version file, so the heal acted on a version still in flight: the
local directory removal replicated back and deleted the committed
version on the source cluster, and a pointer repair would roll its
latest pointer back.
While the pointer names a version minted in the last ten minutes, the
read now answers from the rescan without persisting anything, and the
reconciler skips the key. After that window the heal works as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: retry a failed destination lookup before giving up on an update
Returning a transient lookup error leaves the retry to the caller, and
filer.replicate hands a failed event to the notification input instead
of replaying it. Retry the lookup in place with the shared bounded
backoff; a not-found still returns at once.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync: count only the not-found sentinel as a missing destination
LookupEntry already maps every miss to filer_pb.ErrNotFound, plain-text
ones included. Matching the sentinel's text in any error also counted an
Unavailable lookup carrying that text as a miss, which let the caller
delete and recreate the key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: requeue an in-flight versions pointer for after the grace window
The reconciler dropped a key whose pointer named a version still in
flight, so nothing revisited it once the window passed. Requeue it for
one grace window without counting the skip as an attempt.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: probe the latest version file before deferring an in-flight pointer
A recent pointer whose version file is already present needs no repair;
deferring it kept the key queued for the whole grace window and used
up queue capacity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: retry an in-flight versions pointer when its grace runs out
The reconciler waited a full grace window after the deferral, so a
pointer first seen near the end of its grace stayed unrepaired for
almost twice as long.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: run the in-flight pointer grace from its local commit too
The grace was measured from the version id's mint time on the origin
cluster against the local clock, so a peer whose clock ran more than
the grace ahead, or a filer.sync backlog longer than the grace, saw a
just-synced pointer as stale and could remove or roll back the version.
The .versions entry's commit time is stamped by the local filer when
the pointer is stored, so it bounds the wait with the local clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: repair a pointerless .versions entry despite a recent commit
The in-flight grace protects a pointer whose version file has not arrived
yet. A .versions entry with no pointer names no such file, so a recent
commit of it must not hold back the rebuild of its pointer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: hold a stale-pointer repair while the live entry is still in grace
The heal checked the grace on the snapshot it took before the scan. A
.versions entry stored again with the same pointer during the scan
restarts the grace, so check it on the live entry the CAS is conditioned
on before persisting the repair.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: recheck the live grace before removing an empty .versions
The empty-directory cleanup checked the grace on the pre-scan snapshot,
so a pointer stored again during the scan could still have its
.versions removed. Re-read the entry and leave it while its grace lasts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* ec_balance: keep node addresses out of the task ID
The ID embedded both host:port node addresses, and the admin's task
persistence rejects any ID containing ':', so every ec_balance task
failed to save on each state change and lived only in memory. The
volume, shard, timestamp and index already make the ID unique; the
nodes stay in the task's Reason and params.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* admin: test that a detected ec_balance task saves and loads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* s3: match copy-source ETags as the read and write paths do
validateSourceConditionalHeaders compared the source ETag to the header
value with strings.Trim, so x-amz-copy-source-if-none-match: W/"<etag>"
did not match and an unchanged source was copied instead of answered
with 412. An If-Match list that contained the source's ETag was
rejected for the same reason. RenameObject shares the helper, so
x-amz-rename-source-if-* behaved the same way.
Use util.ETagListMatches, which the GET and PUT paths already use:
strong comparison for If-Match, weak for If-None-Match, and the quoted
tag lists RFC 9110 allows.
* s3: drop the history comment from the copy-source ETag checks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: skip the truncate manifest test on freebsd like its fake filer
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>
* util: refuse to start when fips.mode in security.toml disagrees with GODEBUG
security.toml gains [fips] mode = "off" | "on" | "strict", also settable
as WEED_FIPS_MODE: one setting that states the FIPS 140-3 mode of every
process in a deployment, so the Rust binaries, which do not run on the Go
runtime, can follow it. Go processes keep taking their behaviour from
GODEBUG=fips140 and now check it against the setting:
LoadSecurityConfiguration and `weed worker` exit when "off" runs without
fips140=off, "on" without fips140=on, or "strict" without fips140=only,
naming the setting and the GODEBUG value it needs. An unknown value is
refused; unset or empty changes nothing.
Refs #12839
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rust: fips.mode with FIPS-mode TLS in weed-volume, weed-worker and weed-vector
seaweed-common gains a fips module: FipsMode resolved from fips.mode in
the security.toml a binary uses, with WEED_FIPS_MODE over it. Each binary
resolves it once at startup, logs it and installs the matching rustls
provider as the process default, refusing to start on an unknown value or
when another provider was installed first.
Under "on" and "strict" the provider is aws-lc-rs filtered to the lists
Go's crypto/tls applies in FIPS mode: TLS 1.3 AES-GCM suites and TLS 1.2
ECDHE AES-GCM suites (no ChaCha20-Poly1305), X25519MLKEM768,
SecP256r1MLKEM768, P-256 and P-384 (no plain X25519), Go's ten signature
schemes (no ML-DSA). Configurations SeaweedFS builds require the Extended
Master Secret in that mode, and the volume server refuses a non-FIPS suite
in tls.cipher_suites instead of falling back. sw-client installs the same
provider instead of ring. Unset or "off" keeps aws-lc-rs's default
provider unchanged.
This is behavioural parity only: the provider still runs on the
non-validated aws-lc-rs build.
Refs #12839
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: refuse a fips.mode that is not a string
viper's GetString turns an array or a table into "", so mode = ["strict"]
under [fips] skipped the GODEBUG check while the Rust binaries refused the
same file. RequireFipsMode now reads the raw value (ViperProxy.Get, under
its lock) and exits when it is not a string, naming its source; an absent
or empty value still means unset, and WEED_FIPS_MODE still wins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* rust: read fips.mode with the parser that reads the JWT keys
seaweed_common::fips::resolve parsed security.toml with the toml crate,
while the volume server reads the rest of the file with its own lenient
loader. A file with [fips] mode = "on" beside an unquoted value the loader
accepts resolved to off and logged "fips.mode unset", although the JWT
keys from the same file were applied. Each binary now reads fips.mode
with the loader it uses for everything else and hands the value to
resolve: the volume server through its line parser, the worker and vector
engine through their parsed Security table, which already refuses a file
that is not TOML. A security.toml the volume server finds but cannot read
stops startup. A missing setting is still off, and WEED_FIPS_MODE still
wins. seaweed-common no longer depends on toml.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sw-client: offer only FIPS signature schemes with insecure_skip_verify
With https.client.insecure_skip_verify, reqwest installs its own verifier,
which advertises a fixed scheme list including SHA-1 and Ed448 whatever
the process provider allows. In FIPS mode the volume transport now builds
its rustls configuration itself on the process provider: the server
certificate and host name are not checked, as the setting asks, but
handshake signatures are verified with the provider's algorithms, only its
schemes are offered, and TLS 1.2 requires the Extended Master Secret.
Outside FIPS mode the reqwest path is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* seaweed-common: sign only with Go 1.27's FIPS schemes, allow ML-DSA
The FIPS provider kept aws-lc-rs's key provider, so a FIPS-mode listener
signed handshakes with whatever scheme its key and the peer agreed on,
outside the list the provider verifies with. Keys now load through a
provider that limits each key to the FIPS signature schemes and refuses a
key that can sign none of them, such as Ed448; the volume server and the
worker's gRPC TLS name the certificate and key files in that error.
The lists follow Go 1.27.4, which go.mod now requires: its
defaults_fips140.go allows ML-DSA-44, -65 and -87 as signature schemes and
ML-DSA certificate keys (for Go's native module only), so they are allowed
here as well. Go also allows MLKEM1024 but does not enable it by default,
so it stays out of the key exchange list as in Go's defaults. "off" keeps
the default key provider.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: skip the truncate manifest test on freebsd like its fake filer
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>
sed -i "/# request PartNumber out of range/,+4{s/assert status == 400/assert status == 416/; s/assert error_code == 'InvalidPart'/assert error_code == 'InvalidPartNumber'/}" s3-tests/s3tests/functional/test_s3.py
@@ -175,6 +176,15 @@ cd seaweedfs/weed && make install
`weed` lands in `$GOPATH/bin`. [Getting Started][GettingStarted] covers running master, volume, filer, and S3 as separate processes.
## Development builds ##
Each dev build workflow publishes its latest successful build of `master`:
- **Binaries**: the [`dev` release](https://github.com/seaweedfs/seaweedfs/releases/tag/dev) has Linux amd64, Windows amd64, and macOS amd64/arm64 archives named `weed-<yyyymmdd-HHMM>-<linux|windows|darwin>-<arch>.tar.gz` (`.zip` on Windows) and `weed-large-disk-<yyyymmdd-HHMM>-<linux|windows|darwin>-<arch>`, each with an `.md5` checksum. The Rust volume server is published there too as `weed-volume-*` for Linux amd64 (glibc) and macOS amd64/arm64. The Go archives contain `weed-normal-disk` or `weed-large-disk` (`.exe` on Windows) rather than `weed`, and the Rust archives contain `weed-volume-normal` or `weed-volume-large-disk` rather than `weed-volume`, so rename or symlink the one you want. The `.md5` files are published for the Go archives only.
- **Containers**: `docker pull chrislusf/seaweedfs:dev` or `ghcr.io/chrislusf/seaweedfs:dev`, built for `linux/amd64` and `linux/arm64`. The [dev compose file](docker/seaweedfs-dev-compose.yml) runs the Docker Hub image as master, volume, filer, S3, WebDAV, and admin.
The timestamp in a binary name is the UTC start time of the run that built it. The Go binaries, the Rust volume server, and the `:dev` image come from three separate path-filtered workflows, so they can carry different timestamps and lag `master` by hours, or much longer when their paths were not touched. The release can list more than one timestamp for a while, for example after a failed or retried run; use the newest one for your platform. The `dev` release is marked pre-release, so it does not appear under [releases/latest](https://github.com/seaweedfs/seaweedfs/releases/latest); these builds come from `master`, can break at any commit, and are not recommended for production.
## Scale out ##
Capacity is a volume server. Start one on any machine with disk and point it at the master:
The compose file below uses `chrislusf/seaweedfs:dev`, built from `master`. It is a development image, not a stable release, and can lag `master` by hours or more; the `org.opencontainers.image.revision` label records the commit it was built from, and pinning by digest keeps that exact build. See [Development builds](../README.md#development-builds) for the `dev` binaries and image details.
"description":"Failed EC shard copies into each volume server per rate interval, by collection and reason (source_not_found, empty_index, no_space, timeout, io_error, other). The volume server log names the volume, shards and source of each failure.",
"type":"timeseries",
"id":269,
"gridPos":{
"h":8,
"w":12,
"x":12,
"y":142
},
"fieldConfig":{
"defaults":{
"color":{
"mode":"palette-classic"
},
"custom":{
"axisBorderShow":false,
"axisCenteredZero":false,
"axisColorMode":"text",
"axisLabel":"",
"axisPlacement":"auto",
"barAlignment":0,
"drawStyle":"line",
"fillOpacity":10,
"gradientMode":"none",
"hideFrom":{
"legend":false,
"tooltip":false,
"viz":false
},
"insertNulls":false,
"lineInterpolation":"linear",
"lineWidth":1,
"pointSize":4,
"scaleDistribution":{
"type":"linear"
},
"showPoints":"never",
"spanNulls":false,
"stacking":{
"group":"A",
"mode":"none"
},
"thresholdsStyle":{
"mode":"off"
}
},
"mappings":[],
"unit":"short",
"thresholds":{
"mode":"absolute",
"steps":[
{
"color":"green",
"value":null
}
]
}
},
"overrides":[]
},
"options":{
"legend":{
"calcs":[
"lastNotNull",
"max"
],
"displayMode":"table",
"placement":"bottom",
"showLegend":true
},
"tooltip":{
"mode":"multi",
"sort":"desc"
}
},
"targets":[
{
"datasource":{
"type":"prometheus",
"uid":"${DS_PROMETHEUS}"
},
"editorMode":"code",
"expr":"sum by (instance, collection, reason) ((last_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[$__rate_interval]) and (min_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[$__rate_interval]) < last_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[1d] offset $__rate_interval))) or (increase(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[$__rate_interval]) and count_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[1d] offset $__rate_interval)) or (last_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[$__rate_interval]) unless count_over_time(SeaweedFS_volumeServer_ec_shard_copy_failures_total{cluster=~\"$cluster\"}[1d] offset $__rate_interval)))",
runners=append(runners,fmt.Sprintf("legacy maintenance %s task (turn off with enabled = false under [maintenance] in admin.toml)",work.legacyTaskType))
},[]MaintenanceOverlap{{Work:"EC encoding",Runners:[]string{"plugin erasure_coding job","legacy maintenance erasure_coding task (turn off with enabled = false under [maintenance] in admin.toml)"}}}},
Loaded 100 of 676 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.