mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
cd0f60a2f0858c07ea202b00ebf8df19e65a10a2
1827
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
7c41ed0635 |
kms: swap a reload's providers in as a whole, after S3 parses its identities (#13344)
* kms: build every provider before a reload swaps them in A reload replaced the providers one at a time, closing each old instance as its replacement went in, and kept the providers and bucket mappings the config no longer listed. Between closing the old default instance and setting the new global provider, S3 could get the closed instance. A reload now builds every provider first and swaps the whole set in at once, along with the default, the bucket mappings and the global provider. The default provider failing still fails the reload, and then nothing changes. Any other provider that fails keeps its previous instance. Providers the config no longer lists are dropped, and a bucket mapped to one falls back to the default. A manager other than the global one no longer sets the global provider. The manager no longer keeps the provider configurations, which nothing read. Each load health-checks every provider once, after the swap, for filer.toml as for the identities file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: parse the identities before loading KMS Loading the S3 config loaded KMS before parsing the identities, so a file whose identities didn't parse still replaced the KMS providers. A file without a kms block left the previous providers in place, and one with a number out of float64 range, which protojson accepts, skipped KMS without an error. The identities are now parsed first, and a file that fails there changes neither. A file without a kms block drops the providers, so a reload that took the block out turns SSE-KMS off. A file encoding/json can't read fails the KMS load with an error that doesn't quote it, as it could quote key material. A KMS load that fails is logged as an error, not a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: skip a bucket mapping with an empty bucket name SetBucketKMSProvider refused an empty bucket name, which the rebuilt mappings no longer went through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: check a rejected load leaves the installed provider open 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> |
||
|
|
a7c1cc32ec |
s3api: fail closed when the directory marker lock check cannot read the marker (#13326)
* s3api: refuse a directory marker PUT when the existing marker cannot be read Only a missing marker skips the Object Lock check. Any other lookup error now fails the request instead of letting mkdir replace a marker that may be under retention or legal hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: create the Extended map before applying upload ACL metadata A directory extracted from a zip without an owner header reached applyPutObjectACL with a nil Extended map and panicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse extracting over a marker that cannot be read The zip extract mkdir path had the same fail-open lookup as the directory marker PUT; a failed read now reports InternalError for the member. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d6d5e99f9b |
s3api: limit service account keys to their stored actions (#13325)
* s3api: limit service account keys to their stored actions A service account created with an action subset authenticated as its parent and was authorized with the parent's full permissions. Map each restricted service account key to a copy of the parent that carries the subset as a boundary, and check it in the S3, bucket listing and IAM authorization paths. An empty action list still inherits the parent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: drop restricted service account keys with their removed parent RemoveIdentity only dropped keys that mapped to the parent itself, so a restricted service account key, which maps to its own bounded copy, kept authenticating after the parent was deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sts: keep restricted service account keys out of their parent's roles A named role is admitted by its trust policy alone, so a service account key limited to Read could assume any role trusting its parent and use the role's permissions. Require the key's action subset to allow sts:AssumeRole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: let a service account's scoped upload listing grant pass its boundary The upload and part listing routes are authorized as Read, and the legacy path falls back to the listing grant. The boundary check now does the same, so a service account limited to ListBucketMultipartUploads can still list uploads without being allowed object reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sts: refuse self sessions for restricted service account keys AssumeRole without a RoleArn and GetFederationToken issue sessions that carry the caller's own policies, which for a service account are its parent's. A restricted key would shed its action subset that way, so refuse both for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sts: give the restricted service account role test its own role Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: check a restricted key's parent grants apart from its boundary The boundary is checked against the request first, so the legacy action check only has to cover the parent's grants. Checking the boundary there again without the request denied a Read parent's upload listing to a key limited to ListBucketMultipartUploads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
515b905011 |
s3notification: lose the test lock on the fetch of the records' partition (#13324)
TestALeadThatLostItsLockDoesNotSend dropped the forwarder lock on the first fetch of any partition, then waited for a fetch of partition 0. When another partition's goroutine fetched first, the lead stopped before partition 0 was fetched and the wait timed out (seen on the 32-bit job). The hook now gets the request and drops the lock on partition 0's fetch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2f300c2969 |
s3api: keep the in-flight upload counters 64-bit aligned on 32-bit (#13321)
The recursiveListDeclined sync.Map placed ahead of inFlightDataSize and inFlightUploads moved them off 8-byte alignment on 386, so the first throttled upload panicked with "unaligned 64-bit atomic operation". atomic.Int64 is aligned wherever it sits in the struct. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
add9d60378 |
s3api: list a versioned key whose .versions folder streams past the page (#13317)
* s3api: list a versioned key whose .versions folder streams past the page A key's .versions folder sorts after the longer keys it prefixes: "a.pom.versions" follows "a.pom.sha1.versions" although the key "a.pom" sorts before "a.pom.sha1". A ListObjects page that filled in between returned the longer key and resumed past the folder name, so the shorter key was never listed. When a versioned page is truncated, look up the .versions folder of each proper prefix of the page's last item that would still stream after it, add the live keys found, drop as many items off the end, and resume from the last key kept instead of a .versions folder name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: test versioned listing pages that end between a key and its .versions folder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: test encoded versioned listing pages with spaces and plus signs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep recovered versioned keys in raw key order Encoded keys do not sort like raw ones ("a%20b-1/x" before "a+b"), so a key recovered past the page boundary is placed by its raw key before the page is trimmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: order a versioned page by raw key when listing with encoding-type=url The in-page insert compared encoded keys, which sort differently from raw ones once a directory and a file name escape a space differently. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: test encoded directory keys at a versioned page boundary Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: scan raw keys when retracting a delete-marked null object The page is now ordered by raw key, so the backward scan that finds the null object to retract stops on raw keys too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8a6c948b12 |
s3api: delete a null delete marker named by versionId=null (#13311)
* s3api: split the .versions file delete out of deleteSpecificObjectVersion deleteVersionFile deletes a version stored under .versions and repoints the latest pointer past it. deleteSpecificObjectVersion keeps "null" as the plain object entry, which the suspended delete and lifecycle paths rely on, and calls deleteVersionFile for every other version id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: delete a null delete marker named by versionId=null A suspended-versioning delete stores its marker as .versions/v_null, but DELETE ?versionId=null only looked at the plain object entry. With no null object there, it answered 204 without x-amz-delete-marker and left the marker in place, so the bucket could never be emptied. When the plain null object is missing and a null marker exists, delete the marker file and repoint the latest pointer to the prior version. The routed specific-version delete leaves that case to the lock path, which already handles batch deletes the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: order the repoint past a deleted null delete marker by the versions left A null delete marker's id has no format, so the routed version delete read the recompute order from the first remaining version file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: delete a null delete marker on the key's owner The marker is read from the owner, so deleting it through the gateway's own filer could answer success while the owner kept it. Both the routed DELETE and the lock path delete it with a routed transaction instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: rank the versions left by time when deleting a null delete marker Mixed legacy and inverted ids made the first file name a wrong guide to the repoint order. The routed delete now finds the newest remaining version and picks the name order that reaches it; when neither end of the order is the newest, it leaves the delete to the lock path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep only the ends and the newest while scanning for the null marker repoint Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: choose the null marker repoint from the owner's own listing A filer other than the key's owner can lag it, and the recompute runs over the owner's full directory, so a direction picked from a replica's partial listing could repoint the object to an older version. Scan .versions on the owner only; when the owner cannot answer, leave the delete to the lock path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3764534dd1 |
kms: read filer.toml and the identities file with one parser (#13313)
* kms: read filer.toml and the identities file with one parser The KMS settings from filer.toml and from the identities file went through two paths: the JSON one was wrapped in an adapter so it could be read like viper. Both are now parsed into the same settings and loaded by the same code. Viper lowercases the provider tables in filer.toml but not the values that name a provider, so a mixed-case default_provider or bucket provider never matched and failed the load. Those values are now lowercased for filer.toml. Providers load in name order, a providers or buckets section that isn't a table fails the load instead of being ignored, and so does a default_provider that isn't a string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: test the parser's section types and JSON provider names A providers or buckets section that isn't a table and a default_provider that isn't a string fail the parse, and a JSON config keeps the case of the provider names it uses. The check-once test now loads through the whole loader, which sets the global provider, so it clears it after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: pick the first provider by name when no default is set ListKMSProviders iterated the provider map, so with several providers and no default_provider the global SSE-KMS provider changed between loads, and objects written under one could not be read after a restart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: report KMS load errors from the identities file Any failure loading the identities file's kms block was logged at V(2) as no KMS configuration, which hid the parser's errors and a default_provider that does not exist. Only a missing block is quiet now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
f599f870a8 |
s3: list without a delimiter from one range of the filer store (#13263)
* s3: -s3.listRecursiveFromStore, on by default Lets an operator keep recursive listings on the directory walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3: list without a delimiter from one range of the filer store A bucket that never had versioning is listed with ListEntriesRecursive: one read of the bucket's path range per page instead of one directory listing per directory. A folder object's "<dir>/" key waits for its place in key order, and the folder objects whose rows sort before the range (the one the prefix names, those the marker ends inside of) are looked up. .uploads is skipped; a .versions folder hands the page to the walk, as does a filer that answers Unimplemented, which is then not asked again for a minute. The test pages through both ways over the same tree, for prefixes, markers and page sizes, and expects the same keys, sizes, ETags and markers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/postgres_flat: a range-read gateway lists what the walking one does A second S3 gateway with -listRecursiveFromStore=false runs on the same filer. ListObjectsV2 and V1 pages agree for prefixes, markers and page sizes over folder objects, a prefix object, an unfinished upload and +/-/0 neighbours. Listing 60 keys five directories deep scans the bucket table 2 times from the range read and 302 times from the walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3: range-read listings without the -s3.listRecursiveFromStore flag A filer whose store cannot list a range answers Unimplemented and the gateway already walks that bucket's directories instead, so the flag only switched off a path that falls back by itself. The unit test forces the walk through the decline cache, and the postgres_flat test checks pages against the keys in byte order rather than against a second gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: step a range-read listing over the bucket's upload parts The walk skips the bucket's .uploads folder as one entry, but a range read from the bucket root streamed every part of every unfinished upload and dropped them, one 1024-row window after another, on each first page. Every path under .uploads/ sorts before ".uploads0", so the read resumes there and looks up the one key with that name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: list a waiting folder object once a row passes its key A range-read page queued every childless folder object until a file row arrived, so max-keys=1 over a bucket of empty folders read the whole bucket before answering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: forget a deleted bucket's recursive-listing decline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
77a070fe0a |
s3api: tell a symlink apart from an empty object on GET and HEAD (#13299)
A symlink made through weed mount holds no data, so GET and HEAD answered for it as for an empty file: Content-Length 0 and a type guessed from its name. An S3 client could not tell it from an empty file, nor see where it pointed. For an entry with the symlink mode bit, send the target as user metadata, x-amz-meta-seaweedfs-symlink-target, escaped like a key under encoding-type=url, and use Content-Type inode/symlink (what file(1) reports) when none is stored. User metadata is the one place AWS has for an object's own fields, so SDKs and the AWS CLI show it as they are. The link is not followed: the target is a path on the client that made it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a9d4714aed |
s3api, filer: keep a symlink a symlink when CopyObject copies it (#13298)
* s3api, filer: keep a symlink a symlink when CopyObject copies it A symlink made through weed mount is an entry with the symlink mode bit, a SymlinkTarget and no data. CopyObject builds the destination's attributes afresh, with the permission bits from the request, so a copy to another key dropped both and landed as an empty regular file. A metadata-only self-copy (REPLACE) kept the target but reset the mode, leaving the link an empty regular file in place. Keep the symlink mode bit and the target on both paths. The permission bits still come from the request, as for any other copy. The filer's own copy (copyEntry) already carries the source's whole attribute set. A copy into a new prefix creates the symlink in a missing directory, and the filer gave each parent it created the entry's whole mode plus ModeDir. With the symlink bit as well, a mount shows those directories as regular files, and nothing under them can be reached. Parents now take the entry's permission bits only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: drop the symlink type when promoting an entry to a directory A key nested under a symlink promotes the symlink's entry to a directory. The promotion added ModeDir and kept the symlink bit, so a mount showed the directory as a regular file and could not reach the nested key. Keep only the permission bits there too, with the same restorableModeBits a missing parent now takes from its entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep a self-copied prefix object a directory when it was a symlink A prefix object promoted from a symlink before the filer change still has the symlink bit. A routed self-copy of it restored ModeDir and then keepSymlink added the symlink bit back, leaving a directory a mount shows as a regular file. keepSymlink now leaves directory destinations alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: a prefix object keeps no type bit but the directory's MarkPrefixObject added ModeDir and the execute bits to whatever mode the object had. A symlink copied onto a key that other keys are nested under, or a self-copy outside the owner route of a prefix object promoted from a symlink before the filer change, kept the symlink bit next to ModeDir, which a mount shows as a regular file. Clear the other type bits first. 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> |
||
|
|
85b783cc0d |
s3api: copy a chunk to another volume when its volume fails the write (#13297)
* s3api: copy a chunk to another volume when its volume fails the write CopyObject and UploadPartCopy assigned one volume to each copied chunk and failed the whole copy when that volume failed the write: a streamed copy sent a single POST, and a buffered copy retried only the same fid. PutObject asks for a fresh assignment instead (upload_chunked.go), so a volume that filled up, went away or was overloaded failed a copy that a PUT would have survived. In production, a CopyObject failed with 500 because the destination volume server broke the connection mid-upload, and only the client's retry completed it. Every chunk copy now writes through uploadCopiedChunk: streamed, buffered, range, and the five SSE re-encryption paths. When a volume fails the write in a way another volume would not, the copy deletes whatever the failed write may have stored, asks for another volume and writes the chunk again, as PutObject does: up to three volumes, and only one more after an overload. The uploader's errors are judged by operation.ShouldReassignUpload, and a streamed POST by its status (no response, a 5xx, or an overload refusal). A streamed retry reads the source again, and a range copy digests only the bytes of the attempt that landed. A failed source read is not retried on another volume: a streamed copy now records the source's read error apart from the POST's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: delete a failed copy chunk only when its write reached the volume A streamed copy reads its source inside the write, so a source that could not be read also came back through uploadCopiedChunk, which then deleted a fid nothing had been written to. Only a failure of the volume itself (copyUploadError) is followed by the delete now; the tests check that a source failure sends none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: reassign copy writes refused before the append, bound the cleanup A streamed copy's POST dropped the volume's X-Seaweed-Write-Outcome header, so a 409 from a volume that turned read-only before the append, or a 401 for a token that expired in the queue, failed the copy where the uploader's ShouldReassignUpload tries another volume. The POST now keeps the header and reassigns on the same marked answers; unmarked 409 and 401 stay final. The delete of a failed chunk read its answer with no deadline, so a volume that sent the headers and stalled the body held the copy up for good. Each delete now runs within copyCleanupTimeout (10s), its answer included, and still logs the status and up to 4 KiB of the body. Tests: the fake volume keeps the file it was sent, and each retry case checks that the second volume stored the copied bytes. An SSE-C chunk copied under a new key decrypts with the key and IV its chunk names. Marked 409 and 401 answers reassign, unmarked ones do not, and a stalled cleanup delays the copy by the timeout only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: renew an expired token for a failed copy chunk's delete A copy's write token is minted at the assignment, before the source is read, and lasts 10s by default. A write that failed after that left the cleanup delete refused with 401 and the needle orphaned. PutObject's cleanup renews the token from the master on a 401; do the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: log the status and body of a cleanup delete whose read failed A delete whose answer began but whose body read failed, such as one cut off by copyCleanupTimeout, was logged with the error only. Log its status and the part of the body that arrived as well. 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> |
||
|
|
4cb096e32f |
filer, s3: report a failed read as an error, not as a missing entry (#13289)
* filer/mongodb: report a failed read as an error, not as a missing entry FindEntry logged any read error other than ErrNoDocuments and returned filer_pb.ErrNotFound, so a lookup that could not reach MongoDB answered that an existing entry was gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/arangodb: report a failed read as an error, not as a missing entry FindEntry logged any ReadDocument error other than not-found and returned filer_pb.ErrNotFound, so a lookup that could not reach ArangoDB answered that an existing entry was gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/rocksdb: report a failed read as an error, not as a missing entry FindEntry and KvGet checked for a missing value before the read error, and the value is nil after any failed read, so every read error came back as not found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: a versioned read whose lookup fails is not NoSuchKey In a versioned bucket, GetObject, HeadObject and GetObjectAttributes answered NoSuchKey for any error from getLatestObjectVersion, so a filer or store outage told clients that existing objects were gone. They now classify the error the way CopyObject's source lookup does: NoSuchKey only when the object is missing, 503 for transient failures and 500 otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep the cause when the latest version file cannot be read doGetLatestObjectVersion formatted a failed read of the version file the pointer names with %v, so a transient failure there answered 500 instead of 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1f65d9e708 |
s3api: answer GetBucketLocation with a LocationConstraint document (#13292)
GetBucketLocation wrote the CreateBucket request body (CreateBucketConfiguration), so clients that check the root element, such as the AWS Rust SDK, failed with "expected LocationConstraint tag". Reply with an empty LocationConstraint in the S3 namespace, which is what AWS sends for us-east-1 buckets. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b1f86ddfa2 |
s3: support PutBucketDefaultStorageClass and GetBucketDefaultStorageClass (#13282)
* s3: add PutBucketDefaultStorageClass and GetBucketDefaultStorageClass The setting is kept in the bucket entry's extended attributes next to the other bucket configuration, so every gateway sees it through the bucket config cache. Only STANDARD and INTELLIGENT_TIERING are accepted, matching the AWS model; STANDARD clears the stored value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: give new objects the bucket default storage class PutObject, POST uploads, CreateMultipartUpload and CopyObject store the bucket default when the request names no storage class. The request headers are left alone, so bucket-policy storage-class conditions and the self-copy change check still see only what the client sent. Upload parts are not tagged; a completed upload takes the class recorded when it was initiated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: test the bucket default storage class APIs and write default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: fail a write whose bucket default storage class cannot be read A failed bucket config lookup used to fall back to STANDARD, so a write could store a different class than the bucket default asks for. The write now returns the lookup error instead. A request that names its own class still needs no lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: give extracted ZIP directory members the bucket default storage class Directory members are created through mkdir rather than putToFiler, so they stored no class while the files next to them did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: reject a default storage class body with trailing data The decoder stopped after the first element, so a valid configuration followed by another element or stray bytes was accepted. The body is now read with a size bound and only whitespace, comments or processing instructions may follow the configuration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * go.mod: bump aws-sdk-go-v2/service/s3 to v1.117.1 The release adds the PutBucketDefaultStorageClass and GetBucketDefaultStorageClass client operations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: test the bucket default storage class through the AWS SDK Covers get/set, an unsupported class, the setting stored in the bucket entry and read back by a fresh bucket config, PUT, explicit classes, multipart initiation, copy, existing objects, and per-API grants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let each default storage class subtest set up its own state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: assert the explicit STANDARD class exactly in the default class test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: note that the bucket default storage class is a label only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2574cedfd3 |
s3: publish a recovered PUT's event at its commit stamp (#13265)
* s3: publish a recovered PUT's event at the stored entry's commit stamp A PUT whose create committed but lost its answer, and that recovery then found stored, published its event at the gateway's clock. A later write to the same key that carries its filer stamp could then sort before it. Both recovery paths now take the stamp the committing filer gave the stored entry, as recovered multipart completions do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: return the context error when it ends a topic configure A start whose context ended during ConfigureTopic on the last broker answered with the RPC's text, so errors.Is(err, context.Canceled) did not hold for it as it does for a context that ends before an attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: name the broker whose topic configure failed doConfigureTopic built lastErr with the broker address but returned the bare RPC error, so a failed configure did not say which broker refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2b157f2ef1 |
test: clear the codespell hits left after #13290 (#13264)
* test: use a codespell-clean non-ASCII key in TestEncodeKey Codespell reads caf%C3%A9 as the misspelling caf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topictable: reword want's in the CheckSchema comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
081218bf8a | test: reword misspelled fixtures that trip codespell (#13290) | ||
|
|
9f9c28471f |
s3api: free the parts a multipart completion does not name (#13248)
* s3api: free the parts a multipart completion does not name prepareMultipartCompletionState skipped every entry of the upload directory whose part number the request does not name: it was neither a part of the object nor one of the unused entries freed with their data. The completion then removes the upload directory metadata-only, since the object's chunks are its parts' chunks, so the skipped parts' chunks stayed on the volume servers with nothing referencing them until a volume.fsck purge. Once the upload is completed they cannot be listed, completed or aborted any more. The completion now keeps those entries aside and, once its object is committed and the upload directory is gone, deletes their chunks by file id, resolving manifest chunks first. They are not freed before the commit, as the unused attempts are on the routed paths: until a completion succeeds the upload stays open with all its parts, and the commit transaction can still refuse the write. When another completion of the upload owns the commit (metadataOnlyCleanup), its object can hold them, and they are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: give the unrequested-part cleanup one deadline and check the committed object first The client waits for the completion it already committed, so the cleanup of the parts the request did not name gets one deadline, unrequestedPartsCleanupTimeout, instead of a lookup timeout for each part with manifests: the chunks of the parts without manifests are deleted first, then manifests are resolved part by part while time is left. deleteOrphanedChunksWithContext passes the deadline to the volume lookups and deletes; deleteOrphanedChunks keeps its behaviour. A completion without a ring owner commits under the object lock without the upload-directory precondition, so a routed completion of the same upload can commit after it with a list that names those parts, and remove the directory. The cleanup now frees them only when the key's current object is this completion's commit (this upload, the same chunks), checked once the directory is gone, when no routed completion can commit any more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: deleteOrphanedChunks takes the context its lookups and deletes use Fold deleteOrphanedChunksWithContext into deleteOrphanedChunks instead of keeping a second name; the existing callers pass context.Background(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: check the entry the completion wrote, under the cleanup deadline The check before freeing the unrequested parts resolved the object by its key, outside the cleanup deadline. A key ending in "/" is written inside the directory it names ("dir/" at dir/dir), so the check read another entry and kept the parts, and a filer that stopped answering after the commit could hold the completion without a limit. The completion now records where it writes its object (the version file on a versioned bucket), and the cleanup reads that entry back, from the write owner when there is one, under the same deadline as the deletes. Each part whose manifests resolve is deleted before the next manifest is read, so a read that runs out the deadline no longer strands the parts resolved before it. The cleanup's filer reads, that check and deleteOrphanedChunks' volume lookup, go through withFilerClient with the deadline, so the deadline running out is not booked as a failure of the filer and does not open its circuit for other requests. 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> |
||
|
|
51d2b2b712 |
mq: read a table-backed topic's history from its Iceberg table (#13260)
* mq: read a topic table's data files back as log entries A view of a topic's table holds the current snapshot's offset map and, per _partition, its data files with the _offset and _ts_ns bounds from the manifests. A partition's rows are read by offset or by time, skipping files and then row groups whose bounds miss the read, and come back as the log entries they were copied from: key, timestamp, offset, and the message as _value or as the record re-encoded from its columns. Views are cached per topic, rechecked every few seconds, rebuilt only when the metadata location moves, reuse already-parsed manifests, and are evicted past a bound on the data files they hold. A table that is gone or replaced by another UUID reads as empty; one with delete files is refused. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a table-backed partition below its table's high-water mark from the table The merged reader takes the partition's table, looked up on every read so a table attached later is seen. An offset read below the mark reads the table up to the mark and continues into the log files and compacted parquet from the mark; a time read takes the table's rows after the time and then the files' entries at or above the mark. Log files left below the mark by a crash between the writer's commit and its delete are never read. The broker hands its partitions' disk reads to the table through the topic's cached view; a topic without a table, or whose topic.conf is gone, reads its files as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: start a table-backed partition's offsets at its table A partition whose log files below the table's high-water mark were deleted would reload with a high-water mark and log start taken from the files that are left. Loading it now continues its offsets no lower than the table's mark and starts its log at the table's lowest offset, or, when the table holds nothing of it, at the first file offset at or above the mark. A retired range of a repartitioned topic is read and bounded the same way, and a retention purge raises the log start likewise, so purging hot log files never makes the table's offsets out of range. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: keep a flushed data source's finished flag atomic The streaming goroutine sets finished while the merge loop reads it through HasMore, which the race detector reports on any scan that reads flushed data. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: scan a table-backed topic's history from its table The hybrid scanner hands each partition's merged read the topic's table, so a scan reads the table's data files below the partition's high-water mark, pruned by _partition, _offset and _ts_ns, and log files from the mark on, skipping any a crash left below it. Aggregations no longer answer such a topic from parquet statistics and log counts, which hold none of its table's rows; they scan instead. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a schematized row's raw _value back as its message A schematized topic's table can keep a message that is not a record, a tombstone or an undecodable value, as raw bytes in an optional _value with the record columns null. Such a row now reads back as those bytes; a row whose _value is null reads back as its record, and a schemaless topic's row as its _value as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: delete log files a topic table already holds A log file or compacted parquet whose every offset is below a partition's table high-water mark is never read again, so it can go. The mark used is that of the newest snapshot at least a minute old: a reader's view of the table is at most a few seconds old, so it already reads those offsets from the table and never from a file being deleted. Files without an offset range and the file holding the partition's highest offset are always kept. DeleteCoveredLogFiles is for the topic's writer after its commit; a leader also deletes them under its fence on load and on each retention pass, covering a writer that crashed between its commit and its delete. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: report a topic table's rows as parquet_archive A table-backed topic's scan labelled every row live_log, its table's included. The flushed data source now records the high-water mark of the table its merged read was handed and reports the rows below it, which come only from the table's parquet data files, as parquet_archive. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete the log files a topic table holds after each run Every mq_topic_table run now ends by deleting, in each partition, the log files wholly below the offsets of the newest snapshot at least LogDeleteGrace old, never the leader's newest file. A commit is never old enough on the run that makes it, so each run deletes what earlier ones copied; the partition's leader deletes the same files when no run follows. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a time read's position when nothing on disk follows it A time read that found nothing after its position returned a position at time zero: the parquet reader reports the newest time it delivered, which is none. A loop over an empty memory buffer then read the whole partition from the start, came back to the same empty read, and started over, so a query asking a broker for its unflushed messages streamed the partition forever. The merged and the table-tiered readers now keep the position when they deliver nothing past it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: publish a topic table view under the lock eviction reads it with A loaded view was stored under its entry's loading lock while eviction, run by another topic's load, read every entry's view under the cache's lock, so two topics refreshing at once raced. A view is now stored holding both locks: a load reads it under the first, eviction under the second. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep no topic table view larger than the whole view cache Eviction never dropped the view just loaded, so one topic whose table had more data files than the cache's bound stayed cached past it, and evicted every other topic's view on the way. Such a view is now answered and not kept; the others stay. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: look up a topic table's mark again where a read leaves the table A read kept the table mark it started with. One slow over the table's rows could outlast the grace: the writer commits past that mark, the logs below the new mark are deleted, and the read then lists the logs from its old mark and passes over the deleted offsets without a word. The read now asks for the table again each time it leaves it and reads on in the table up to the mark it finds, until the mark stops moving; a time read takes the rows between the marks by offset. A gap where the logs begin is checked against the table once more, and read from the table if it took it meanwhile. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's timestamps back without going through nanoseconds A timestamp or time column was turned into micros by way of nanoseconds, which overflow for dates before 1678 or after 2261, so a year 1 or year 9999 value came back as another date. Each unit now converts to micros directly. The table fixture wrote every topic's rows whole into _value once every table had that column, so the record columns these reads take went untested; it now writes a schematized topic's rows as columns. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: order a compaction bin by the first sort field that varies in it A topic table sorts by _partition, then _offset, and is partitioned by _partition, so every file of a bin holds one _partition. Ordering the bin by it kept the files in manifest order, and a merged file's offsets came out of order for the topic table reader, which delivers a data file's rows as offsets in order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: list a retired range from its table's lowest offset A topic lookup lists each retired range with the bounds of its own files, so once the table held a range's history and its log files went, the range was listed from its newest file on, while its reader serves the table's offsets below it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: never merge compaction inputs across a file left out of the merge A file already at the target size takes no part in compaction, yet small files on both sides of it in sort order went into one bin, so the merged file's bounds spanned it. For a topic table that is a data file whose _offset range overlaps another's, which a reader finishing one file before the next cannot read in order. An ordered bin is now cut wherever a file left out of the merge falls between two of its files, so every merged file covers a range no file outside its run lies in. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: merge a topic table's overlapping data files by offset when reading A partition's data files were read one after another by their lowest offset, which only reads in offset order while no two ranges overlap. A rewrite by another engine can leave a file spanning another one, and then a read from inside the overlap delivered the spanning file's later rows first, and a read that stopped early left the rows in between behind. Files whose offset ranges overlap are now read together, their rows merged by offset and an offset held twice delivered once. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: open a topic table's data files only as a read reaches them A merged read opened every file of an overlapping group before it delivered a row, and a file the manifest records no offset bounds for overlaps every other one, so a short fetch held a reader for each file of the partition's history. The files of a read now wait in a heap keyed by the lowest offset each can hold, and a file is opened only once nothing before that offset is left to deliver; a file without bounds is opened where the read starts, and its row groups' statistics skip what they rule out. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: retire no log file a topic's table does not hold yet Retention deleted a table-backed topic's log files by age alone, so with the table writer behind it deleted messages the table did not hold, and they were gone from both. On such a topic a file now expires only once all it holds is below the table's mark of a grace-old snapshot, the same files the leader deletes as covered; what the table holds ages out with table retention. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a table-backed range's bounds by its caller's deadline The table lookup that widens a partition's bounds ran under a background context, so a retention pass or a retired-range lookup with a deadline waited on a stalled table catalog for as long as it stalled. It now runs under the caller's context. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table's mark again when a time read reaches its files A time read caught up with the table and then read the files above the mark it last saw. A view that had moved on meanwhile, with the logs below its new mark deleted before the files were listed, left the offsets between the two marks to neither. The time read now asks for the table again at the first file entry it would deliver, or after the files if they held none, and on a moved mark reads the table up to it before reading the files again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: bound the topic table views kept, empty ones included, and keep those in use Eviction only counted data files, so views of tables holding none, and entries a failed first load left behind, were never dropped; and it could drop an entry while a caller was loading it, so the next caller loaded the same table again alongside. A failed first load now leaves no entry, at most maxCachedTopics views are kept, and an entry a caller still holds is never evicted. The eviction test now requires exactly the one eviction that makes room. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table afresh before deleting the logs below its mark A leader's covered-log delete and log retention took the table's mark from the cached view, up to a few seconds old, so a table rolled back to a lower mark meanwhile had its logs above that mark deleted although it no longer held them. Both now check the table before acting: the cache takes a maximum age, a read passes ViewRefresh and a delete zero. A cached view is also reused only for the same table state, since a commit that rewrote the metadata in place keeps its location. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: leave a sort field holding nulls to order a compaction bin A sort field whose bounds are one value in every file was taken as constant and the bin ordered by the next field, yet bounds leave nulls and NaNs out, so a column holding them besides its one value is not constant. A field is now skipped only when the files also record no null in it, and no NaN for a floating point one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete a topic's covered logs only while it still names the table A run's log cleanup used the table metadata the run started with, so after the topic left the table, or the run lost its lock, it still deleted the logs below that table's marks. The cleanup now checks, when it runs, that it still holds the topic's lock and that topic.conf still names the table with its recorded UUID, and reads the marks from the table as it is then. It still runs after a run that failed otherwise. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each covered log it deletes The leader read the table's mark once, listed the files below it, then deleted them one by one, so a rollback or a detach landing in between went unseen and files the table no longer held were deleted. The delete now holds the table writer's lock, so the topic cannot leave the table meanwhile, and before each file reads topic.conf and the table afresh, stopping at the first file not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: let a caller waiting on a topic table's load give up at its deadline A caller wanting the view a stalled load of the same table was making waited on a mutex, past its own deadline, for as long as the load stalled. The entry is now held by a one-token channel a waiter selects on with its context, so it returns at its deadline and lets go of the entry. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: give up a scan's table lookup when the query is cancelled The table a scan reads below each partition's mark was looked up under a background context, and the flushed data source waited on its channels alone, so a cancelled query stayed blocked on a stalled table catalog. The scan's context now reaches the topic.conf read and the table lookup, and the data source returns once it is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: take a topic table's lock only when a covered log is left to delete The leader's covered-log pass took the table writer's lock for every table-backed partition it leads once the table had a mark, every five minutes, even with nothing to delete. While a copy run held the lock, each such partition waited out the lock wait and logged a failure, holding up the rest of the retention tick. List the covered files first and take the lock only when there are some; the per-file checks under the lock stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: drop a topic table view only with the last caller holding it An oversized view was removed while other callers still held it, so the next caller loaded it again alongside; an entry no load filled was removed only by a failing load that was its sole holder, so one whose callers failed or gave up in another order stayed; and eviction that found every candidate held left the cache above its bounds with nothing to evict again. Callers now let go through one release: the last one removes an entry no load filled or one marked to drop, as an oversized view is, and each release runs eviction again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: check a topic's table again before each covered log the cleanup deletes The cleanup checked the lock, topic.conf and the table once, then deleted every file below the marks it read, so a detach, a dropped or replaced table, or a lapsed lease landing during the deletes went unseen. The deletes now check all three again before each file, with the mark of the table as it is then, and stop at the first file not below it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: let a flushed data source's producer close its own channels Next can return on the query's cancellation while the producer is still sending, and the merge then closes the source, which closed the result and error channels under that send. The producer now owns them: Close only signals it to stop, every send also selects on that signal, and the producer closes the result channel when it exits, after sending its one error if it has one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: fail a scan whose data source fails after its first row The merge only logged an error from a source past its first row, the query's cancellation included, and returned the rows read so far, so a cancelled or timed-out COUNT or SUM answered with a wrong number. It now closes its sources and returns the error, and the scan wraps it, so a caller can tell the context's error from others. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each group retention deletes Retention read a table-backed partition's deletable mark once, chose its expired groups, then deleted them with no further look, as the covered-log delete did before it rechecked; a rollback in between left groups deleted that the table no longer held. The live and retired purges and the covered-log delete now share one guard: it holds the table writer's lock and, before each group or file, reads topic.conf and the table afresh, stopping at the first one not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a partition load's reads of what it already stores Loading a partition reads its files' offset range and, for a table-backed topic, the table's, while holding accessLock, under a background context, so a stalled filer or table catalog held every other partition operation for as long as it stalled. The reads now get the bound a load's fence take has; past it the load fails, as it does when the stored offsets cannot be read, and the caller retries. Falling back to the log files' bounds would start the log above the table's offsets with no later refresh to lower it, so consumers resetting to the earliest offset would skip the table's history. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: count a flushed source's pending error as more to read The merge asks HasMore before reading a source again, and HasMore looked only at buffered rows and whether the producer finished, so a producer that failed after its last row and finished before the merge asked had its error never read, and the scan returned the rows so far as its answer. An error waiting counts as more to read now, so Next returns it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the table's files of a topic that left it before the delete A topic that left its table between the listing of what the table held and the guard the delete takes got no guard, which let every listed file go, though readers take those offsets from the logs again. Files chosen by the table's rules, the covered logs and the groups retention trimmed to the table's mark, are now kept when no table remains; files of a topic that had no table when the pass began still expire as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: order the pending-error merge test's row before its error The test's producer could send its error before the first Next took the row, and Next then picked either one, so on some runs the error came through the first read and the test passed without exercising HasMore. The producer now holds its error until the first Next has the row, and the merge asks again only after the producer has finished, so the test fails every time without the pending-error fix. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's chunk-backed files under the caller's context A manifest or manifest list stored in chunks was read through a stream reader built without a context, and the stream reader looked up and fetched each chunk under a background context even when built with one, so a stalled volume server held a partition load past its bound while it held accessLock. A chunk stream reader now looks up and fetches its chunks under the context it was built with, and a table's chunk-backed files are read with the caller's. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the expiredLogFiles doc comment on expiredLogFiles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: let the table catalog read chunk-backed table metadata The broker's table catalog reached its filers through a client with no way to look up chunk locations, so a table whose catalog record holds only the location of its metadata, as one whose metadata outgrew a request does, failed to load once that file was stored in chunks: the topic's history could not be read. The client now resolves chunks the way the broker's own filer client does. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: read chunk-backed table metadata under the caller's context A catalog record holding only a metadata location had its chunk-backed file read by StreamContent, whose lookups and fetches run under a background context, so a stalled volume server held a table load past its caller's deadline: a broker loading a table-backed partition under accessLock past its bound. The read now streams under the read's own context, which already bounds its other filer calls. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * filer: give up a LookupFn volume lookup's retries at its caller's deadline LookupFn retried a failed volume lookup through util.Retry, which sleeps its backoff without looking at the caller's context, so a lookup failing near a deadline outlived it by up to the whole backoff; a table load under a broker's accessLock held it that long. The lookup now retries through util.RetryWithBackoff with the same transient-error rule and about the same total wait, which stops when the context is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
284d491587 |
s3: forward notification topics to webhook targets (#13245)
* util: move the guarded dialer out of the volume server The deny list and the dialer that re-checks every resolved address at connect time move into weed/util/netguard, with the allow-private knob as a policy, so other outbound clients can dial through the same guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: fence consumer group position saves by generation A position saved with a generation is written only while the stored one carries no newer generation, or the same generation from another writer: the save reads the stored position and writes on the condition that it is unchanged, routed to the entry's owner filer, and re-reads when another writer got there first. A single consumer that elects itself can then store its offsets without a deposed predecessor overwriting them. Saves without a generation keep overwriting as before. Loading a missing position now reports ErrNotFound instead of trying every filer and marking each one failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: post bucket event batches to a webhook target A webhook destination renders a batch of records as one {"Records":[...]} body, posts it with the target's bearer token, and takes any 2xx as delivered. The renderer is a function the destination holds, a stand-in that refuses until the record renderer lands. It dials through the guarded dialer under a new Local policy, which refuses metadata-service, link-local and unspecified addresses at connect time but lets an operator point a target at a private host or a sidecar on loopback. Redirects are followed only to the endpoint's own host and never down from https. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: forward each target's topic to its destination A Forwarder runs beside the Publisher on every gateway. Each enabled target with a destination gets a lock, s3.notify.<target>, held through LockClient.StartLongLivedLock, so one gateway forwards a target and targets spread across gateways; a topic target has none. The holder runs one loop per partition of the target's topic: fetch from the stored offset at the partition's leader, decode the records, deliver them as one batch, store the next offset. A fetch that stops short at a segment boundary just continues from its next offset. A failed send, a rejected one included, blocks the partition and is retried with capped backoff, and the offset is stored only after the destination took the batch. An offset that retention removed skips to the earliest one and counts the gap. Offsets go to the consumer group offset storage under group forwarder, fenced by the lock generation. On taking the lock a forwarder stores each partition's offset back under its generation, so an older holder's saves are refused and it stops. A stored generation at or above its own means the lock was lost, unless the forwarder has since held the lock through a full renewal, which happens only when the lock server's counter restarted; it then fences above the stored generation. Metrics per target: records delivered, send retries, retention gaps, and lag from the forwarding gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: run notification forwarders beside the publisher Every gateway with filers starts a Forwarder with the publisher. It elects itself per target through the gateway's object-write lock client, stores offsets in the filer, reads through the same brokers the publisher uses, follows the target registry as the publisher does, and releases its locks on shutdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: post a test event to a webhook on its own The renderer refuses an s3:TestEvent that shares a body with other records, so a webhook splits a batch around each one and posts them in order, the test event as its own body. The test is a stand-in until the renderer's lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: skip a bucket event record that can never be delivered A record that does not decode, or that the renderer refuses, used to be retried like a failed send and would block its partition for good. The webhook now renders a whole batch before posting any of it and names the records that cannot render; the forwarder drops those, counts them per target and reason in notification_skipped_records_total, logs each offset once, and sends the rest. Only transport and HTTP failures are retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: read a fenced position save at the filer that applies it The fenced save read the stored position from whichever filer answered and then sent its conditional write to the key's owner, so with filers that keep their own stores the condition could be checked against an entry other than the one read, failing until replication caught up or judging a stale copy. The storage now takes the ring's owner lookup, the one route-by-key writes already use, and sends both the read and the write to that filer. The gateway hands its object-write lock client's PrimaryForKey to the forwarder offsets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: follow a repartitioned notification topic A forwarder listed its topic's partitions once, when it took the lock, so a repartition left the new partitions unforwarded until the lock moved. It now lists them again every 30 seconds, starts a loop for each new partition, and marks the loops of partitions no longer listed as replaced; such a loop keeps delivering what its partition holds and ends once it has caught up. A failed fetch now looks up the leader of that exact partition, not of any partition with the same range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let the first forwarder take the lock before the second asks The election test synced both gateways at once, and each forwarder asks for its lock from its own goroutine, so the second could ask first and store the offsets the test expected from the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: warn when a partition returns nothing below its high-water mark A fetch that returned no records and kept its next offset below the high-water mark looked like an idle partition, so the forwarder waited without a word while its lag stayed up. It still waits, since skipping would lose the records, but now warns at most once a minute with the topic, partition, offset and high-water mark, so the lag has an explanation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: render webhook bodies with the bucket event renderer The webhook now renders through Render and posts each s3:TestEvent alone by IsTestEvent, replacing the stand-ins it held until the renderer landed. The tests send real records and read the object keys and test request ids back out of the bodies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * netguard: refuse the IPv6 and Alibaba metadata service addresses AWS's IPv6 metadata address fd00:ec2::254 is unique-local and Alibaba's 100.100.100.200 sits in the CGNAT range, so the Private and Local policies let a webhook or remote endpoint reach them. Refuse both under every policy, like 169.254.169.254. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * grafana: chart the notification forwarder metrics Add an S3 Notifications row with delivered records, lag, send retries, and records skipped or lost to retention per target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: follow only webhook redirects that keep the POST On a 301, 302 or 303 Go resends the request as a GET without a body, so an endpoint that redirected and then answered 2xx counted as delivered while it received no records. Only 307 and 308, which keep the method and resend the body, are followed now; any other redirect fails the send and is retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep webhook endpoint secrets out of errors and logs The guarded dialer names its endpoint in every refusal, and the forwarder logs that error, so a webhook endpoint carrying credentials in its userinfo or a token in its query had them written to the log. The dialer now gets the endpoint as scheme, host and path only, and the parse and request errors no longer echo the URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: load a consumer group position from its owner filer A forwarder taking over read its start offset from whichever filer answered, while its fenced saves read and write at the key's owner. With filers that keep their own stores, a replica still holding an older offset handed the new holder that offset, which it then stored under its higher generation at the owner, replaying everything delivered since. Loads now go to the owner too when the storage knows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound consumer group position loads and saves by the caller LoadConsumerGroupPosition and SaveConsumerGroupPosition ran their filer calls under context.Background(), so a filer whose store stalled held a forwarder's save forever: ending the lead waited on it, the lock was never released, and Close hung while the lock kept renewing. Both now take the caller's context; the forwarder gives each call its RPC deadline under the lead's context, so stopping returns and the lock is released. The offset wrappers the broker uses keep their signatures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: list a consumer group's positions across partition generations ListConsumerGroupPositions walks every generation and range directory of a topic and returns the group's stored position in each, keyed by partition directory, so a consumer can tell which ranges it holds offsets for that the topic no longer lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: stop forwarding ranges a repartition removed A repartition drops the old assignments, and the broker serves only assigned ranges, so the loop draining a removed range retried a refused fetch forever, and after a restart nothing looked at it at all. Reading a removed range's flushed data would need a read-only path in the broker. Until then a removed range's loop delivers the batch it holds and ends, and the forwarder logs an error naming each range it stops and, when it takes the lock, each partition directory holding a stored offset the topic no longer lists. The fake broker now refuses unassigned ranges as the real one does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: deliver what a repartition left in the retired ranges The lookup now offers the sealed ranges a repartition retired, and any broker serves them from their files, so the forwarder no longer drops them. On taking the lock and on each re-list it asks for the retired ranges too and runs a loop for each, from its stored offset up to its high-water mark, after which the loop ends; a range it was forwarding as current and that is now retired gets the same end. A read below a retired range's log start counts as a retention gap, as for a live one. A key's records in a retired range precede its records in the ranges that replaced it, and loops running side by side would not keep that order. So the retired ranges go first, one generation at a time, oldest first, and the current ranges start only once none is left. A range listed neither as assigned nor as retired, as while a drained range is not sealed yet, pauses until it is offered again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: match a retired range to its forwarding loop by directory The broker lists a retired range at the second its generation directory is named for, while the assignment the forwarder started its loop from carried nanoseconds. After a repartition the retired entry missed the running loop, so a second loop started on the same stored offset and delivered the batch the first was still retrying. Key the loops by partition directory; the fake broker now lists retired ranges and the fake positions store offsets at that resolution, like the real ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: replace a paused forwarding loop only once it ended A range drained but not sealed yet is listed neither as assigned nor as retired, so its loop is paused and dropped from the lead's loops while it may still be retrying a batch. Once the range was offered as retired a new loop started at the stored offset and sent that batch again. Keep a paused loop until it ends, and start the range again only then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: hold the new ranges while a drained one is not sealed yet A repartition saves the new ranges before it drains and seals the old ones, so for a while an old range is offered neither as assigned nor as retired, and the forwarder started the new ranges at once: a key's new records could go out before its records still waiting in the old range. On each look at the topic the forwarder now lists the directories holding a stored offset that the topic does not offer, and probes each at its offset; one that may still hold records past it, refused because it is not sealed, holds the new ranges until it is offered as retired and drained. One that answers with nothing past the stored offset is settled, sealed and empty or already delivered, and stays so for the lead. While holding, the forwarder logs at most once a minute and keeps looking even with no loop running. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: have the fake broker serve only the generation a fetch names The broker now refuses a fetch naming a generation other than the one it assigns for the range, unless that generation is sealed and read as retired. The forwarder tests' fake broker matched an assigned range by its range alone, so it served the live generation to a fetch for an older, unsealed one; it now matches the generation too, as the broker does. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold the current ranges until the stored offsets can be listed A lead whose first look at the stored offsets failed took that as no old range left unsettled and started the current ranges, delivering a key's newer records ahead of the ones still in a drained range that is not sealed yet. A failed look now holds the current ranges as an unsettled range does, and is retried with backoff and on each partition refresh; the current ranges start only after a look succeeds. Retired ranges and loops already running carry on meanwhile. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3api: leave forwarding off on an unusable broker TLS config The forwarder loaded the grpc.msg_broker client TLS config with LoadClientTLS, which exits the process on a bad one, and every gateway with filers builds a forwarder whether or not it has webhook targets. It now loads it as the publisher does: an unusable config is logged and leaves forwarding off while the gateway keeps serving. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold the new ranges for an unsealed old range with no stored offset The check for old ranges still unsealed looked only at ranges holding a forwarder offset. A forwarder starting for the first time while a drained range was not sealed yet had stored none in it, so it started the new ranges and delivered a key's newer records ahead of its older ones. The consumer group listing now names every partition directory of the topic, with no position where the group stored none, and such a range is probed from offset 0. A range with nothing left past that offset, including one whose records retention already removed, is settled. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check the load in the fenced save race test The test read the stored position back ignoring the load's error, so a failed load panicked on a nil position instead of reporting the error. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: take a partition over at the offset its last holder committed A new forwarder generation claimed a partition by writing the offset it had loaded. When the old generation committed again in between, the claim rewound the stored offset and the new lead replayed what had been delivered since. A fenced save that takes over from an older generation now keeps the offset that generation committed last, rereading it on a conditional write miss, and hands it back in the position, and the forwarder starts from it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: wait for a position's owner filer instead of asking another A position store routed by owner fell back to any filer while the owner of a key was not known yet, as before the lock ring is learned. That filer's not-found ended the load there, though it may only not have caught up, and a claim on it would start the partition over. Loads and fenced saves now fail until the owner is known, and the forwarder retries them; a store without an owner routing still uses any filer. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: wait for the last checkpoint before a forwarder handoff in tests The resume, repartition and election tests stopped the first forwarder once its records were delivered but possibly before their offsets were stored, so they could pass on a replay rather than on a committed handoff. They now wait for the final offsets first. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: have Close wait for removed targets to release their locks A target removed from the registry had its forwarder cancelled and dropped from the targets, so a Close soon after did not wait for it and returned with that target's lock possibly still held. Removed forwarders are now kept until they are done, and Close waits for them as well. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold newer retired generations behind an unsealed older one A range of an old generation still unsealed held back only the current ranges. A generation retired after it was offered and delivered right away, ahead of the older generation's records of the same keys. The unsealed range's generation now counts as the oldest one left, so only that generation's own sealed ranges are forwarded until it is sealed. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: check the forwarder lock right before each send A lead checked its lock at the top of each fetch and after a failed send's backoff, so a lead that lost the lock while it fetched a batch still sent it, and the next holder sent it again. The lock is now checked right before each send. Delivery stays at-least-once: a lock lost during a send cancels that send once the lead notices, which may be after the endpoint took the batch. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: read a retired range past a broker that answers with an error Any broker serves a retired range from its files, but a fetch took the first broker's answer even when it was a storage error, and each retry asked that broker first again, so one broker that could not read the files held the range up for good. A retired fetch answered with an error other than an offset out of range now goes on to the next broker, and returns the error only when none could read it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: count ranges held back behind an older generation in the lag The lag gauge summed what each running loop reported, so the current ranges held back while an older generation was still unsealed, and the retired generations waiting their turn, showed no lag however much piled up in them. On each partition refresh the lead now reports their lag from the stored offset to the high-water mark, read from the range's leader or the retired listing, and drops the lag of ranges it no longer has. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold retired generations too while stored offsets cannot be listed A lead whose look at the stored offsets failed held only the current ranges and went on forwarding retired generations, though an older generation it could not see might still be unsealed and hold earlier records of the same keys. A failed look now holds every range not yet running until a look succeeds; loops already running carry on. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: read stored offsets only of the ranges a lead does not know yet The check for unsettled ranges listed every partition directory and read every stored offset in it one by one under one deadline, before dropping the ranges the topic offers and those already found settled. A topic with many past generations could take longer than the deadline on every refresh and hold a new lead for good. The listing now takes the directories to skip and reads only the remaining offsets, a few at a time, and the lead skips the offered ranges and those it found settled. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: test the failed-listing hold with no unsealed range The failed-listing test also had an older generation unsealed, which holds the newer ranges on its own once a listing succeeds, so it did not show the listing guard by itself. A second case has no unsealed range: nothing goes out while the listing fails, and both the retired and the current range do once it succeeds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: stop the lead before marking a failed loop ended A forwarding loop that failed, as on being deposed, was marked ended before it cancelled its lead. A partition refresh in between saw a retired range's loop ended, took the range as delivered, and started the next generation's ranges on the lead that was about to stop. The lead is now cancelled first, so no refresh acts on the failed loop. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: count no retention gap below an offset only claimed A lead claiming a partition with no stored offset wrote offset 0 to fence it before reading anything. A lead that stopped there left 0 behind, and the next one, finding the log start past it, counted those offsets as lost though no forwarder had ever been at them. A claim made before any read is now marked as such, a takeover keeps the marker of the entry it replaces, and only an offset a lead read from counts a gap. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: retry a takeover save at the offset it kept A claim's save that took a partition over from an older generation kept that generation's last offset, but when its reply was lost the retry went out with the offset the claim had loaded. The stored entry was by then the claim's own, so the retry kept nothing and rewound the partition, replaying what had been delivered since. A failed save now retries with the offset and marker the attempt settled on. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: store an offset as read from once the first fetch succeeds A claimed offset lost its claimed marker only when a later save moved it, so a lead that read an empty partition and stopped left it marked as never read. Records published and then removed by retention while no gateway forwarded the target were skipped without a gap counted or logged. The first successful fetch now stores the offset as read from, once per claim, even when it has not moved. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: wait for the stalled topic's publisher before reading it in a test The worker sets the topic publisher up on its own goroutine, which on a loaded host can start after Publish has stopped waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep what a timed-out offset check settled for the next one A check for unsettled ranges that could not read every stored offset within its deadline returned nothing, so each retry read the same ranges again and a long enough history kept the new ranges held for good. The listing now returns the positions it read along with the error and goes on past one that fails, and the check probes those and keeps the ranges it finds settled before reporting the failure, so the next check reads only the rest. The ranges stay held until a check covers them all. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: say which records the notification lag counts The lag gauge's help, and the dashboard panel with none, read as every undelivered record, but the records of an old range still being sealed after a repartition cannot be read and are not counted. Both now say the gauge covers the current ranges, the ranges held back behind an older generation, and the sealed retired ranges. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3f2f625822 |
s3: publish bucket events to each notification target's MQ topic (#13244)
* mq: report when a published message is acknowledged Publish now returns a channel the publisher closes once the broker acks that message, including an ack that arrives on a later stream after a resend. A caller that has to know its message is stored, such as the S3 gateway answering a request only after its event is durable, can wait on it with its own bound; callers that do not care ignore it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: build bucket event records in the AWS shape An Event is what one operation did to one object; Record turns it into an eventVersion 2.7 record for one rule, and Message wraps that record in the Records envelope a consumer receives. The key is form-encoded per path segment as AWS does it, size and eTag are left off removals, and the sequencer is the filer's commit stamp as 16 hex digits, so one key's sequencers compare as strings in commit order. The s3:TestEvent message is built here too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: publish bucket event records to each target's MQ topic The Publisher runs one worker per enabled target. The worker creates the target's topic, s3.notify-<target> with 4 partitions and 7 days of retention, then hands records to the MQ publisher keyed by bucket/key so one object's events stay in one partition in order. Setup retries with backoff, so a broker that is down or still taking the balancer lock after a cold start delays records instead of losing them. A removed or disabled target's worker stops; its topic is left for retention to age out, since a forwarder may still be draining it. Publish queues every record and waits up to 2 seconds, or until the request ends, for all of them to be acked, and reports whether they were. A record not acked by then stays queued and is still sent; the MQ publisher resends it across leader changes. Each target's queue holds 10000 records; past that, and for records whose target has no worker, a record is dropped. Acked, late and dropped records, the queue depth and the wait are exported as metrics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: start a bucket event publisher with the gateway The gateway creates one event publisher and syncs it with the target registry whenever the registry loads or changes, so each enabled target gets its topic and worker. The publisher bootstraps from the broker the command started beside the gateway, passed in as MqBroker once it bound, and from every broker the masters list, so a gateway running without its own broker still finds the cluster's. Broker connections use the grpc.msg_broker TLS section. Shutdown stops the workers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: send the test event before storing a notification configuration Unless x-amz-skip-destination-validation is true, PUT notification publishes an s3:TestEvent to the topic of every target the configuration names, in parallel, and fails with InvalidArgument listing the destinations whose topic did not ack it within the publisher's 2 second wait. Nothing is stored in that case. The registry checks still run with the header, and an empty configuration sends nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: publish ObjectCreated events for PUT and POST A PUT, including a "dir/" marker, publishes ObjectCreated:Put and a POST upload ObjectCreated:Post, after the filer commit and before the response, once per matching rule of the bucket's configuration, waiting for the acks within the publisher's bound. A failed write publishes nothing and a slow or absent broker never fails the request. The sequencer is the filer's stamp of the commit. putToFiler records it, from the routed ObjectTransaction or the lock path's CreateEntry, with the committed size, into the request so the handler finds it; the marker write and a create recovered after an ambiguous route return none, and take the gateway's clock instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: publish ObjectCreated events for copy and multipart completion CopyObject, including a metadata-only copy onto itself, publishes ObjectCreated:Copy, and CompleteMultipartUpload publishes ObjectCreated:CompleteMultipartUpload, both after the commit and before the response; a copy that keeps the connection alive publishes before its final answer. The write wrappers these use dropped the transaction response, so they now return the filer's commit stamp: routedMkFile, writeMultipartObject, routedVersionedFinalize, routedMultipartFinalize, routedSelfCopy and finalizeCopyDestination. Writes that go off the owner, through mkFile, still return none and the event takes the gateway's clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: publish ObjectRemoved events for deletes DeleteObject and DeleteObjects publish ObjectRemoved:DeleteMarkerCreated when a delete without a version id leaves a marker in place of the key, in a versioning-enabled or suspended bucket, and ObjectRemoved:Delete for any other delete, including the delete of a marker by its version id. The record carries the marker's or the deleted version's id. DeleteObjects publishes one event per key it deleted and waits for all of them at once. The routed delete wrappers now return the filer's commit stamp: routedDeleteSpecificVersion, routedDeleteNullVersion, routedDemoteNullVersion and createDeleteMarker; deleteMutationResult carries it to the handler. A suspended delete uses the stamp of the null version's delete, since the marker write after it returns none. Deletes on the lock path go through DeleteEntry, which has no stamp, and take the gateway's clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: report the ack of a published record too PublishRecord now returns the same ack channel as Publish, so a caller publishing to a topic with a record type can wait for its record to be stored. Both go through doPublish, which registers the waiter for every message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: carry bucket events as schematized records A notification topic now has a record type, EventRecordType, the single source for its flat snake_case columns: the event, requester, bucket and object fields, the commit stamp as sequencer, and multipart columns for later. event_time, event_name and bucket_name are required, the rest optional, and changes to it are additive only. The topic is configured with it, with bucket_name and object_key as key columns and the schema format left empty as for the other schematized topics, and records go out through PublishRecord. The record holds raw values: the object key unencoded, the sequencer as an int64, and nulls where a value is absent, such as size and eTag on removals. Render turns records into the AWS JSON a destination receives, the Records envelope with eventVersion 2.7, a form-encoded key and a hex sequencer, or the test event message for an s3:TestEvent, so forwarders produce exactly the body the gateway used to publish. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: shut a stopped target's publisher down even while it is blocked With the broker away long enough to fill a partition's unacked buffer, the worker blocks inside PublishRecord. Removing, disabling or closing the target only cancelled the worker's context, which the blocked worker never looked at, so the publisher and its queued records lived on and resumed sending once the broker came back. Stopping a target now shuts its MQ publisher down directly, which releases the blocked publish, and does it in the background so Sync and Close do not wait for the flush. A publisher that finishes setting up after the stop is shut down at once, and a worker that dequeues a record after the stop drops it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: publish nothing for a retried multipart completion A CompleteMultipartUpload retried after the object committed is answered from that commit and writes nothing, yet the handler still published an ObjectCreated:CompleteMultipartUpload, with size 0 since no commit was noted. AWS sends the event once, for the completion that created the object, so the handler now publishes only when the request itself committed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: take an event's principal from the authenticated identity only With auth off, the gateway keeps the s3-account-id header the client sent, and an event's principal_id fell back to it, so any client could name itself as the requester in the record a destination trusts. The principal is now the identity name authentication put in the request context, or anonymous. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: turn notifications off instead of exiting on a bad broker TLS config The event publisher loaded the grpc.msg_broker client TLS with LoadClientTLS, which exits the process on a config it cannot use, such as a cert without its key, so a broker-only TLS mistake took the S3 gateway down even with no notification targets. It now loads it with TryLoadClientTLS and, on an error, logs it and runs without a publisher: object writes publish nothing and a notification configuration's test event fails. It never falls back to an insecure connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: count a record dropped while its request waits only as dropped A record dropped while a request waited for it, by a PublishRecord error or its target being stopped, was counted dropped where it was dropped, and then late when the request's wait ran out, which it also sat through in full. Each queued record now carries a done signal that both its ack and its drop close, so the wait ends as soon as the record's fate is known and the drop is not counted again as late. Late still counts a record that was neither acked nor dropped when the request answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: let a caller cancel starting a topic publisher NewTopicPublisher returned only once a partition lookup succeeded, and retried the lookup for as long as the broker refused it, with nothing a caller could stop it with. It now takes a context that bounds the start: the topic configuration runs under it, and cancelling it stops the lookup loop and returns an error. A publisher already returned is not affected. Existing callers pass context.Background(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: stop a removed target's publisher that is still starting A target's MQ publisher was started without the worker's context, so a target removed while its partitions had no leader kept its publisher looking them up, and its worker waiting, until a lookup succeeded. The worker's context now bounds the start, so removing or disabling the target ends both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: bound each broker's ConfigureTopic during a target's setup Setup asked each broker in turn to configure the target's topic with the worker's context alone, so a broker that accepted the call and never answered held the worker there for good. Each broker now gets 10 seconds before setup moves on to the next, and a stopped worker does not ask the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: stamp a suspended delete's event with its marker write A suspended-bucket delete removes the null version, then writes the null delete marker and points latest at it. Its DeleteMarkerCreated event took the stamp of the first step, so a write landing between the steps got a later sequencer although the marker it lost to is what remained. The event now takes the stamp of the pointer write, the delete's last commit. To get it, MkFile, the gateway's mkFile and updateLatestVersionInDirectory return the CreateEntry stamp, and createNullDeleteMarker returns it. createDeleteMarker's unrouted path and writeMultipartObject off the owner now return their write's stamp too instead of none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound each broker's ConfigureTopic when a publisher starts NewTopicPublisher configures the topic again before its lookups, with no deadline per broker, so a broker that accepted the call and hung held the start until the caller gave up, even with a healthy broker next in the list. Each broker now gets 10s before the next is tried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: sequence a key's events only with stamps from its owner filer The previous change stamped a suspended delete's DeleteMarkerCreated with the null marker's pointer write, but that write goes to the gateway's default filer, not the key's owner. Filer clocks differ, so a delete could get a smaller sequencer than the PUT before it, and a consumer deduplicating on the sequencer would drop it as stale. Routing the marker write to the owner would move the suspended delete onto the transaction path, a change to the write itself. Until then the event goes back to the stamp of the null version's routed delete on the owner, and gateway clock when the delete is not routed. The same reasoning applies to the other stamps that change began returning from off-owner writes, a delete marker or a multipart object written through mkFile, so those return none again, and MkFile, mkFile and updateLatestVersionInDirectory go back to returning only an error. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: count each queued record once as acked or dropped, and late apart A drop counted the record as dropped and then closed its done channel, so a request whose wait ran out between the two still saw it pending and counted it late in the same counter. Each queued record now has a terminal outcome, acked or dropped, set once by compare-and-swap, and notification_records_total counts that outcome alone, so every lost record shows as dropped exactly once. Late moves to its own counter, notification_records_late_total, counted once per record when its request stops waiting on it before it is acked or dropped; that record is still counted acked or dropped when it settles. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3api: publish the event of a completion recovered after its commit When a finalize committed but returned an error, completeMultipartUpload answered from committedCompletion without noting the commit, so the handler published no ObjectCreated:CompleteMultipartUpload. A retry is answered as a replay and publishes nothing either, so the event was lost although the object exists. The recovery now notes the commit when the stored object holds this attempt's parts, stamped by the gateway clock as the filer's stamp is not known. One answered from another attempt's commit stays silent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: sequence a recovered completion's event with its entry's commit stamp A completion whose finalize committed but returned an error is answered from the stored object, and its event took the gateway clock. The stored entry carries CommitTsNs, the meta log stamp the committing filer gave the write, from the same sequence as the stamps the routed write paths return, and peers that replicate the entry keep it. The event now takes that stamp, and falls back to the gateway clock only for an entry written by a filer that predates it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d915787cf1 |
mq: a topic can name an Iceberg table in a table bucket (#13246)
* mq: add a table option to topic configuration
ConfigureTopicRequest, ConfigureTopicResponse and
GetTopicConfigurationResponse carry a TopicTable: the table bucket ARN,
namespace and name of the Iceberg table that holds the topic's compacted
history. A request without it keeps whatever the topic has; one with an
empty table bucket ARN asks to detach it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq: map a topic's record type to an Iceberg table layout
The topictable package lays out the table a topic's compacted history
goes into. Its columns are _partition, _offset, _ts_ns, _ts (a
timestamptz copy of _ts_ns to partition on) and _key, then the record's
fields, or _value for a schemaless topic. Scalars map to their Iceberg
counterparts, TIMESTAMP to timestamptz, records to structs and repeated
fields or list types to lists, with required-ness taken from the field.
A DECIMAL field has no precision or scale of its own, so it takes the
decimal(38, 18) the topic's parquet files already use.
The spec is identity(_partition) and day(_ts), the sort order _partition
then _offset, and the seaweedfs.mq.topic property names the owning topic.
CheckSchema says whether an existing table can hold a topic's rows,
matching columns by name so the ids a table assigns do not matter.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: create and load a table in process
The create handler splits into planCreateTable, which checks the name,
authorizes the create and builds the first metadata, and
registerCreateTable, which stages the metadata file and registers the
table, with stage-create still handled between them in the handler.
Server.CreateTable runs both for a caller inside the cluster, and
Server.LoadTable answers what a load does, sharing the GetTable call and
the metadata parse with the handler. A server-side component that needs
its own table now gets the same location, metadata file, exclusive
staging and cleanup as a REST client, rather than writing metadata by
hand.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: keep a topic's table in topic.conf
ConfigureTopic stores the requested table with the rest of the topic's
configuration, so it survives restarts and moves to another balancer. A
request that does not name a table keeps the stored one, including one
that changes the partition count, and an empty table bucket ARN detaches
it. GetTopicConfiguration returns it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: create or adopt a topic's table on ConfigureTopic
When a configure names a table, or changes the schema of a topic that
has one, the balancer loads the table through the Iceberg catalog the
broker now keeps over its filers. A missing table is created through the
catalog's own create path with the topic's layout and the
seaweedfs.mq.topic property; the table bucket and namespace must already
exist. An existing table is accepted only if that property names this
topic, its location is inside its table bucket, and its columns can hold
the topic's rows, so a topic never takes over a table it did not create
and a schema change the table cannot follow is refused.
The broker creates the table with no caller identity, as trusted
cluster tooling, so the table is owned by its namespace's owner like any
other table there. Deleting a topic only removes /topics and leaves the
table.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: refuse to leave a topic table that holds data
A configure that detaches a topic from its table, or points it at
another one, first loads the current table, and is refused while that
table has any snapshot: its history would be left with no topic to read
or trim it. A table that is still empty, or that its owner has dropped,
can be left, and stays where it is with its property. Detaching a table
that holds data is left to an explicit command.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: pass the table catalog's answers through the filer accessor
The filer accessor treats any error as a failed filer: it records the
failure, asks the next filer and wraps the last error with %v. A catalog
answer such as NoSuchTable then reached ConfigureTopic as an opaque
string, so a missing table was reported instead of created. The catalog
now goes through an adapter that returns the catalog's own answers
unwrapped and leaves failover to real filer failures.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: a table hidden by its policy still holds the topic's history
GetTable answers NoSuchTable both for a table that is gone and for one a
policy denies the caller, so a topic whose table carried snapshots under
a policy denying GetTable could detach as if the table had been
dropped. When the catalog says the table is missing, the broker now
looks for its record in the filer with the new s3tables.TableRegistered,
which finds what GetTable finds before policy, and refuses to leave a
table that is registered but unreadable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: fail over the table catalog's internal errors
The adapter between the table catalog and the filer accessor passed
every S3TablesError back as a successful filer call. An InternalError is
what the catalog answers when its own read of the filer fails, so a
broken filer was recorded healthy and no other filer was asked. Only
the catalog's refusals pass through now; an internal error goes back to
the accessor, which marks the filer failed and tries the next one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq: name a table's owning topic by its path under /topics
The seaweedfs.mq.topic property was <namespace>.<topic>, and topic names
may hold dots, so a.b/c and a/b.c wrote the same value and either could
adopt the other's table. The value is now <namespace>/<topic>, the
topic's directory under /topics: two topics that write the same value
already share one topic.conf, so they are the same topic.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq: reserve the day partition field's name in a topic's table layout
The spec partitions by day(_ts) under the name _ts_day, and Iceberg only
lets a partition field share a column's name when it is that column's
identity. A topic with its own _ts_day field mapped fine and then failed
the table create with an invalid partition spec. Schema now refuses the
name up front, with the system columns, saying it is reserved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: let the table catalog fail over to every discovered filer
The broker's filer accessor lists only the current filer, so the
failover the catalog adapter relies on had nowhere to go: an internal
error from the current filer failed the catalog call even with another
healthy filer discovered. The catalog now gets an accessor of its own
over every filer the broker has discovered, the current one first, read
under the lock that guards them. The broker's shared accessor stays on
the current filer, so topic.conf, offsets and the subscriber coordinator
keep reading one filer as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: a topic leaves a table that no longer names it
A table dropped and replaced under the same name by one that does not
carry the topic's property holds none of the topic's history, so its
snapshots no longer keep the topic from detaching, switching tables, or
following a schema change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3tables: keep tableMetadata's doc comment on tableMetadata
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mq broker: walk the table catalog's filers in order, current first
FilerClientAccessor shuffles the filers it is given, so the catalog's
create, load and registration calls each went to a random discovered
filer even while the current one answered. A filer with its own store
may not yet hold what another just wrote. Try the current filer first
and move on to the others only when it fails, as the S3 gateway does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Revert "mq broker: a topic leaves a table that no longer names it"
The property alone does not show the table was replaced: a
set-properties commit on the same table changes it and keeps the
snapshots, and the topic would then leave its history behind. Telling a
replacement apart needs the table's identity stored with the topic.
This reverts commit
|
||
|
|
45458336e1 |
s3: run a message queue broker beside every S3 gateway (#13235)
* mq broker: let an embedding command own the broker's start failure and shutdown startQueueServer now returns an error when the broker cannot start instead of exiting, binds its port before creating the broker so one that cannot serve never registers with the master, and stops when an optional shutdownCtx is cancelled. Profiling setup moves to weed mq.broker, since an embedded broker read the standalone command's profile flags. weed mq.broker and weed server -mq.broker still exit on a start failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: run a message queue broker beside the gateway by default weed s3 now starts a broker on -mq.broker.port (17777) once it has reached its filer, using the masters and filer group the filer reports. The broker is its own gRPC server: it binds the gateway's -ip.bind, advertises the address the gateway registers with the master, and joins the cluster like any other broker. It stops with the gateway. A broker that cannot start, say because the port is taken, is logged and the gateway keeps serving. -mq.broker=false turns it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: start the message queue broker with the S3 gateway weed server -s3 now runs a broker beside its gateway, started by the gateway once it reaches the filer. -mq.broker=false leaves it out. An explicit -mq.broker or -mq.agent still starts the broker on its own, and then the gateway does not start a second one. Only that explicit broker exits the server when it cannot start; the one that comes with -s3 is logged, so a host already running a broker on the port keeps its gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: run the message queue broker beside the S3 gateway weed mini now starts a broker with its S3 gateway on -mq.broker.port (17777, below the Linux ephemeral range), binding and advertising mini's -ip.bind and -ip like the other services. The port joins mini's port layout, so a taken port moves to the next free one unless it was given explicitly. The broker stops with the gateway, before the filer it flushes to. -mq.broker=false or -s3=false leaves it out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: start the message queue broker with the S3 gateway weed filer -s3 now runs a broker beside its gateway on -s3.mq.broker.port (17777), the same way weed server -s3 does: it binds and advertises where the gateway does, takes the filer's -dataCenter and -rack, stops with the gateway, and a broker that cannot start is logged while the gateway keeps serving. -s3.mq.broker=false leaves it out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: list the message queue broker when it is running The S3 gateway now binds its broker's port before it starts serving, as it does for the Iceberg and Lance listeners, and records whether the bind worked. Once mini sees the S3 port answer, the result is final: the progress board shows the broker ready or failed, and the welcome banner lists its address only when it bound. With -mq.broker=false or -s3=false neither shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep the default broker off the gateway's own ports The broker binds before the gateway binds its ports, so a gateway started with -port=17777, -port.grpc=17777 or -port=7777 (gRPC port 17777) lost its port to the default broker and exited. weed s3, weed server -s3 and weed filer -s3 now compare the broker port with the gateway's HTTP, HTTPS, gRPC, Iceberg, Lance and metrics ports first. A default broker port that clashes skips the broker with a warning; a broker port given on the command line that clashes is an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: reserve explicitly set gRPC ports before placing other ports Mini only kept derived gRPC ports free while it placed the other services, so the broker's default port could take an explicit -s3.port.grpc=17777 and push the S3 gRPC server to another port. An explicit gRPC port is now reserved too: the default broker moves off it, and an explicit broker port on it is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: keep the default broker off the ports of the servers it starts With -volume.port=7777 the volume gRPC port is 17777, the default broker port. The volume server binds its gRPC port only after a master answers, so the broker could take it first and the whole process exited. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mini: keep an explicit gRPC reservation when a derived one moves When the filer's HTTP port was taken and moved, dropping its old derived gRPC port also dropped an explicit -s3.port.grpc on the same port, so an explicit -mq.broker.port could share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: bind the broker beside S3 where the gateway binds With -ip.bind=0.0.0.0 -s3.ip.bind=127.0.0.1 the broker that comes with the gateway listened on every interface. It now takes the gateway's bind and advertised address, as under weed s3 and weed filer -s3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: keep the default broker off the volume public port Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: report a bad TLS config instead of exiting The embedded broker loaded grpc.msg_broker TLS through LoadClientTLS and LoadServerTLS, which exit on a bad config, so a cert without a key or without grpc.ca took the whole S3 gateway down. The broker now loads TLS before binding through the error-returning loaders, exported from the security package as TryLoadClientTLS and TryLoadServerTLS, and returns the error like any other start failure: the gateway logs it and keeps serving, while weed mq.broker and weed server -mq.broker still exit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: start the gateway's broker by default only with broker TLS Without grpc.msg_broker TLS the broker accepts any peer, so the broker beside weed s3, weed server -s3 and weed filer -s3 now starts on its own only when grpc.msg_broker has a cert and key in security.toml. Otherwise it stays off and the gateway logs one line saying so and that -mq.broker=true (-s3.mq.broker=true for the filer) runs it without TLS. An explicit true starts it either way and an explicit false keeps it off. weed mini, a single-process dev setup, keeps its broker on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the default broker off the ports of the servers it starts weed filer -s3 checked the broker port only against the gateway's ports, so with -webdav -webdav.port=17777 the broker could bind 17777 first and WebDAV then took the whole filer down. The check now also covers the filer's own HTTP, gRPC and read-only ports, its metrics port, and the WebDAV, IAM and SFTP ports when those run, as weed server does. A default broker port that clashes skips the broker with a warning; a clashing -s3.mq.broker.port is an error before the servers start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * server: keep the default broker off the filer read-only and debug ports The port check beside -s3 left out -filer.port.public and, with -debug, -debug.port, so a broker on 17777 could still take a port the filer or the debug server binds. Both are now in the list. WebDAV, SFTP and IAM were already covered when enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6b2e22950a |
s3: bucket notification configuration API and target registry (#13236)
* s3: add the bucket notification target registry Notification destinations are defined by the operator in /etc/s3/notification/targets.json and referred to by name from bucket configurations, so a bucket owner cannot make the server connect anywhere new. The registry parses and validates that file: unique names that fit in an ARN segment and an MQ topic name, known types (topic and webhook now, kafka, aws_sqs, google_pub_sub and pubsub accepted for later), the fields each type needs, and no unknown keys. A target serves only the buckets its allowed_buckets globs match, and none when the list is empty. Parse errors never carry credential values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: hot-reload the notification target registry Every gateway reads /etc/s3/notification/targets.json at startup and reloads it from the /etc metadata subscription it already runs for the IAM and circuit breaker files. A write reloads it, a delete or rename away empties it, and a file that does not parse leaves the previous registry in place so a bad edit does not cut every bucket off its destinations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: parse and validate bucket notification configurations The full PutBucketNotificationConfiguration document is parsed: topic, queue and cloud function configurations with their Id, destination ARN, events and key filter. Event names are checked against the AWS list, wildcards and names for things that never happen here included, plus the multipart and retention events this server emits. A filter takes at most one prefix and one suffix rule, a document at most 100 configurations, and overlapping rules are allowed. EventBridge stays NotImplemented. A destination resolves by the last segment of its ARN to a target, which must exist, be enabled and allow the bucket; the error does not say which of those failed. A rule without an Id gets one derived from its content, so every gateway reports the same configurationId for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: match an event against a bucket's notification rules Configuration.Match takes an event name such as s3:ObjectCreated:Put and an object key and returns each rule that covers them, with its configurationId and target, in configuration order. Category wildcards cover every event in the category, prefix and suffix are case-sensitive and checked independently, and an event that several rules cover matches each of them, as AWS delivers one record per rule. Publishing calls this; it is a pure function of the stored configuration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: store bucket notification configurations PutBucketNotificationConfiguration used to accept only an empty document and answer NotImplemented for any destination. It now parses the full document, checks every destination against the target registry for this bucket, and stores the XML exactly as sent in one Extended key on the bucket entry through updateBucketConfig, which patches that key alone on the bucket's owner filer. An empty document removes the key. GET returns the stored bytes unchanged, so tools comparing ARNs see no diff, and the bucket config cache carries the parsed rules for publishing to match. x-amz-skip-destination-validation is parsed and must be true or false. It only skips the test event, which publishing will send; the registry check always runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3notification: reject content after the configuration's root element The stored document is served back unchanged by GET, so anything after the root other than whitespace, comments or processing instructions is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3notification: reject unknown elements inside rules and filters A misspelled Filter, S3Key, FilterRule or Value was dropped by decoding and left an unfiltered rule; it is now MalformedXML like an unknown root child. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3notification: URL-decode prefix and suffix filter values AWS has special characters in filter values percent-encoded and a space written as +, so reports+2026/ selects reports 2026/a. A value that is not valid encoding is still matched as written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse a notification targets file stored in chunks Only inline content is read, so a targets.json kept in chunks (written by a mount, for one) read as an empty registry and dropped every target. It is now refused with a warning and the loaded registry stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3notification: refuse overlapping rules as AWS does AWS answers InvalidArgument ("Configuration is ambiguously defined") when two rules share an event type and both their prefixes and suffixes overlap, so an event for a key matches at most one rule. Such configurations were accepted and matched every rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
40bb214b3f |
s3api: store a re-copied multipart part as a new attempt so the earlier copy's data is freed (#13216)
* s3api: replace a re-copied multipart part in place so the old part's data is deleted UploadPartCopy into a part number that already held a part removed the old part entry with isDeleteData=false and then wrote the new one. The filer deletes the chunks an entry replaced only when it overwrites that entry, as UploadPart does, so the old part's chunks were left on the volume servers with no entry referencing them, for every retried or repeated copy of a part. The same applied to an empty-range copy. The part entry is now written over the existing one: the filer deletes the chunks the new entry does not hold, and the part is never missing between the two writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: store each UploadPartCopy as a new attempt of the part instead of replacing it Replacing a copied part in place deletes the replaced part's chunks while the upload is open. A CompleteMultipartUpload that listed the part before the replacement builds the object from those chunks and can commit it after they are deleted. UploadPart never replaces a part: each upload is a new attempt with its own name (genPartUploadPath). copyPartLocation now names each copy the same way, and nothing is replaced or deleted when a part is copied again. Completion already uses the latest attempt of each part number and frees the data of the others after it commits, and abort frees them all, so the earlier copy's data is still reclaimed, without a window against a completion in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: trim the UploadPartCopy attempt comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
0b0f54381d |
s3api: list every entry of the upload directory when completing a multipart upload (#13219)
prepareMultipartCompletionState read the upload directory with one listing of MaxS3MultipartParts+1 entries and ignored whether more remained. The directory holds one entry per attempt of a part, as each UploadPart gets its own name, so an upload with many parts and some retries can hold more, and the parts that sort after the first page were never found: completion answered InvalidPart for parts that exist. The cleanup listing of an already committed completion was capped the same way. listUploadEntries lists the directory page by page until the listing reports its last entry, and both listings use it. The completion test filer now pages like the filer, which its map-order listing had hidden. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
30d7f484aa |
s3api: delete the chunks a failed CopyObject or UploadPartCopy wrote (#13217)
* s3api: delete the chunks a failed CopyObject or UploadPartCopy wrote A copy writes new needles for the destination before any entry references them. copyChunks and copyChunksForRange returned on the first failed chunk without waiting for the copies still running, and nothing deleted the chunks already written. The running copies went on to write needles after the request was over; the written ones were never referenced. The same happened when the copy succeeded and the later write of the entry failed or a destination precondition refused it, and in the per-chunk loops of the SSE copy paths. The concurrent copies now go through copyChunksConcurrently: no further copy is started after a failure, every started copy is waited for, and the chunks the others wrote are deleted with deleteOrphanedChunks. The sequential SSE loops delete what they wrote when they fail part-way. A chunk a failed copy returned is not kept anywhere, so nothing is left for volume.fsck. CopyObject and UploadPartCopy delete the copied chunks when a precondition or the lock refuses the write, or when the write of the entry fails and no filer holds an entry at that path that references them: a failed write can have committed (the answer lost), and chunks deleted under a stored entry would break the object. An answer the lookups cannot settle keeps the chunks. Chunks the source entry also holds (the SSE-KMS same-key rotation hands them back) are never deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep a failed copy's chunks when any entry exists at the destination After a failed write of the destination entry, the copied chunks were deleted when the first entry the lookup found did not hold them. That entry can be an older one on one filer while the copy's own entry committed on another, for example a part written to a filer the routing failed over to, so the delete could reclaim chunks a stored entry holds. Delete them only when no filer holds an entry at the path and every filer answered, as putToFiler does. A copy that fails over an existing object therefore still leaves its chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep a copy's chunks when its failed write may still commit A write of the destination entry that fails without the filer's answer (a transport failure, a timeout or a cancel) can still be running on the filer. A lookup that finds no entry then proves nothing: the write can commit after it, and an entry would reference the chunks the cleanup deleted. Keep the copied chunks after such a failure without a lookup; these are the errors filerErrorToS3Error keeps retryable for the same reason. The lookup now runs only after the filer answered the write with an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep a copy's chunks whenever its write of the entry fails A failed write of the destination entry can have committed with its answer lost, or still commit: after a transport failure, or when a failover replay that another filer refused hides an ambiguous first attempt. A lookup cannot tell these apart, and chunks deleted under a stored entry break the object, which is worse than the leak. CopyObject and UploadPartCopy therefore keep the copied chunks when the write fails. They still delete them when the lock or a precondition refuses the write, or the old part cannot be removed, before any entry write is attempted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: size the copy-owned chunk set without adding slice lengths CodeQL flags the summed capacity hint as a possible allocation overflow; the map grows as needed anyway. 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> |
||
|
|
abd2587f9e |
s3api: send user metadata headers in lowercase (#13228)
GET/HEAD returned user metadata as X-Amz-Meta-<key>. AWS sends x-amz-meta-<key>, and older aws-sdk-kotlin releases match the prefix case-sensitively, so they saw no metadata at all. Airbyte's S3 destination reads ab-generation-id that way at the end of an Overwrite sync, treats a missing id as generation 0, and deleted the files it had just written. |
||
|
|
d4910b70cf |
s3api: classify the GetPart part key in the route-key test (#13193)
s3api: classify the GetPart part key as an uploadId modifier The GetPart route added a `part` query key that TestRouteQueryKeysAreClassified did not know, failing the s3api tests on master. `part` only narrows an uploadId request from ListParts to GetPart, like partNumber does for UploadPart, so it must not count toward the ambiguity guard: counting it would reject every `?part&uploadId` request. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d807dbfcbc |
fix(s3): preserve logical part layouts on multipart completion (#13184)
* fix(s3): preserve logical part layouts on multipart completion * s3api: accept a multipart part that is entirely a hole UploadPartCopy of a range that overlaps no source chunk stores a part with no chunks but a non-zero size. Completion rejected any chunkless non-last part as empty, so the upload failed with InvalidPart even though the part copy succeeded. Reject only parts whose logical size is zero; the all-hole part now completes as zeros at its position. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse a multipart completion made only of holes When every completed part is a hole, the object gets a positive size and no chunks, and GET answers it with InternalError as a data integrity failure. Reject that completion with InvalidPart instead of committing an object that cannot be read. Uploads that mix hole-only parts with data parts still complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
480a1baa20 |
s3api: GetPart, reading parts of in-progress and completed multipart uploads (#13174)
* s3api: GetPart reads one part of a multipart upload GET /key?part&partNumber=N&uploadId=X serves the latest attempt of an open upload's part, or the bytes that part became in the object a completed upload assembled, including a version that is no longer latest. x-amz-multipart-upload-status says which. A Range counts within the part, and a whole part answers 200 even though a completed part is served as a range of the object. The route sits ahead of ListParts and claims any ?part request, so a missing partNumber is InvalidArgument rather than a listing, and the request resolves to s3:GetObject, not the ListParts grant. * s3api: reading an open upload's part needs s3:GetIncompleteUpload AWS gates GetPart on an upload that has not completed behind s3:GetIncompleteUpload on top of s3:GetObject, so a plain read grant does not start exposing data its writer has not committed yet. The action is its own legacy grant too; Read alone does not carry it, Admin does. A completed upload's part needs only the read grant, plus s3:GetObjectVersion when it lives in a version. * s3api: a GetPart request carrying ?uploads is not a multipart listing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: GetPart answers a completed empty part with an empty 200 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1a2be918bf |
s3api: reset the circuit breaker when its config is deleted (#13148)
* 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> |
||
|
|
05d9242f3c |
s3api: answer NoSuchBucket to a denied authenticated request on a missing bucket (#13139)
* 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> |
||
|
|
672ba10b2b |
iceberg: parse each table metadata version once and encode the load response once (#13129)
* 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> |
||
|
|
8bb5c069ec |
iceberg, s3tables: new tables take only fresh locations (#13160)
* 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> |
||
|
|
aa006fa228 |
iceberg: answer vended credentials with Cache-Control: no-store (#13137)
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> |
||
|
|
4cda7ca0a4 |
iceberg: a transaction's rollback never overwrites a later write (#13162)
* 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> |
||
|
|
8f4663f516 |
iceberg: a Lance record loads with read-only credentials (#13159)
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> |
||
|
|
d29b0d430c |
lance: a register of a new name needs a dataset at its location (#13158)
* 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> |
||
|
|
10c66011c8 |
iceberg: vended credentials list only the table's directory (#13157)
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>
|
||
|
|
79b4a8ab31 |
s3tables: keep a table's root on update and rename (#13156)
* 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> |
||
|
|
442e0a24c6 |
iceberg: let a client ask for a shorter vended session, with an opt-in floor below 900 s (#13138)
* 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> |
||
|
|
edbcc718d3 |
iceberg: read remote-only metadata files, and fail a table whose metadata cannot be read (#13134)
* 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> |
||
|
|
f4931605e0 |
s3tables: say why a write the table bucket layout refuses is refused (#13133)
* 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>
|
||
|
|
2acd49ba27 |
s3api: end a vended table session no later than the caller's credential (#13161)
* 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> |
||
|
|
a963c1309c |
worker: purge the filer metadata log from a lifecycle job that keeps it past every TTL (#13101)
* 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> |
||
|
|
f9b494c576 |
filer, s3: give an entry without chunks the ETag of its inline content (#13106)
* 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> |
||
|
|
036d1117d2 |
fix(s3api): refuse a "dir/" PUT body larger than a directory marker holds (#13104)
* 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> |
||
|
|
e7cbfdcc44 |
s3: blame no filer for a deadline gRPC reports before ctx.Err() (#13098)
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> |