mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
df2fa630c110e3ff7487e71c848c55ee79e60107
16649
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
df2fa630c1 |
mount: fence events below a cached entry's own commit stamp (#13152)
A listing snapshot capped at the peers' delivery watermark can trail entries already in the store. A delayed event older than the listed version then rolled the entry back, e.g. a completed file to its empty create, until the newer event arrived. A live entry now counts as versioned at least at its CommitTsNs. Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
0d09c87281 |
fix(master): handle capacity changes during volume placement (#13185)
* fix(master): handle capacity changes during volume placement * topology: test capacity changes during placement deterministically The maintenance-toggling loops ran for seconds and could pass without reaching either guard. Drain the secondary rack or data center right before its slot draw, and feed PickNodesByWeight a node whose reported capacity changes between reads. Each case fails on the code before the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
ac2efbac01 |
fix(buffered_queue): synchronize enqueue with input closure (#13168)
Check isClosed while holding the queue mutex so the check and insertion are atomic with respect to CloseInput. This prevents a producer from successfully enqueueing after a consumer has exited a closed, empty queue. Add concurrent enqueue, close, and drain coverage with a bounded wait, plus checks for both sequential close orderings. The concurrent regression reproduces the original data race and stranded item under the race detector. Co-authored-by: Master <Master@node0.8m510.lpad-pg0.utah.cloudlab.us> |
||
|
|
10381075f3 |
mq: record the offset range of a partition's first window (#13180)
The flush wrote offset_min/offset_max only when minOffset > 0, using 0 as "no range given". A partition's first window starts at offset 0, so its file never got a range. A restarted broker derives the high water mark from those ranges, so a partition whose data was all in its first file read as empty. |
||
|
|
51d591e060 |
cluster: read a LiveLock's owner atomically (#13179)
The renewal goroutine rewrites the owner on every attempt while other goroutines read it through LockOwner. The MQ broker reads it on every request it proxies to the balancer. |
||
|
|
0964dd7713 |
filer: put a finished download on the budget's idle list before waking readers (#13147)
A download closed done and then moved its reservation to the budget's
idle list, so a reader woken by done could ask the budget for room
before the chunk it had just read was evictable.
TestReaderCacheBudgetLendsScratchToHedges failed this way about 1 in
1000 runs under -race ("hedge buffers did not evict the idle chunks").
The download now completes in the budget first.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
411e9a8542 |
filer: keep a copy of the entry in the path-specific test store (#13146)
The stub store kept the caller's entry, which the path translator changes back after the insert, so TestNameInAPathSpecificStoreCreatedTwiceIsCountedOnce raced with a lookup under -race. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
68072eff8a |
webdav: set mtime when a file is created (#13144)
* webdav: set mtime when a file is created OpenFile created the entry with Mtime 0 and only Close after a Write set the real time, so an empty PUT, or one truncating a file to empty, left it at 1970. The "new entry" marker for a failed first upload is now a field on the file. * webdav: keep a failed upload from removing another writer's version With every new entry carrying an mtime, a failed first upload removed whatever the path held at the first Write, including a version another writer stored after this open created it. The open now records the commit stamp of the entry it created, and the first Write keeps the removal only when the loaded entry still has that stamp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: check the entry's commit stamp when the upload fails The first Write's lookup left a gap: a version another writer stored after it was still removed by a later failed flush. Flushes only append chunks locally, so the stored entry keeps the create's stamp until Close; the failed flush now reads it then and removes it only while it still has that stamp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
53206f16be |
fix: reject NaN minimum free-space percentages (#13153)
Signed-off-by: guagucai <guagucai@outlook.com> |
||
|
|
0025e7177f | fix(filer): preserve chunk ordering on 32-bit systems (#13175) | ||
|
|
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> |
||
|
|
c637d60dfc |
filer.sync: keep an informational replay cursor on the source, and let the log purge honor it (#13176)
* filer.sync: save the sync position on the source filer as a replay cursor The position stays authoritative on the target. The source copy holds the last position the target checkpoint stored (a fresh sync without one holds just before the first event it received) and is rewritten hourly while the sync runs, even when the position does not move. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: do not replicate the sync cursors of the source A target never holds cursors that describe the source's log. A rename into or out of the cursor directory replicates the ordinary side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * metadata log purge: keep the logs a filer.sync still needs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: describe the sync in its source cursor The source cursor is informational: besides the position it records the source and target filers and paths, exclusions, host, version, when the sync started, whether the position is a target checkpoint, and the processed and failed event times, for display in admin tools. The target checkpoint stays authoritative. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: save the first sync cursor when the first event arrives and retry failed saves A fresh sync only saved its cursor on the next minute tick, and a failed save still pushed the next attempt out by an hour, leaving the purge without a cursor while the sync replayed old log days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.backup: do not seed the source's sync cursors in the initial snapshot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * metadata log purge: say that a position not saved for 7 days stops holding the log Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.backup test: lock the recording sink for concurrent snapshot workers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: leave the sync cursors out of the metadata log gap check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
bcd678271e |
mount: authorize filer calls with a pre-issued token file (#13118)
* security: filer token source read from a file FilerTokenFile is the token source of a client that holds a pre-issued filer token rather than a signing key. It reads the file on every call, so an atomic replacement that keeps size and mtime takes effect on the next attempt, and trims surrounding whitespace. A missing, unreadable, empty or malformed file fails the call: there is no fallback to anonymous or admin authority, and errors name the path but not the contents. FilerTokenClaims decodes a token's claims without a key, and FilerTokenGrantCovers compares two grants, so a client can plan reconnects before expiry and know when a replacement narrows what it may see. * mount: -filer.tokenFile authorizes filer calls with a pre-issued token A mount that should not hold a filer signing key can now present a token issued for it. -filer.tokenFile (or -o filer.tokenFile=) names the file; it is read for every filer gRPC attempt, so a replaced file takes effect on the next call or retry without a restart, and a missing or empty file fails the call locally. The source reaches every filer client the mount builds: the startup handshake, each attempt of WithFilerClient, the volume location client, the SSE-S3 reader's configuration call, the peer registrar dial and the lock client. It is attached per call, never to the cached channel, and never to master, volume or peer mount RPCs. The filer refuses MountRegister, MountList and distributed locks to scoped tokens, so the mount refuses to start when -filer.tokenFile is combined with -peer.enable or -dlm instead of failing at run time. Server-side copy_file_range signs its filer HTTP request with the HTTP key, not this token, and is unsupported with it. Without the flag the mount behaves as before. * mount: resubscribe metadata with a replaced filer token A metadata subscription keeps the authority it opened with, so a mount reading -filer.tokenFile would follow with the old token until the filer ended the stream at expiry, and every such end took the gap path that distrusts all cached listings. SubscribeMetaEvents now takes the credentials of each attempt. The mount opens each subscription with the token current at that moment and watches the file; once it holds a different token the attempt ends and the follow resubscribes at once from its checkpoint. This planned resubscribe is not a gap: cached listings stay, unless the new grant may show less than the old one or either token cannot be decoded, in which case they are read again so nothing the old grant showed outlives it. The filer walk treats a resubscribe like a stopped follow, so the same attempt is not replayed on the next filer. Without a token file nothing changes. * mount: hand the mutation stream over to a replaced filer token The mutation stream keeps the token it opened with, and a filer refuses to send on a scoped stream once that token has expired. A mutation applied at that moment loses its reply, the mount reads that as a transport failure, and the unary fallback sends it again. The stream now opens with a snapshot of the token source. Before admitting a request it checks the source: when the file holds another token, or the stream's token would expire before a reply could come back, the stream is retired. New requests wait while the admitted ones are answered, the stream is half-closed so the filer finishes it, and a successor opens with the new token. The waits give up only after filerRPCWait without a response, so a rename that keeps answering is not cut short. A request is never resent by the handover: one still unanswered when the wait gives up fails as on any lost stream, as before. A token too close to expiry to open a stream with is refused before anything is sent, so the request goes out once as a unary call, which the filer checks when it starts. Without a token file nothing changes. * mount: review fixes for the filer token file - A distrust of cached listings now also discards the directory builds in flight, in the meta cache's apply loop: such a build publishes nothing, its entries are wiped and the visit lists the directory again, so a listing read under a grant that has since narrowed is never cached after the distrust. The cached flags are reset again in the loop, after any build that completed before it. - Retiring the mutation stream runs in the background, and a request that waits for the retirement gives up on its own context, unadmitted. - With a token file and no filer signing key, server-side whole-file copy is not tried: its filer HTTP request would go out unsigned and fail as ambiguous. The copy streams through the chunk path instead. - On Windows the token file is opened with delete sharing, so a renewer can replace it by rename while a read holds it open; the missing-file test checks os.ErrNotExist instead of Unix wording. * mount: review fixes for the mutation stream handover A request admitted to the mutation stream with just over one RPC wait left on its token could wait behind a slow send until that margin was gone; its reply could then be refused at expiry and the request was resent over unary. The send loop now checks the margin again right before sending and holds back a request that no longer has it, which is safe to send over unary because the filer never saw it. A sent request whose reply is lost while the token has one RPC wait or less left now fails with EIO instead of a transport error: the filer may have applied it, so it is not resent. Losses with the margin intact fall back to unary as before. A newly opened stream now admits its first request through the same checks as an open one, so a token file replaced, or a token that neared expiry, while the stream opened is caught before anything is sent. A retirement keeps a cancel handle for its stream. Close uses it, so unmount no longer waits for admitted requests to be answered, and a waiter that gives up on a retiring stream stops it as it would stop an open one, so a request still queued there is never sent after that waiter fell back to unary. An ordinary rotation still drains admitted requests. * mount: drop kernel listings when the filer token's grant narrows A replacement token whose grant may not cover the old one already distrusts the mount's own cached listings. The kernel kept its own copy: OpenDir sets FOPEN_CACHE_DIR | FOPEN_KEEP_CACHE, so a directory still reachable under the new grant was listed again from the page cache with names the new grant may hide, until something else invalidated it. On a narrowed or undecodable grant the mount now also notifies the kernel for every directory inode it holds, from the subscription goroutine as the metadata apply path already does, so the next readdir reaches the mount. A readdir already under way on an open handle still finishes from what it read. * mount: drop kernel listings after a subscription gap too distrustCachedListings serves both the narrowed-grant path and the gap path. A gap can lose the very events that would have dropped the kernel's cached listings one directory at a time, and with FOPEN_KEEP_CACHE on OpenDir the kernel then serves those listings on every reopen. Move the kernel drop into distrustCachedListings so both paths get it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
2b0bff0135 |
filer.sync: warn when the source metadata log no longer covers the sync (#13143)
* filer.sync: warn when the source metadata log no longer covers the sync A sync replays the source's metadata log from its saved position, or from the oldest log file when it has none. Once older log days are purged, a position older than the log silently skips the purged changes, and a fresh sync never copies entries whose last change was purged, so the target ends up incomplete without any sign of it. At start, compare the position with the oldest log file the source keeps; for a fresh sync, look for a child of the source path whose last change (commit time, or mtime for entries without one) predates the log, and log a warning naming it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: skip excluded and multipart upload entries in the log gap check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.sync: run the log gap check without delaying the subscription Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
50f7c73101 |
s3 backend: HTTP/1.1 client defaults for disable_http2 (#13126)
* s3 backend: HTTP/1.1 client defaults for disable_http2 ## Problem `disable_http2` (#11897) keeps the cloud tier's S3 client on HTTP/1.1, so every tier upload and range read gets a connection of its own. The rest of the client still has the defaults sized for one multiplexed HTTP/2 connection: - Go's idle pool keeps only 2 connections per host, so a burst of concurrent range reads redials TLS for almost every request once the burst is over and the next one starts; - the wait for response headers is the 60 s bound every tier client has; - the SDK retries 3 times. On a Ceph RGW-based S3 service, HTTP/2's small flow-control window held tier uploads at 18 MB/s and made 24 concurrent cold scans take 52 s each; on HTTP/1.1 they took 3.7 s each, but only with a larger idle pool, a shorter header bound and more retries for the 503 SlowDown answers that the extra parallelism draws. ## Fix With `disable_http2 = true` the tier client also gets: - an idle pool of 100 (`MaxIdleConns` and `MaxIdleConnsPerHost`); - `ResponseHeaderTimeout` of 30 s; - `MaxRetries` 5, so the SDK's retryer backs off on 5xx, SlowDown and throttling. `max_connections` and `idle_connection_timeout_seconds` apply as before. Without `disable_http2` the client is unchanged. The scaffold `master.toml` mentions the defaults. ## Tests `TestS3BackendHTTP1ClientDefaults` in `weed/storage/backend/s3_backend/s3_sessions_test.go`: with `disable_http2` the transport has the idle pool and the 30 s header bound, and the client 5 retries; without it (and with `max_connections` set) the client keeps the SDK's retries, the default idle pool and `s3ReadTimeout`. It fails without the change. `go vet ./weed/storage/backend/s3_backend/` and `go test ./weed/storage/backend/s3_backend/`: ok. `go build ./weed`: ok. * s3 backend: keep the larger idle pool for every tier client A tier client on a plain http:// endpoint, or on a TLS service that offers no HTTP/2, speaks HTTP/1.1 without disable_http2 and had the same 2 idle connections per host, so each burst of concurrent reads redialed. HTTP/2 keeps one connection, so the pool size does not change it. The header bound and retries stay with disable_http2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
faffb0d291 |
build(deps): bump github.com/jackc/pgx/v5 from 5.10.0 to 5.13.0 (#13164)
Bumps [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) from 5.10.0 to 5.13.0. - [Release notes](https://github.com/jackc/pgx/releases) - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgx/compare/v5.10.0...v5.13.0) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v5 dependency-version: 5.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
5f65cd0859 |
build(deps): bump go.mongodb.org/mongo-driver from 1.17.9 to 1.17.10 (#13163)
Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.17.9 to 1.17.10. - [Release notes](https://github.com/mongodb/mongo-go-driver/releases) - [Commits](https://github.com/mongodb/mongo-go-driver/compare/v1.17.9...v1.17.10) --- updated-dependencies: - dependency-name: go.mongodb.org/mongo-driver dependency-version: 1.17.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
184860a4c3 |
build(deps): bump golang.org/x/oauth2 from 0.37.0 to 0.38.0 (#13165)
Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.37.0 to 0.38.0. - [Commits](https://github.com/golang/oauth2/compare/v0.37.0...v0.38.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-version: 0.38.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
1924ce9f06 |
build(deps): bump github.com/aws/aws-sdk-go-v2 from 1.48.0 to 1.48.1 (#13166)
Bumps [github.com/aws/aws-sdk-go-v2](https://github.com/aws/aws-sdk-go-v2) from 1.48.0 to 1.48.1. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/v1.48.0...v1.48.1) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2 dependency-version: 1.48.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
3993cb38c3 |
build(deps): bump github.com/jhump/protoreflect from 1.18.1 to 1.19.0 (#13167)
Bumps [github.com/jhump/protoreflect](https://github.com/jhump/protoreflect) from 1.18.1 to 1.19.0. - [Release notes](https://github.com/jhump/protoreflect/releases) - [Commits](https://github.com/jhump/protoreflect/compare/v1.18.1...v1.19.0) --- updated-dependencies: - dependency-name: github.com/jhump/protoreflect dependency-version: 1.19.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
62d6127d6e |
build(deps): bump actions/download-artifact from 7 to 8 (#13169)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7 to 8. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
a07f774e6f |
build(deps): bump github/codeql-action from 4.39.4 to 4.39.5 (#13170)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.39.4 to 4.39.5. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/v4.39.4...v4.39.5) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 4.39.5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> |
||
|
|
b066c31172 |
build(deps): bump sigstore/cosign-installer from 4.1.3 to 4.1.4 in /.github/actions/sign-image (#13171)
build(deps): bump sigstore/cosign-installer Bumps [sigstore/cosign-installer](https://github.com/sigstore/cosign-installer) from 4.1.3 to 4.1.4. - [Release notes](https://github.com/sigstore/cosign-installer/releases) - [Commits](https://github.com/sigstore/cosign-installer/compare/v4.1.3...v4.1.4) --- updated-dependencies: - dependency-name: sigstore/cosign-installer dependency-version: 4.1.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.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> |
||
|
|
a2d6b07d3c |
filer: refuse a non-recursive delete of a bucket that has children (#13122)
* filer: refuse a non-recursive delete of a bucket that has children A non-recursive delete of a folder that has children fails with ErrNonEmptyFolder: doBatchDeleteFolderMetaAndData lists the folder's first page and refuses. For a bucket on a store that keeps each bucket apart (leveldb3, the SQL stores with bucket tables, ArangoDB, YDB with bucket tables), it skipped that listing, because such a store drops a deleted bucket's children in one call and a recursive delete needs no walk. The non-recursive delete then went through: DeleteFolderChildren dropped the bucket's objects, the bucket entry was deleted, and DeleteEntryMetaAndData deleted the bucket's collection, so the objects' volumes went with them. rmdir on a weed mount, fs.rm without -r and a filer HTTP DELETE without recursive=true each send such a delete. On the other stores the same request is refused. A non-recursive delete now lists a bucket on these stores the way it lists any other folder, and is refused when the bucket has children. An empty bucket is still dropped by the store, which frees what the store keeps per bucket, and a recursive delete still drops a bucket without a walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: say why a non-recursive bucket delete still sweeps Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
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> |
||
|
|
3da9c41404 |
iceberg maintenance: worker setting for the row-group size of compacted files (#13128)
* iceberg maintenance: worker setting for the row-group size of compacted files Compaction takes a compacted file's row-group size from the table property `write.parquet.row-group-size-bytes`, and falls back to Iceberg's default, 128 MB, when the table sets none. Most tables set none, and the default target file size is also around 128 MB, so a compacted file usually comes out as a single row group. A reader's column filter (a time range, an id range) can then skip the whole file or nothing inside it. Setting the property table by table is the only way to change that today. This adds a worker setting, `row_group_size_mb`, that sets the size for tables without the property: - default 0 = Iceberg's 128 MB, so nothing changes unless an operator sets it; - the table property still wins over it, so an engine or a user that chose a size keeps it; - `write.parquet.row-group-limit` (rows) is untouched. For example, `row_group_size_mb = 64` gives about two row groups per 128 MB compacted file. Test: `TestRowGroupSizeWorkerSettingAndTableOverride` (the default is 0, the setting is read, a table without the property gets the worker's size, the property wins). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg maintenance: raise the descriptor version with row_group_size_mb The admin keeps a stored descriptor unless the new one's version is not lower. With both at 1, an older worker serving a descriptor refresh during a rolling upgrade replaced the form and row_group_size_mb disappeared. The test fails at version 1. * iceberg maintenance: say row_group_size_mb also caps the spatial row group size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: keep at least one row per row group when a row outgrows the byte size With an explicit row limit the estimate had no floor, so a byte size smaller than one row gave 0, which parquet-go takes as no limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: say row_group_size_mb only caps a spatial rewrite's row groups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
81f9231e2f |
iceberg compact: optional spatial clustering of geometry tables (#13135)
* iceberg compact: optional spatial clustering of geometry tables Compaction of an Iceberg v3 table with a geometry column merges files in manifest order (bin-pack) or by a declared sort order. Neither keeps nearby geometries together: after a bin-pack every output file and row group spans the whole extent of the table, so a reader can skip nothing by the geometry bounds and row-group geospatial statistics. In one measurement a point lookup on a table of places read 4.59 MB after bin-pack compaction and 0.55 MB after a spatial one. A declared sort order cannot express this either: Iceberg v3 has no spatial sort transform, a geometry cannot be a sort source, and DuckDB refuses INSERTs into a table that declares a sort order. This adds an opt-in spatial order to the compaction job. Spatial clustering (`spatial_clustering`, off by default). When on, a v3 table with no declared sort order and exactly one top-level geometry column is rewritten in the Hilbert order of each row's bounding-box centre, whatever `rewrite_strategy` says (a declared sort order is still honoured, since such a table does not qualify): - The 62-bit key (31 bits per axis) is computed from the WKB while the rows stream through the merge, carried as an extra last column through parquet-go's sorting writer into a temporary file in `sort_spill_dir`, and dropped when a plain writer copies the rows to the output. Row lineage is mapped before the key is added. The grid is the globe for a lon/lat CRS and the union of the bin's file bounds for a projected one. Null, empty and unreadable geometries sort last. The key only orders rows; pruning stays on the geometry bounds, so a poor key costs speed, never results. - Files are listed by the key of their bound's centre before binning, so the bins of one partition cover compact areas. - Row groups target `spatial_row_group_size_mb` (2 MB, capped by the table's `write.parquet.row-group-size-bytes`, at least 16 rows; an explicit `write.parquet.row-group-limit` still wins). A row group is what a spatial filter skips, and a row of a large polygon can be tens of kilobytes. - A bin the order cannot be laid over (a projected column whose files carry no bounds, a geometry column the merge cannot find, e.g. after a rename in files without field ids) is bin-packed in bin-pack row groups. - The table property `seaweedfs.compaction.spatial-column` names the column when a table has several, or opts a table out with `none`. - The snapshot summary records `rewrite-strategy=spatial` and `spatial-column`, or `binpack` when every bin fell back, and `spatial-fallback-bins` when some did. The planning index's config hash covers the new settings. Open time partitions (`spatial_hold_open_partitions`, default true, and `spatial_open_partition_grace_minutes`, default 120; both only matter with spatial clustering on). A spatially ordered partition has every row group spanning its whole time range. On a day of vehicle positions, "where is every vehicle now" read 2.51 MB of the spatially compacted day against 0.04 MB of the files as written, while an area query on a closed day read 2.74 MB against 19.35 MB. So a day or hour partition is left in write order until it has ended plus the grace (late batches still land in it), and is ordered in space after that. The job and detection hold the same bins; the planning index caches its answer only until the first held partition is released, so a table nobody writes to after midnight still gets its last day ordered. Coarser time partitions and the other strategies are unchanged. `github.com/twpayne/go-geom` (already in the module graph) becomes a direct requirement for its WKB parser. Tests: - spatial_order_test.go: the Hilbert curve, plan resolution (version, sort order, one or several geometry columns, the property, opt-out), 2,400 scattered points compacted end to end in spatial order with row ids kept and no key column written, the job setting off as control, nulls last, a projected CRS with and without file bounds, file ordering, and the row-group sizing. - spatial_fallback_test.go: the bin-pack fallback uses bin-pack row groups; a geometry column the merge cannot find falls back, with the summary saying so. - spatial_open_test.go: partition ends for day and hour across the value types a manifest reader returns and far from 1970; the hold, the grace and their controls; the planning index release time and config hash; on the fake filer, a day-partitioned geometry table where the job compacts the past day in spatial order and leaves today's files, a table of only today commits nothing, and the index records midnight UTC plus the grace (each with the hold off as control); spatial clustering is off by default. - Mutation checks: a constant key fails the spatial order tests; disabling the hold fails four open-partition tests. - go vet and go test (also with -race) of weed/worker/tasks/iceberg pass; go build ./weed passes. * iceberg compact: give the spatial sort key a name no table column has Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: report spatial order only for bins it wrote A bin skipped after a read or merge error no longer counts as spatially ordered in the snapshot summary or the job result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: do not hold an open partition the spatial order cannot cover A projected geometry column whose files carry no bounds is bin-packed, so holding its open day or hour partition only left small files behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: do not hold a drop-only bin in an open partition A bin whose rows are all deleted removes its files and writes nothing, so there is no spatial rewrite for an open day or hour partition to wait for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: pack delete-heavy files in the spatial file order Delete-heavy bins took the table's order while the other bins of a spatial plan list their files by the Hilbert key of their geometry bounds, so a partition split into several delete-heavy bins merged overlapping areas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ec2d96888d |
pb: use the slot allocator as gRPC's buffer pool (#13136)
* pb: power-of-two gRPC buffer tiers up to 1 MB ## Problem gRPC's default buffer pool has tiers of 256 B, 4 KB, 16 KB, 32 KB and 1 MB, and zeroes a pooled buffer's whole capacity on every `Get`. Every message between 32 KB and 1 MB therefore zeroes 1 MB, in the proto codec's marshal and in every receive. A filer entry that holds a table's Iceberg metadata (inline content, extended attributes) is such a message, several times per commit. Profiled on `weed mini` under an Iceberg commit load (8 DuckDB writers, one table each, 30 s CPU profile): `runtime.memclrNoHeapPointers` under `sizedBufferPool.Get` was 2.39 s of 30.0 s sampled, 8% of the process's CPU. With the tiers below it is 0.74 s of 22.2 s. ## Fix `weed/pb` sets the process-wide default pool at init (`experimental.SetDefaultBufferPool`, which gRPC documents as init-time only) to a binary tiered pool with every power of two from 4 KB to 1 MB (plus 256 B), so zeroing is bounded by twice the message size. Buffers are still zeroed; only the tier sizes change. The proto codec reads only the default pool; `NewGrpcServer` and `GrpcDial` also pass the pool as an option (`experimental.BufferPool`, `experimental.WithBufferPool`), because gRPC's own default server and dial options captured the old pool before this package's init ran. Messages up to 32 KB and above 1 MB use the same tiers as before. Each extra tier is a `sync.Pool`, emptied by the GC like the others. ## Tests `weed/pb/grpc_buffer_pool_test.go`: - `TestGrpcBufferPoolIsTheDefault`: the default pool is the tiered one. - `BenchmarkGrpcBufferPoolGet`: a `Get`+`Put` with gRPC's default tiers against these (Apple M-series, `go test -bench GrpcBufferPool -count 3 ./weed/pb/`): | message | default tiers | power-of-two tiers | |---|---|---| | 40 KB | 9.8–10.1 µs | 0.59–0.71 µs | | 100 KB | 10.1–10.8 µs | 1.24–1.29 µs | | 300 KB | 11.1–14.7 µs | 5.6–5.7 µs | `go vet ./weed/pb/` reports nothing in the touched files; `go test ./weed/pb/`: ok. `go build ./weed`: ok. * pb: test the buffer capacity each gRPC pool tier hands out Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: rely on the default pool for dials, which read it per connection grpc's defaultDialOptions() reads mem.DefaultBufferPool() at dial time, so only the server, whose defaults were captured at grpc's init, needs the pool passed as an option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mem: return only slot-sized buffers to the slot pools Free put any buffer into the slot its capacity rounds up to, so a nil or odd-capacity buffer made a later Allocate of that slot panic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mem: serve the slots through a Get/Put pool type SlotPool satisfies gRPC's mem.BufferPool, and Allocate and Free now go through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: use the slot pool as gRPC's buffer pool The slots round up to the next power of two and do not zero, so gRPC shares buffers with Allocate and no longer clears them on every Get. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
c3f7f24684 |
mount: wake an upload parked on a read when the read ends (#13123)
* mount: wake an upload parked on a read when the read ends
An upload that finishes while a read holds its chunk waits in its own
goroutine until the read lets go (`for up.IsLocked(index) {
up.readerCountCond.Wait() }`), and only then drops the sealed chunk and
returns its executor slot. The only wake-up came from MaybeReadDataAt,
which a read calls before it lets go of the chunk. UnlockForRead, where
the read does let go, woke nobody. So:
- A read that returns before its dirty-page pass never wakes the
upload. readDataByFileHandleWithContext skips readFromDirtyPages when
the chunk read fails, and the kernel interrupts a FUSE read, which
cancels it, whenever a signal reaches the reading thread.
- A read that does call MaybeReadDataAt wakes the upload while it still
holds the chunk, so the upload goes back to waiting unless the read
releases the chunk before the upload gets the lock back.
Only a later read of the same file then moves the upload on. When none
comes, because the file was closed or is no longer read, the upload
stays parked for good. It keeps its sealed chunk (and its share of
-writeBufferSizeMB, when that is set) and a slot of the
concurrentWriters executor, which every file of the mount shares (128
by default). Once parked uploads hold every slot, each new upload of
the mount waits for one, and writes and flushes behind them hang.
UnlockForRead now broadcasts when the last read of a chunk ends, which
is the only place the condition changes, and MaybeReadDataAt no longer
signals. It broadcasts rather than signals: a read across a chunk
boundary releases two chunks, and an upload may be parked on each.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* mount: wait for the uploads to park instead of sleeping in the wake-up tests
parkUploads slept 100ms and assumed the uploads were waiting on the read
by then. An upload that had not got there yet would find the read gone
and go on without a wake-up, so the tests could pass with the wake-up
missing. It now watches the goroutines' stacks until each upload waits
on readerCountCond, counting out uploads an earlier test left waiting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
576eb98ce9 |
mount: leave -cacheMinFreeSpace free on the chunk cache's disk (#13124)
* mount: leave -cacheMinFreeSpace free on the chunk cache's disk weed mount sizes its on-disk chunk cache by -cacheCapacityMB alone and preallocates each cache file in full when it creates it. With a capacity larger than the free space of the disk holding -cacheDir, the cache takes that disk down to nothing: the preallocations run until fallocate fails, and chunk writes fill the rest. The mount's metadata cache (a leveldb store under -cacheDir) and the swap files of dirty pages (-cacheDirWrite, which defaults to -cacheDir) live on the same disk, so once it is full their writes fail with ENOSPC, and writes whose dirty pages spill to swap return EIO to the application. The same happens when several mounts share a cache disk and together are configured beyond it. -cacheMinFreeSpace is the free space the cache leaves on that disk, written like the volume server's -minFreeSpace: a percentage like 1 or a size like 10GiB, 1 by default, as for volume servers. - When the cache opens, its disk layers shrink to the space above the floor, counting the cache files already in the directory as the cache's own. With no room the disk tier keeps no files. - Each new cache file preallocates only what the disk holds above the floor at that moment, so the files of one cache, or the caches of several mounts opening together, stop reserving at the floor. - A chunk write that lands in blocks its file already holds, preallocated or written, goes ahead as before, even with the disk under the floor. A write that takes new disk space, into a file a rotation truncated or where nothing could be preallocated, goes ahead only while the space above the floor covers it. The disk is read at most once a second, and the cache counts what it takes in between, so it cannot run past the floor between readings. A rotation gives the truncated file's blocks back, so the write after it reads the disk again. A chunk the cache cannot place is not cached, like any other miss. The webdav server's cache passes no floor and behaves as before. * mount: read the cache disk on every write that takes space, leave the index files room Review follow-ups. - take reads the disk each time, instead of once a second less what the cache took since, so a write sees what other mounts sharing the disk wrote, and what a rotation gave back. It runs only for writes past the blocks a file already holds, and a statfs costs little next to the write. - The index files (.idx and the leveldb maps) grow by a few dozen bytes a chunk beside the data files that the cache size counts. Sizing leaves them a sixteenth of the room above the floor. - The cache's own files count as room by the blocks they hold, so a file that was preallocated but not yet written when the mount exited counts in full when the cache reopens. - weed fuse checks -o cacheMinFreeSpace in the parent as well: the parent waits for the child's signal, and a child that rejects the value never sends it. * mount: keep the resolveCacheDirs doc comment on resolveCacheDirs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: say -cacheMinFreeSpace stops new disk space, not every chunk Under the floor the cache still fills the blocks its files already hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
7a5c12a8b0 |
filer: order finished reader cache downloads by a counter (#13125)
Eviction picked the oldest finished download by the wall clock time it finished at, and only counted downloads that finished before time.Now(). A download that finished in the same clock tick as the eviction didn't count, so the loop fell back to a chunk a stream was still reading, and two pinned downloads that finished in the same tick tied. After a wall clock step back, downloads that finished before the step didn't count either, and with none of them pinned nothing was evicted and the cache grew past its limit. Finished downloads now take the next value of a counter on the cache, which never ties or steps back. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ecd0493906 |
mount: keep following the metadata log when the cache refuses an event (#13141)
* mount: keep following the metadata log when the cache refuses an event The mount applies each event of the filer's metadata log to its local metadata cache, a leveldb store under -cacheDir. Once that disk is full every write to the store fails, and an event the cache refuses goes one of two ways: - An event the stream delivers fails the follow, which the mount runs with FatalOnError: glog.Fatalf ends the process, every file open on the mount goes with it, and the mount does not come back when the disk has room again. - An event replayed from the persisted log is returned to the follow loop, which resubscribes from it and fails on it again: the mount stays up, but no later event reaches its cache, so its listings stop changing. A local change whose apply fails (create, mkdir, unlink, rmdir) drops its directory's cached listing with InvalidateChildrenCache and goes on. An event from the log now does the same: the cached listings it changes, the parents it leaves and enters and a directory it creates, moves or deletes, are dropped, so the next lookup reads the filer and the next listing rebuilds them, and the event's kernel invalidations still go out. The follow goes on. A warning reports the first such event and then at most one a minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: handle a refused event in the apply step that refused it Review of the previous commit found two gaps. A rename into a directory whose listing is being built applies the part leaving the source at once and keeps the part entering the building directory for the build to replay. When the part applied at once was refused, the other part was not kept, and the build published its listing without the renamed file. It is now kept whatever happens to the part applied at once. The listings a refused event changes were dropped, and its kernel invalidations sent, by the follow's event function after the apply returned. By then the apply loop could have taken a later request, such as this mount's own create of the name a rename left, and the rename's invalidation would then move the new file. The apply step that fails now does both before it returns, as it sends the side effects of an event the store takes, and on the apply loop, which owns buildingDirs and is the only one to feed the invalidate worker. A local change whose apply fails gets the same; its caller still drops its directory's listing as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
3c7b3fc16f |
mount: fail an unlink or rename the filer did not apply (#13140)
* mount: fail an unlink the filer did not apply * mount: hold an unlinked handle's flushes until the filer answers * mount: mark a rename's replaced handle once the filer answers * mount: read a draining handle's unlink mark under its lock Unlink now sets the mark after the delete answers, while a close queued before it can be draining, so the worker's bare read raced the write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: drop the unlink comment about marking before the delete Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: wait for the close to block on the handle lock in the unlink and rename tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: wait on the handle lock with the untagged helper in the rename close test waitAttributeReadFrame lives in a !freebsd test file, so the FreeBSD test build failed on weedfs_rename_publish_test.go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d4a21cef59 |
weed: flush buffered log lines when a command exits (#13151)
exit() ends the process with os.Exit, which skips deferred calls, and glog writes its files only every 30s. A short-lived command such as a piped weed shell session lost every log line it buffered, including the daily_run summary of s3.lifecycle.run-shard. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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>
|
||
|
|
bf14326c3c |
iceberg maintenance: apply deletion vectors in compaction; optionally rewrite delete-heavy files (#13131)
* iceberg maintenance: recognise deletion vectors whose format is written in lowercase Iceberg maintenance tells a Puffin deletion vector from a Parquet position-delete file by its `file_format`, compared exactly with iceberg-go's constant `PUFFIN`. DuckDB records the format in lowercase, `puffin` (as it records `parquet`, which compaction already compares without case). Such a vector was never taken for a vector: - the data file it covers was not kept out of compaction bins, and - the vector itself was handed to the Parquet position-delete reader, which cannot read a Puffin file, so compacting any table holding one failed (and the position-delete rewrite tried to read it the same way). The fix adds `isPuffin`, a case-insensitive comparison, and uses it at the four places that compared the format. Test: `TestLowercasePuffinDeletionVector` wraps a deletion-vector entry so its format reads `puffin` (as the Avro reader passes it through) and checks that the data file it covers is excluded and that `collectPositionDeletes` does not try to read the vector. It fails without the change (`dv paths = map[]`). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg maintenance: apply deletion vectors in compaction; optionally rewrite delete-heavy files Compaction has no reader for Puffin deletion vectors (DVs), so every data file a vector covers is kept out of compaction for good (`excludeDeletionVectorFiles`). A format-version 3 table that is reloaded with DELETE + INSERT (DuckDB writes a vector hiding all of the old file) keeps the old file and its vector forever, and every reader pays for both. Bins also form only from `min_input_files` small files per partition, so deleted rows never enter the decision. This builds on #13127 (the case-insensitive `puffin` format check); the first commit on this branch is that PR. Changes: - **Vectors are applied.** The vectors of the compaction candidates are read with iceberg-go's `table/dv` (length, magic and CRC checked, and the decoded cardinality checked against the manifest's `record_count`) and joined with the Parquet position deletes the merge already applies. A vector that does not decode keeps its file out of every bin, as before, so a file never merges without its deletes. One Puffin file is read once per run even when it holds several vectors. - **A consumed vector leaves with its data file.** When the snapshot removes a data file, the delete manifests holding its vector are rewritten (that vector `DELETED`, the other entries `EXISTING`); manifests without one are carried as they are. Vectors are matched by the data file they cover, never by the Puffin file path, because one Puffin file may hold the vectors of several data files (Spark writes them that way) and the vectors of files left in place must stay. - **A bin whose deletes leave no row writes no empty file**; its files are just removed. - **New setting `delete_ratio_threshold_percent`** (default 0 = off, so bin selection is unchanged unless set; Iceberg's own `rewrite_data_files` uses 30%). When set, a Parquet file whose vector deletes at least that share of its rows is rewritten in a bin of its own, whatever `min_input_files` says, packed by live bytes up to the target size. A file whose decoded vector deletes exactly positions 0..n-1 is dropped without being read; a manifest count that says "all" with positions that do not is rewritten row by row instead. Only files under the target file size are taken (the merge reads a file whole into memory), except a file dropped unread. - **Detection reads no vector**: a DV's `record_count` is its cardinality, which is all the ratio needs. With `apply_deletes` off, planning ignores vectors (execution skips tables with deletes then). The planning-index cache key includes the ratio. Tests (`deletion_vector_test.go`): - a vector with a lowercase `puffin` format is matched to its data file under either path spelling; - a merge with a vector and a Parquet position delete: every file merges minus its deleted rows, row ids kept, and the delete files leave the table (ratio off); - a reloaded table: the wholly deleted file and its vector are dropped without the file being read (it is not even present), the new file untouched; - ratio past / under / vector not decodable / manifest count says all but positions do not / partly deleted file past the target size left alone; - two vectors in one Puffin file, only one data file compacted: the other file's vector stays; - detection with the ratio on and off. Each was checked red against a mutation of the rule it covers (exact format compare, vectors not applied, vector consumed by Puffin path, size check skipped, whole-file check skipped). `go vet ./weed/worker/tasks/iceberg` and `go test ./weed/worker/tasks/iceberg` pass; `go build ./weed` builds. * iceberg compact: check a deletion vector's blob range without overflow Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg detection: key the cached compaction plan on apply_deletes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg detection: skip a table with deletes while apply_deletes is off Execution already skips it, so detection proposed a job that never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: a drop-only bin is not held to the sort input cap Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: split delete-heavy bins at the sort input cap The packer counted live bytes only, so two partly deleted files could share a bin the sort input cap then dropped on every run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: compare the delete ratio in whole rows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: merge delete-heavy files in the order of their bounds Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: read only the vectors of files a bin can take Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg compact: pack a vector whose count and positions disagree by its whole size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
347f1cf705 |
deps: bump parquet-go to v0.33.0 (#13130)
* deps: bump parquet-go to v0.33.0
parquet-go v0.33.0 fixes several bugs that Iceberg compaction runs into:
- BOOLEAN columns that Arrow and parquet-mr write with data page v2 are
RLE-encoded. v0.32.0 decoded such runs wrong (a run's value byte expanded
bit by bit, runs taken as multiples of 8 values), so compaction rewrote the
flags wrong, and it wrote its own runs of trues with the value byte 0xFF,
which DuckDB refuses to read ("Payload value bigger than allowed")
(parquet-go/parquet-go#617, fixed by parquet-go/parquet-go#620).
- A column chunk without a dictionary lists the level encoding RLE next to
PLAIN. v0.32.0 took RLE as the column's encoding, so the schema derived from
a non-dictionary INT32 or DATE file could not write ("RLE: cannot encode
INT32 with invalid bit-width=0") and such files never compacted
(parquet-go/parquet-go#603, fixed by parquet-go/parquet-go#611).
- The sorting writer dropped the row groups' geospatial statistics when a
bin fit in its sort buffer, so a sorted rewrite of a geometry table wrote
files without a geometry bound (parquet-go/parquet-go#627, fixed by parquet-go/parquet-go#693 and parquet-go/parquet-go#700).
- A null in a list of required values wrote no value and shifted the rest of
the page (parquet-go/parquet-go#616, fixed by parquet-go/parquet-go#618); a short data page read leftover
values from a pooled buffer instead of failing (parquet-go/parquet-go#624, fixed by
parquet-go/parquet-go#731).
- A geometry or geography column declared without a CRS is now written
without one rather than with OGC:CRS84 spelled out (parquet-go/parquet-go#628, fixed
by parquet-go/parquet-go#688).
Changes that follow from the bump:
- A corrupt data page now fails with an error rather than a panic. The
position and equality delete readers returned that error without the file
name; they now name the file, as the data file merge already does.
- The default-CRS tests built their "spelled out" inputs with
parquet.Geometry(""), which now writes no CRS; they declare OGC:CRS84
explicitly. The footer rewrite in geometry_crs.go is still needed when an
input spells the default out, since the output schema comes from an input.
Tests:
- compact_rle_boolean_test.go with four pyarrow fixtures: two files with
v2-page RLE booleans (with nulls) read back and compacted with every flag
kept, and two non-dictionary INT32/DATE files compacted with every value
kept. All three tests fail on v0.32.0 (3005 of 6000 flags wrong; "no bins
successfully compacted").
- TestCompactSortedGeometryBoundCoversEveryRow only checked a bound when
there was one, so it passed with the statistics dropped. It now requires a
geometry bound on the data file and geometry statistics in the footer; it
fails on v0.32.0 and passes on v0.33.0.
- go vet and go test of every package that imports parquet-go
(weed/admin/dash, weed/mq/logstore, weed/mq/schema, weed/query/engine,
weed/worker/tasks/iceberg) pass; -race on weed/worker/tasks/iceberg and
weed/mq/logstore passes; go build ./weed passes.
* iceberg: fail the Arrow fixture tests on a read error
Both row-reading loops ended on any error, so rows decoded next to an
error could still pass the value checks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg: check each fixture row comes out of compaction exactly once
A row replaced by a copy of another kept the row count and passed the
value checks, which use the row's own id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
5017a07475 |
iceberg maintenance: whole-pass tests of equality deletes on a partitioned table (#13132)
* iceberg maintenance: whole-pass tests of equality deletes on a partitioned table The equality-delete tests call the pieces (`collectEqualityDeletes`, `eqDeleteGroupsForBin`, `mergeParquetFiles`) one at a time. These run `compactDataFiles` end to end and check what a reader sees after the commit, including the deletes carried for files left uncompacted and the sequence numbers of the merged files. Tests only; no code changes. The table has three partition specs: 0 unpartitioned, and 1 and 2 both `identity(name)` on the same partition field, so only the spec ID tells their deletes apart. It is written as a writer commits it: one snapshot per data sequence number, its manifests carrying the number and their ADDED entries inheriting it. Its equality deletes come in every scope: partition-scoped, global, by another column, and with keys that live in other partitions or specs. Each test reads the table before and after the pass with its own merge-on-read (each delete applies to data files with a lower data sequence number, under an unpartitioned spec or the same spec and partition) and compares the rows. - Every two-file bin compacts, bin-packed and sorted; one partition's single file does not. The live rows are unchanged and the deletes are carried for the file left as it was (a merged file given an input's lower sequence number would lose rows to the carried deletes). - Every file compacts: the rows are unchanged and the deletes leave the table. - An unreadable partition delete fails the pass, names the file, and commits nothing; once the file is back the table reads as before. - A delete under a spec the table does not list fails the pass and commits nothing. Checked red against a mutation of the sequence-number rule (equality deletes applied whatever the sequence numbers): the first two tests fail. `go vet` and `go test ./weed/worker/tasks/iceberg` pass. * iceberg maintenance: whole-pass table snapshot IDs differ from its sequence numbers The fixture gave each commit's snapshot the ID of its data sequence number, so a compaction that read an entry's snapshot ID in place of its sequence number still kept the right rows. The IDs now count down as the sequence numbers count up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg maintenance: a whole-pass name-keyed delete that removes a live row The only name-keyed delete matched no row, so a pass that ignored deletes keyed by name still kept the right rows. u1 now holds a "zz" row that a global name-keyed delete removes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |