mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
a16ca18ae083d50bf03c8865262ca20f2ce2e8ff
16762
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a16ca18ae0 |
kms/local: load master keys from the provider config (#13312)
* kms/local: load master keys from the provider config The local provider generated its master keys in memory, so a restart or a reload lost them, and with them every object they encrypted. It now reads a keys list from its config. Each entry has a key_id, 32 bytes of key_material in hex or base64, and optional aliases and description. A reload reads the list again, so objects encrypted under a listed key stay readable. A name that's already taken, key material that isn't 32 bytes, or enableOnDemandCreate together with keys fails the provider, and the keys it loaded before the error are cleared. No default key is generated when keys are listed, since whatever it wrapped would be lost on a restart. CreateKey and CreateKeyWithID refuse a name that's taken instead of replacing that key. GetStringMap copies a list of tables like the other nested values it hands out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms/local: give a racing on-demand request the key the first one created CreateKeyWithID refuses a key ID that's taken now, and the on-demand path looked the key up and created it under separate locks. Two requests for the same new key could both miss it, and the second then failed with KMSInternalFailure. The on-demand path checks for the key under the lock it stores it with, and returns the one stored in the meantime, so the first request's data key stays readable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms/local: serve requests that name no key with the configured aws/s3 key With keys configured there is no generated default key, so an SSE-KMS request without a key ID failed even when the bucket-default path (which already resolves to alias/aws/s3) would work. Resolve an empty key ID to alias/aws/s3, as AWS does, so an operator picks the default by giving a configured key that alias instead of a new setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms/local: refuse a master key that Close cleared mid-request A reload replaces the provider and closes the old one, which zeroes its key material in place. A request that looked up a key before the close could then build its cipher from zeros and store a data key no provider can unwrap. Build the cipher under the provider lock and refuse a key that is no longer registered. 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> |
||
|
|
2938037cae |
filer: end a subscriber's stall when memory serves its cursor (#13310)
* filer: end a subscriber's stall when memory serves its cursor
A metadata subscriber that finds nothing in the ring yet parks until data
arrives ("no readable in-memory entries yet"), which starts its stall
clock. When data arrives the ring serves the cursor and the read goes on,
but nothing stopped the clock: only the paths that leave a gap do.
The clock is what bounds the wait on a gap. With it still running from
that first park, the first real gap the subscriber meets, hours later,
looks older than maxGapStall the moment it parks: the park gives up at
once and skips to the eviction watermark, and the events a peer would have
flushed within the flush interval are never delivered. The log shows a
subscriber "parked" for hours at a cursor a few seconds old, and the gap
skipped in the same millisecond. A mount keeps the stale listing it has
for those events, and filer.sync loses them.
resolve now ends the stall when it sends the read to memory.
* filer: age the first stall in the memory-serves test instead of shrinking maxGapStall
With maxGapStall at 50ms, a scheduler pause between the fresh park and its
give-up check expired the new stall and failed the test against the fixed
code. Keep the real bound and backdate the first park's clock.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: shorten the comment on ending the stall in resolve
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
||
|
|
c7ba8bd079 |
sftp: give user store accounts without a Uid a non-root id (#13309)
* sftp: give user store accounts without a Uid a non-root id An entry that leaves out Uid decoded to 0, and Uid 0 skips every Permissions check, so a read-only account could write and delete. Generate a regular id for it the way NewUser does, and default an omitted Gid to the Uid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: test that an omitted Uid or Gid does not load as root Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: keep the default Uid of an account stable across loads Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: test that a default Uid survives Reload and a new store Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: keep a default Uid off the ids other accounts use Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: test that a default Uid skips ids other accounts use Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: refuse a user store with no free id for an omitted Uid When every id in the default range is taken, loadUsers now fails instead of reusing a taken id, and it fails before replacing the loaded users so a Reload keeps the previous accounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: test that a full id range rejects the store and keeps old users Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b445228794 |
volume: read the fields it knows from a .vif a later version wrote (#13305)
* volume: read the fields it knows from a .vif a later version wrote The .vif is parsed as strict JSON, so one field this version does not know fails the whole file. The volume server only logs that and serves the volume with an empty VolumeInfo: a read-only mark is gone, and so is the remote file of a tiered volume. Every field added to VolumeInfo makes the .vif files written from then on unreadable to the versions before it, which is what a rollback runs into. When neither the strict parse nor the old format's reads the file, it is now parsed once more with unknown fields ignored. The fields this version knows apply, and a warning names the file. The old format is still tried first, since read this way it would lose its DestroyTime, and a file that is not a VolumeInfo is still an error. * volume(rs): read an old-format .vif before the current format VifVolumeInfo ignores fields it does not know, so an old-format .vif parsed as it too: its DestroyTime and BytesOffset were dropped and the old-format fallback never ran. The Go server tries the old format before reading a file with unknown fields ignored, which keeps the destroy time. The old format is now taken only when every field in the file is one of its own, and a file that is not old-format reads as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d05cb0d308 |
volume: keep the largest needle id of a leveldb-indexed volume through a vacuum (#13306)
* volume: keep the largest needle id of a leveldb-indexed volume through a vacuum The index a vacuum builds for a volume with a leveldb needle map is loaded by LevelDbNeedleMap.DoOffsetLoading, which counted the files and tracked the end of the data but not the largest needle id, as the in-memory map's loader does. After the commit the volume reported 0 as its largest id until a needle with a larger one was written, and after each vacuum again. The volume server sends the largest id over its volumes in every heartbeat, and the master keeps its id sequence above it. A server whose largest ids sit in volumes that were vacuumed since they were last written reported too small a value, which is all the master has to go by when its own sequence is behind. * volume: test the largest needle id when nothing lands during the vacuum Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d0b431b192 |
filer: pace the deletion ledger's snapshots to a byte budget (#13301)
* filer: pace the deletion ledger's snapshots to a byte budget The durable deletion ledger is written as a snapshot of the whole pending set, and the snapshotter is woken by every queued and every finished delete. A filer deleting a hundred chunks a second rewrote the set a hundred times a second, close to 4KB written to the store per deleted chunk. The cost of each snapshot is the size of the set, so a filer that holds deletes it cannot finish yet, the ones it retries, rewrote that whole backlog on every other change as fast as the store took it. A snapshot is now followed by a pause in proportion to the bytes it wrote (filer.deleteQueue.persistBytesPerSecond, 64KiB a second by default, and 4KiB charged per snapshot), never longer than the periodic interval. The first change after a quiet spell is still written at once; the changes made during the pause go into the next snapshot. A crash therefore loses the ids queued since the last write instead of those of the write in flight. * filer: fix the deletion ledger's write budget instead of a config key The pacing needs no operator knob: 64KiB a second keeps a large backlog's snapshots at the periodic interval and a small ledger's at a few a second. The snapshotter reads the budget and the interval once when it starts, so a test that pins the budget does not race a running snapshotter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
75ba2b125c |
filer: count the store's KV requests in the store metrics (#13302)
* filer: count the store's KV requests in the store metrics FilerStoreWrapper counts and times InsertEntry, UpdateEntry, FindEntry, DeleteEntry and the listings, but passed KvPut, KvGet, KvBatchGet and KvDelete straight to the store. Hard link records, the deletion ledger and the per-path commit records are all kept in KV, so that part of what a filer asks of its store did not show in SeaweedFS_filerStore_request_total or in the request duration histogram. The four KV calls are now counted and timed like the others, as kvPut, kvGet, kvBatchGet and kvDelete. * filer: shorten the KV metrics helper comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5c36ee70ee |
master: sign a LookupVolume token for the file id asked for (#13300)
* master: sign a LookupVolume token for the file id asked for LookupVolume signed the token with the bare volume id, and the volume server checks the token's fid against vid,key, so every token it handed out was refused. /dir/lookup signs the file id. operation.LookupJwt goes through LookupVolume, so the expired-token renewals of the S3 PutObject and copy cleanup deletes, the admin file browser and weed benchmark all got a token the volume server refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: sign lookup tokens for the base file id The volume server checks a token's fid against the file id with its _<delta> suffix stripped, so a token minted for vid,key_N, over gRPC or /dir/lookup, was refused. Sign baseFid of the file id in both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
dc15685282 |
filer: rename a postgres_flat scan test bucket codespell flags (#13314)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ae99aae2cb |
mq: report the caller's deadline when a broker sees it first (#13303)
* mq: report the caller's deadline when a broker sees it first doConfigureTopic checked ctx.Err() to tell the caller's deadline from a broker failure. A broker's DeadlineExceeded status (or its RST_STREAM, which gRPC maps to DeadlineExceeded once the deadline has passed) can arrive before the context's own timer has run, so ctx.Err() was still nil and NewTopicPublisher returned the wrapped gRPC error instead of context.DeadlineExceeded. Once the deadline is behind us, wait for the context's timer before reading ctx.Err(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: let the configure call start before its deadline passes in the test The deadline the test reported had already passed when NewTopicPublisher started, so the check before the first broker caught it and the check after the call was never exercised. The fake broker now moves the deadline behind us only once it has the call, and answers with its own DeadlineExceeded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f599f870a8 |
s3: list without a delimiter from one range of the filer store (#13263)
* s3: -s3.listRecursiveFromStore, on by default Lets an operator keep recursive listings on the directory walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3: list without a delimiter from one range of the filer store A bucket that never had versioning is listed with ListEntriesRecursive: one read of the bucket's path range per page instead of one directory listing per directory. A folder object's "<dir>/" key waits for its place in key order, and the folder objects whose rows sort before the range (the one the prefix names, those the marker ends inside of) are looked up. .uploads is skipped; a .versions folder hands the page to the walk, as does a filer that answers Unimplemented, which is then not asked again for a minute. The test pages through both ways over the same tree, for prefixes, markers and page sizes, and expects the same keys, sizes, ETags and markers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/postgres_flat: a range-read gateway lists what the walking one does A second S3 gateway with -listRecursiveFromStore=false runs on the same filer. ListObjectsV2 and V1 pages agree for prefixes, markers and page sizes over folder objects, a prefix object, an unfinished upload and +/-/0 neighbours. Listing 60 keys five directories deep scans the bucket table 2 times from the range read and 302 times from the walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * s3: range-read listings without the -s3.listRecursiveFromStore flag A filer whose store cannot list a range answers Unimplemented and the gateway already walks that bucket's directories instead, so the flag only switched off a path that falls back by itself. The unit test forces the walk through the decline cache, and the postgres_flat test checks pages against the keys in byte order rather than against a second gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: step a range-read listing over the bucket's upload parts The walk skips the bucket's .uploads folder as one entry, but a range read from the bucket root streamed every part of every unfinished upload and dropped them, one 1024-row window after another, on each first page. Every path under .uploads/ sorts before ".uploads0", so the read resumes there and looks up the one key with that name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: list a waiting folder object once a row passes its key A range-read page queued every childless folder object until a file row arrived, so max-keys=1 over a bucket of empty folders read the whole bucket before answering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: forget a deleted bucket's recursive-listing decline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
77a070fe0a |
s3api: tell a symlink apart from an empty object on GET and HEAD (#13299)
A symlink made through weed mount holds no data, so GET and HEAD answered for it as for an empty file: Content-Length 0 and a type guessed from its name. An S3 client could not tell it from an empty file, nor see where it pointed. For an entry with the symlink mode bit, send the target as user metadata, x-amz-meta-seaweedfs-symlink-target, escaped like a key under encoding-type=url, and use Content-Type inode/symlink (what file(1) reports) when none is stored. User metadata is the one place AWS has for an object's own fields, so SDKs and the AWS CLI show it as they are. The link is not followed: the target is a path on the client that made it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
acb7728915 |
filer: ListEntriesRecursive RPC (#13262)
* filer: name the check that a listing expires an entry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: StreamListRecursiveEntries lists a subtree in path order It pages through the store's RecursiveLister until the limit, leaves out and deletes expired entries as a directory listing does, and declines a subtree in or holding a remote mount. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer.proto: ListEntriesRecursive A new RPC rather than a field on ListEntries: a filer that predates it answers Unimplemented instead of listing one directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: serve ListEntriesRecursive Unimplemented when the store cannot list the subtree in path order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: a scoped token is refused ListEntriesRecursive Classified with TraverseBfsMetadata: it lists a whole subtree, past the per-directory checks a scoped ListEntries gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: trim a trailing slash before checking a recursive listing for remote mounts An empty directory lists from the root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep the recursive listing cursor when a page comes back empty Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a9d4714aed |
s3api, filer: keep a symlink a symlink when CopyObject copies it (#13298)
* s3api, filer: keep a symlink a symlink when CopyObject copies it A symlink made through weed mount is an entry with the symlink mode bit, a SymlinkTarget and no data. CopyObject builds the destination's attributes afresh, with the permission bits from the request, so a copy to another key dropped both and landed as an empty regular file. A metadata-only self-copy (REPLACE) kept the target but reset the mode, leaving the link an empty regular file in place. Keep the symlink mode bit and the target on both paths. The permission bits still come from the request, as for any other copy. The filer's own copy (copyEntry) already carries the source's whole attribute set. A copy into a new prefix creates the symlink in a missing directory, and the filer gave each parent it created the entry's whole mode plus ModeDir. With the symlink bit as well, a mount shows those directories as regular files, and nothing under them can be reached. Parents now take the entry's permission bits only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: drop the symlink type when promoting an entry to a directory A key nested under a symlink promotes the symlink's entry to a directory. The promotion added ModeDir and kept the symlink bit, so a mount showed the directory as a regular file and could not reach the nested key. Keep only the permission bits there too, with the same restorableModeBits a missing parent now takes from its entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep a self-copied prefix object a directory when it was a symlink A prefix object promoted from a symlink before the filer change still has the symlink bit. A routed self-copy of it restored ModeDir and then keepSymlink added the symlink bit back, leaving a directory a mount shows as a regular file. keepSymlink now leaves directory destinations alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: a prefix object keeps no type bit but the directory's MarkPrefixObject added ModeDir and the execute bits to whatever mode the object had. A symlink copied onto a key that other keys are nested under, or a self-copy outside the owner route of a prefix object promoted from a symlink before the filer change, kept the symlink bit next to ModeDir, which a mount shows as a regular file. Clear the other type bits first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
85b783cc0d |
s3api: copy a chunk to another volume when its volume fails the write (#13297)
* s3api: copy a chunk to another volume when its volume fails the write CopyObject and UploadPartCopy assigned one volume to each copied chunk and failed the whole copy when that volume failed the write: a streamed copy sent a single POST, and a buffered copy retried only the same fid. PutObject asks for a fresh assignment instead (upload_chunked.go), so a volume that filled up, went away or was overloaded failed a copy that a PUT would have survived. In production, a CopyObject failed with 500 because the destination volume server broke the connection mid-upload, and only the client's retry completed it. Every chunk copy now writes through uploadCopiedChunk: streamed, buffered, range, and the five SSE re-encryption paths. When a volume fails the write in a way another volume would not, the copy deletes whatever the failed write may have stored, asks for another volume and writes the chunk again, as PutObject does: up to three volumes, and only one more after an overload. The uploader's errors are judged by operation.ShouldReassignUpload, and a streamed POST by its status (no response, a 5xx, or an overload refusal). A streamed retry reads the source again, and a range copy digests only the bytes of the attempt that landed. A failed source read is not retried on another volume: a streamed copy now records the source's read error apart from the POST's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: delete a failed copy chunk only when its write reached the volume A streamed copy reads its source inside the write, so a source that could not be read also came back through uploadCopiedChunk, which then deleted a fid nothing had been written to. Only a failure of the volume itself (copyUploadError) is followed by the delete now; the tests check that a source failure sends none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: reassign copy writes refused before the append, bound the cleanup A streamed copy's POST dropped the volume's X-Seaweed-Write-Outcome header, so a 409 from a volume that turned read-only before the append, or a 401 for a token that expired in the queue, failed the copy where the uploader's ShouldReassignUpload tries another volume. The POST now keeps the header and reassigns on the same marked answers; unmarked 409 and 401 stay final. The delete of a failed chunk read its answer with no deadline, so a volume that sent the headers and stalled the body held the copy up for good. Each delete now runs within copyCleanupTimeout (10s), its answer included, and still logs the status and up to 4 KiB of the body. Tests: the fake volume keeps the file it was sent, and each retry case checks that the second volume stored the copied bytes. An SSE-C chunk copied under a new key decrypts with the key and IV its chunk names. Marked 409 and 401 answers reassign, unmarked ones do not, and a stalled cleanup delays the copy by the timeout only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: renew an expired token for a failed copy chunk's delete A copy's write token is minted at the assignment, before the source is read, and lasts 10s by default. A write that failed after that left the cleanup delete refused with 401 and the needle orphaned. PutObject's cleanup renews the token from the master on a 401; do the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: log the status and body of a cleanup delete whose read failed A delete whose answer began but whose body read failed, such as one cut off by copyCleanupTimeout, was logged with the error only. Log its status and the part of the body that arrived as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
38422bd1fa |
filer: RecursiveLister, a subtree in path order from one range of postgres_flat (#13261)
* filer: RecursiveLister, a store capability to list a subtree in path order The wrapper hands it to the default store, reading hard links as listings do, and declines it when path-specific stores could hold part of the subtree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: list a subtree with one range scan when rows are keyed by path AbstractSqlStore lists recursively when its generator implements RecursiveListSqlGenerator. The range runs from the directory and prefix to the least string past every path starting with them. A directory whose subtree spans the bucket tables is declined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: the postgres_flat generator lists a path range Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/store_test: check recursive listings Byte order across +, -, / and non-ASCII names, prefixes holding a slash, literal % and _, resuming after a path, pages of one and three, a directory outside the buckets, and the directories that span bucket tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: a recursive listing's start path outside the bucket table bounds it by full path A start path in another bucket was trimmed as if it were inside this one, so a start path past the bucket listed it all again, and one before it could skip entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b7536bd6f6 |
test: S3, versioning and FUSE integration tests for the postgres_flat filer store (#13255)
* test/postgres_flat: S3 against a filer on the postgres_flat store A weed mini whose filer.toml enables postgres_flat in a schema of its own. Objects, listings, copies, multipart uploads, versions and bucket deletion are checked through S3 and against the rows of the bucket's table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/postgres_flat: a FUSE mount against the postgres_flat store Files, a directory longer than a listing page, renames, hard and symbolic links, tree removal and a bucket made through the mount, checked against the rows, then read back by a second mount with an empty metadata cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: run the postgres_flat S3 and FUSE tests against Postgres Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: run the postgres_flat tests on pull requests to any branch Like the S3 workflows, so a stacked pull request runs them too, and only when the code they reach changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/postgres_flat: fail fast when weed mini or the mount exits ProcessState is only set by Wait, which ran only at cleanup, so a mini or mount that died at startup was noticed only at the 45s or 90s deadline. Reap each command as it starts and check for its exit while waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: run the postgres_flat tests on changes anywhere under weed/ The tests run master, volume, filer, S3 and a mount, so changes in packages such as weed/pb, weed/wdclient or weed/credential reach them too. Match the FUSE integration workflow and also trigger on the fusermount action the job uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test/postgres_flat: versioned buckets on the postgres_flat store Versions and delete markers are rows under the key's .versions folder in the bucket's table. Covers version listings in one page and one version a page, delete markers, promoting the previous version, the null version under suspended versioning, and dropping the table once every version and the bucket are deleted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: run the S3 versioning suite on a postgres_flat filer The whole test/s3/versioning suite, stress tests included, against a weed mini whose filer.toml enables postgres_flat. The job first checks that filemeta has the flat layout, so a filer on its default store cannot pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * test/postgres_flat: set up shared objects before the subtests The S3 and versioning suites wrote their objects and the second bucket inside the first subtest, so running one later subtest with -run left the version ids empty and panicked. The parent test now writes them and the subtests only check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test/postgres_flat: helpers fail the test that calls them paths, tableExists, count, filerList, start and mount take the caller's *testing.T, so a failure inside a subtest fails that subtest instead of calling FailNow on the parent and stopping its siblings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: wait for the filemeta table before the versioning suite Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test/postgres_flat: POSIX subtests set up their own fixtures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test/postgres_flat: absent versions must answer 404 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b5a7d9600e |
kms: read provider settings as TOML gives them (#13294)
* kms: read provider settings as TOML gives them Provider settings were read with plain type assertions, so a setting of another type read as its zero value. TOML decodes integers as int64, which GetInt ignored, so max_cache_size from filer.toml never applied, and Viper lowercases TOML keys, so the local provider never saw enableOnDemandCreate. A cache_ttl that didn't parse fell back to an hour without a word. Settings are now read through one typed getter. An int64 or a whole float64 reads as an int, a key matches ignoring case when it isn't found as given, and a provider that reads a setting of the wrong type fails to load and is closed. The loader reads the cache settings the same way and fails a provider whose cache settings don't parse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: apply the cache defaults to a setting given as null A JSON null for cache_enabled or cache_ttl counted as set, so it turned caching off or failed the provider on an empty duration, where it used to read as the default. 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> |
||
|
|
ed177d31e3 |
kms: run provider health checks without the manager's lock (#13295)
* kms: run provider health checks without the manager's lock GetKMSHealth held the manager's read lock while it asked every provider for a key, and a remote KMS can take its whole timeout to answer. A provider change waited behind it for the write lock, and every request looking up a provider then waited behind the change. The checks now run on a copy of the providers. SetDefaultKMSProvider and SetBucketKMSProvider check that the provider exists and set it under one lock, so a provider removed in between can't be left as the default or as a bucket's provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: health-check only the provider a load adds Loading a provider checked every provider loaded so far, so a configuration with N providers made N(N+1)/2 remote calls at startup, and one slow provider could spend the shared 10s budget and get the new provider reported unhealthy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * kms: run provider health checks concurrently The checks shared one deadline and ran one after another, so a provider stuck until the deadline got every provider checked after it reported unhealthy, and startup waited for the checks in turn. 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> |
||
|
|
acff807879 |
filer: postgres_flat store keyed by the full path (#13253)
* filer/store_test: conformance suite for filer stores Entries in and out of buckets, byte-ordered and prefixed listings, key-value records, transactions, bucket tables and the snapshot scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: run postgres2 and mysql2 through the conformance suite RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS does the Redis stores; each test gets a schema or database of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: give the go test job Postgres and MySQL services Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of row statements Insert, update, find and delete now take the row key and return their arguments with the query, so a generator decides how a key maps to its columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of directory statements Listing and deleting a directory's children take the directory and return their arguments with the query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: batch lookup takes row keys and matches rows by name and directory A key-value key's directory column already determines its dirhash, so the batch read no longer selects dirhash to match its rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: build the connection string with pgxutil.BuildDSN The credential store already does; it quotes values per libpq, so a password or certificate path with spaces or quotes no longer breaks the connection string. The OpenPGXDB alias has no callers left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: scan pages take the row key of the last row as their cursor Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: postgres and postgres2 share their connection setup ReadConnection reads the settings and their defaults, Connection.Open opens the store's pools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: key-value records may live in a table of their own A store whose entry tables have another layout keeps its key-value records in KvTable, written by KvSqlGenerator; its scans then read only entries and need not tell the records apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: SQL generator keyed by the full path Rows have path as their primary key; a (directory, name) unique constraint serves the directory listings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: postgres_flat store Entries are keyed by their full path, the object key inside a bucket's table; buckets get tables of their own as in postgres2. Key-value records keep the postgres2 layout in filemeta_kv. The store refuses a filemeta table of another layout, so it needs a schema of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: register postgres_flat and add it to the filer.toml scaffold Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: test the arguments each generator binds Each statement's arguments must match its placeholders in count and column. Check them for every generator method, including the Postgres UPDATE whose parameters are now numbered key first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: name a missing filemeta table instead of a foreign layout With createTable = false and no filemeta table, the layout check said the table had no path column and blamed a postgres2 layout. Report the missing table and the key-value table that also has to be created. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres: postgres_flat escapes the table name inside its quotes A double quote in it is doubled, as PostgreSQL reads a quoted identifier. Bucket names cannot hold one, but the statements no longer rely on that. Reported by CodeQL (go/unsafe-quoting). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: escape the table name inside its quotes A double quote in it is doubled, as PostgreSQL reads a quoted identifier. Bucket names cannot hold one; the statements no longer rely on that. Reported by CodeQL (go/unsafe-quoting) on the lines this branch changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: postgres_flat shares the generator's tableIdent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: keep the nameExpr doc comment on nameExpr Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: find filemeta along the search path when checking its layout The store's queries name filemeta unqualified, so with schema = "a,b" they reach a table in b; the layout check looked in current_schema() only and refused it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres_flat: force byte order when the path column is locale-ordered Directory listings order and bound rows by path, but only the name column's collation was checked. A createTable with a locale-ordered path column listed in locale order, and byte-order bounds missed entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres: read the ordered columns' collation along the search path The collation check looked for filemeta in current_schema() only. With the tables in a later schema of the search path it found no column and took the database's order, so a locale-ordered path column next to a C database went unforced, and byte-ordered columns in a locale database got a needless sort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres_flat: list a directory from its path range A directory's children are the rows of its path range whose directory is the listed one. The listing reads that range in growing batches and skips the rows of the children's subtrees in Go, so a versioned object's .versions rows cost no query of their own. Past 64 rows of one subtree it queries again from that subtree's end. A name prefix narrows the range. Listing no longer reads the (directory, name) index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: find a folder's children in its path range Deleting a folder's children looked them up by directory alone, which only the (directory, name) index serves. Bound the delete by the folder's path range as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: key the table by path alone Listing and deleting a folder's children both read the path range now, so the (directory, name) unique index only cost writes and storage: flatPath already makes the path unique per (directory, name). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres: read the ICU or builtin database locale before datcollate An ICU-default database can report datcollate 'C' while its default collation orders by the ICU locale, so a name column on the database default looked byte-ordered and the listing kept locale order. Read datlocprovider and the provider locale (via to_jsonb, so servers before Postgres 15 still answer) and treat an ICU default as locale-ordered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: list a folder's children from its path range The bucket enumeration listed /buckets by directory and ordered by name, a sequential scan and sort now that path is the only index. Read the folder's path range in path order instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres_flat: only the path column needs byte order Listings now order and range by path alone, and directory and name are only compared for equality, which no deterministic collation changes. Drop their COLLATE "C" and check only the path column's order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ce7b6c93b2 |
filer: read the views of the chunk a boundary read leaves in one goroutine (#13293)
A read across a chunk boundary started a goroutine for each view of the chunk the stream leaves, outside the limit on chunks read at once, so a compressed chunk written over in many places could start any number of them. One goroutine started before the others now reads those views one after another, and the other views are back under the errgroup limit. It reads every view from the held download before a view the download can't serve falls back to a read of its own, as that read can make room and evicting the chunk waits for the holds. The test of a boundary read that doesn't wait for the chunk it leaves now has four times as many views of that chunk as chunks run at once, and checks that the read starts fewer goroutines than that. The waits for a prefetch to reserve and for a boundary read to fetch its last chunk are bounded, so a failing test reports instead of hanging. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
411ab1d920 |
worker(rs): refuse short JWT keys under fips.mode strict (#13284)
* worker(rs): refuse short JWT keys under fips.mode strict weed-worker, weed-vector and weed-vector-cli now check the JWT keys of the security.toml they read, as every Go process does: under fips.mode strict each exits at startup naming every key shorter than the 14 characters FIPS 140 needs for HMAC keys, with the rule and messages of seaweed_common::jwt_keys (#13206); outside strict mode each such key but a previous_key gets a warning. A filer signing key given on the command line (--filer-signing-key, WEED_FILER_SIGNING_KEY) is checked the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * worker(rs): warn about a short signing key flag outside strict mode A filer signing key given by --filer-signing-key or WEED_FILER_SIGNING_KEY was checked only under fips.mode strict; outside it, a key strict mode would refuse now gets the warning a short key in security.toml gets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: start the worker binaries with short keys under fips.mode strict Integration tests start the built weed-worker, weed-vector and weed-vector-cli under WEED_FIPS_MODE=strict with a 10-byte key in security.toml, or a short --filer-signing-key, and check that each exits naming the key. They run in the existing cargo test jobs and need no cluster: the check comes before the binaries dial anything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6a67fe503e |
vacuum: compact copies held read-only by a readonlyCanDelete mark (#13283)
* vacuum: compact copies held read-only by a readonlyCanDelete mark A volume marked with volume.mark -readonlyCanDelete takes no new writes but keeps taking deletes, so it can drain instead of holding a volume slot (#10688). The automatic vacuum never reclaims those deletes: it skips every read-only copy unless low disk space is the only cause, and a mark clears that exception (#11519). The space comes back only once the last needle is deleted (deleteEmpty) or through volume.vacuum -volumeId, one volume at a time, so a volume that never drains completely keeps its garbage. VacuumVolumeCheck now also reports can_delete_mark: the copy is read-only through a readonlyCanDelete mark and nothing that refuses deletes (no plain read-only mark, no I/O quarantine, not tiered to remote storage). The sweep compacts such a copy like a writable one, except when the master pushed the mark itself to quarantine a duplicate volume id. The mark survives the compaction, so the copy stays read-only, keeps taking deletes and stays out of the writables. A read-only volume reserves no headroom, so the space it gives back becomes free volume slots. The Rust volume server reports the same field. In volume.vacuum, the help text and the list of read-only volumes the sweep skips leave out copies that still take deletes. For the unnamed collection, which the shell vacuums volume by volume, such volumes are left to the sweep: an explicit request would also compact a quarantined copy. An older volume server does not set the field and an older master ignores it, so a mixed cluster keeps skipping these copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: say which marked volumes volume.vacuum leaves to the sweep For the unnamed collection, volume.vacuum sends one request per volume and skips a volume held by a readonlyCanDelete mark, while the "skipped by the sweep" hint leaves such volumes out because the sweep compacts them. With a filter matching only those volumes, the command returned without a request and without a word. It now lists the marked volumes over the threshold that it leaves to the automatic sweep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: drop the compacted needle map a read-only commit leaves unused CommitCompact reloads a read-only volume into a sorted map, so the compacted map built for the reload is never consumed: it stays in v.tmpNm with every needle of the volume, and with a leveldb index its .cpldb stays on disk. The next compaction reopens that .cpldb as is, so needles deleted between the two compactions come back in the leveldb map with stale offsets once the volume is writable again, and reads of them fail with EOF instead of not found. The sweep now compacts readonlyCanDelete volumes, so this path is no longer limited to an explicit volume.vacuum -volumeId. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * storage: do not tie the canDelete compaction test to random needle sizes newRandomNeedle sizes its data at random, so three deleted needles out of six left under 30% garbage about once in twenty runs and failed the precondition. The test only needs the deletes to leave some garbage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: say the sweep skips quarantined copies in the left-to-sweep note The note named unnamed-collection volumes as left to the automatic sweep, but the sweep skips a copy the master holds for a duplicate volume id under the same mark, and the topology does not show that quarantine. The note now says so. It also describes the copies by what the topology shows, read-only but still taking deletes, since a copy read-only only for low disk space looks the same when its probe fails. 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> |
||
|
|
c96636ecd0 |
filer: fold chunk lists for scoped commits (#13281)
* filer: fold chunk lists for scoped commits A filer serving a keep-only scoped token never folded chunk lists, and refused any new chunk for an entry holding manifests, so scoped clients kept their lists flat. On a store with a value size limit, such as FoundationDB, a scoped file stopped fitting at about 1000 chunks. The filer now folds scoped commits and reuses stored manifests as it does for unscoped ones. Folding runs after the retained-data check, so the only manifests a scoped commit stores are ones the filer wrote: - a scoped request may keep a manifest stored at the target, sent as stored; any other manifest is refused, with or without a proof, and a stored manifest cannot be kept as a data chunk; - the chunks held by the stored manifests count as stored at the target and join the identity map, so they may be retained flat but not under another spelling of their file id; - those chunks are read under the handler's path lock, not at admission; admission still refuses a manifest the target does not store and leaves the checks that depend on the held chunks to the locked check. A manifest that cannot be read refuses the write as Unavailable. An update rechecking inside its store transaction reuses the chunks it already read, so it does no volume I/O there. Appends to a folded entry are allowed under the same rules: an append keeps every stored chunk, and the locked check refuses aliases of the chunks the stored manifests hold. * mount: explain why a scoped mount keeps chunk lists flat A filer serving a scoped token now folds scoped commits itself and keeps only the manifests it wrote. The mount's flat rule is unchanged; only the reason given for it was out of date. * filer: test a scoped truncate through a stored manifest * filer: refuse manifest chunks in a scoped append An append moves each chunk it carries to the end of the file. A manifest cannot be moved that way: the chunks it holds keep their own offsets, so the appended range would read no data and the manifest's bytes would still read at their old place. Before this series a scoped request could carry no manifest at all; now that a scoped commit may keep a stored manifest, an append still takes data chunks only. * filer: read only the stored manifests a scoped commit drops The locked retained-data check read every stored manifest whenever a scoped request had chunks, so each flush of a folded file and each append cost one volume read per manifest under the path lock. The unscoped path reads only the manifests a commit drops. Read the same way for a keep-only scope: only the stored manifests the request does not keep unchanged, and none for an append, which keeps every stored chunk. A kept manifest keeps its chunks referenced, and garbage comparisons match chunk identities, so another spelling of one of its chunks cannot get the needle deleted; such a chunk now needs its own proof like any new chunk. Truncating through a manifest and listing its chunks flat still work, since both drop it. * filer: find the dropped manifests of a scoped commit in one pass Index the manifests the request keeps by file id instead of scanning the request for each stored manifest, which compared and cloned chunks quadratically in the number of manifests. * filer: rewrap the scopeManifestReader comment 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> |
||
|
|
4cb096e32f |
filer, s3: report a failed read as an error, not as a missing entry (#13289)
* filer/mongodb: report a failed read as an error, not as a missing entry FindEntry logged any read error other than ErrNoDocuments and returned filer_pb.ErrNotFound, so a lookup that could not reach MongoDB answered that an existing entry was gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/arangodb: report a failed read as an error, not as a missing entry FindEntry logged any ReadDocument error other than not-found and returned filer_pb.ErrNotFound, so a lookup that could not reach ArangoDB answered that an existing entry was gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/rocksdb: report a failed read as an error, not as a missing entry FindEntry and KvGet checked for a missing value before the read error, and the value is nil after any failed read, so every read error came back as not found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: a versioned read whose lookup fails is not NoSuchKey In a versioned bucket, GetObject, HeadObject and GetObjectAttributes answered NoSuchKey for any error from getLatestObjectVersion, so a filer or store outage told clients that existing objects were gone. They now classify the error the way CopyObject's source lookup does: NoSuchKey only when the object is missing, 503 for transient failures and 500 otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep the cause when the latest version file cannot be read doGetLatestObjectVersion formatted a failed read of the version file the pointer names with %v, so a transient failure there answered 500 instead of 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1f65d9e708 |
s3api: answer GetBucketLocation with a LocationConstraint document (#13292)
GetBucketLocation wrote the CreateBucket request body (CreateBucketConfiguration), so clients that check the root element, such as the AWS Rust SDK, failed with "expected LocationConstraint tag". Reply with an empty LocationConstraint in the S3 namespace, which is what AWS sends for us-east-1 buckets. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
97cac5f5e5 |
test: fix mq tests broken by separately merged changes (#13285)
* mq/logstore: rename the tiered copy of a duplicated test name TestTimeReadWithNothingNewKeepsItsPosition was added in both merged_read_test.go and merged_read_table_test.go by changes that merged separately, so the package's tests stopped compiling. The table-backed one becomes TestTieredTimeReadWithNothingNewKeepsItsPosition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: make the topic table test's control entry a close marker The test's offset 5 had no key but kept its value, which was a control entry before keyless messages became data. Now only an entry with neither key nor value is skipped, so the baseline scanned that message in both partitions and counted 22 rows instead of 20. Offset 5 drops its value too, so it is the close marker the test means. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
13d65deb3a |
filer/tikv: report a failed read as an error, not as a missing entry (#13287)
FindEntry turned every failed read into filer_pb.ErrNotFound, because the value it checks is still nil after any error. While TiKV cannot be reached, or a region has lost its leader, a lookup of an existing entry answers "not found" once the client library gives up its backoff (about 40 s): the S3 gateway returns 404 NoSuchKey to HEAD and CopyObject, weed mount returns ENOENT and the filer HTTP API 404. Writes in the same outage fail with an error, so only reads report the entry as gone. A read that TiKV answers with "not exist" is still a missing entry; any other error is returned to the caller. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
b1f86ddfa2 |
s3: support PutBucketDefaultStorageClass and GetBucketDefaultStorageClass (#13282)
* s3: add PutBucketDefaultStorageClass and GetBucketDefaultStorageClass The setting is kept in the bucket entry's extended attributes next to the other bucket configuration, so every gateway sees it through the bucket config cache. Only STANDARD and INTELLIGENT_TIERING are accepted, matching the AWS model; STANDARD clears the stored value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: give new objects the bucket default storage class PutObject, POST uploads, CreateMultipartUpload and CopyObject store the bucket default when the request names no storage class. The request headers are left alone, so bucket-policy storage-class conditions and the self-copy change check still see only what the client sent. Upload parts are not tagged; a completed upload takes the class recorded when it was initiated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: test the bucket default storage class APIs and write default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: fail a write whose bucket default storage class cannot be read A failed bucket config lookup used to fall back to STANDARD, so a write could store a different class than the bucket default asks for. The write now returns the lookup error instead. A request that names its own class still needs no lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: give extracted ZIP directory members the bucket default storage class Directory members are created through mkdir rather than putToFiler, so they stored no class while the files next to them did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: reject a default storage class body with trailing data The decoder stopped after the first element, so a valid configuration followed by another element or stray bytes was accepted. The body is now read with a size bound and only whitespace, comments or processing instructions may follow the configuration. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * go.mod: bump aws-sdk-go-v2/service/s3 to v1.117.1 The release adds the PutBucketDefaultStorageClass and GetBucketDefaultStorageClass client operations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: test the bucket default storage class through the AWS SDK Covers get/set, an unsupported class, the setting stored in the bucket entry and read back by a fresh bucket config, PUT, explicit classes, multipart initiation, copy, existing objects, and per-API grants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let each default storage class subtest set up its own state Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: assert the explicit STANDARD class exactly in the default class test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: note that the bucket default storage class is a label only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6b402aa87c |
sftp: serve one session on stdin/stdout when run as an OpenSSH Subsystem (#13278)
* sftp: add -stdio to run as an OpenSSH Subsystem
weed sftp -stdio serves one SFTP session on stdin/stdout, so sshd can run it
as its sftp subsystem and handle authentication itself (PAM, SSSD, 2FA,
AllowUsers, Match blocks):
Subsystem sftp /usr/local/bin/weed sftp -stdio -filer=filer:8888
The session belongs to the OS user sshd started it as. With -userStoreFile
that user must be in the store, and its HomeDir and Permissions apply as
over SSH; without one, the session reaches the whole filer, which the
process's filer access allows anyway. The SSH listener options are ignored
and nothing but SFTP is written to stdout.
Checked with OpenSSH's sftp -D: put/ls/rm on the whole filer without a
store; with a store the user is jailed to its home, and a user missing from
the store is refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp -stdio: explain an unreadable user store, test the stream
The session runs as the logged-in OS user, who must read the store; a
store without passwords or keys can be shared with them. Tell that user
why the store is refused instead of a bare permission error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: stdio sessions reuse handleSFTP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: a refused -stdio session exits 1 without printing usage
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp -stdio: give up after 30s when the filer is unreachable
The listener keeps waiting for the filer; a stdio session is one login and
should not hold a process for the whole outage.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp -stdio: bound the filer configuration request by the wait
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftpd: skip the unreadable-store test on Windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* sftp: detect the sshd Subsystem launch instead of a -stdio flag
weed sftp serves one session on stdin/stdout when sshd starts it: SSH_CONNECTION
is set and stdin and stdout are both pipes or sockets. A listener started by
systemd, a container, nohup or a shell has a terminal, /dev/null or a file
there, so it keeps listening.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Denis Maier <denis@dAir.lab>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
|
||
|
|
f88ca328da |
sftp: answer md5sum, sha1sum, df and echo exec requests (#13277)
* sftp: answer md5sum, sha1sum, df and echo exec requests SFTP clients such as rclone verify transfers and show free space by running md5sum/sha1sum/df over an SSH exec request. weed sftp rejected every exec request, so rclone fell back to comparing sizes and could not report usage. Answer the few commands those clients send, without a shell: - echo <text>: prints text (rclone's shell detection) - md5sum/sha1sum [path]: the file's hash in coreutils format, or the empty-input hash without a path (the support probe). The path is resolved inside the user's home and needs read permission. MD5 uses the hash the filer stored when there is one, otherwise the content is read. - df [-k] [path]: the filer's volume capacity in df -k format Anything else fails with exit status 1. Checked with rclone: hashes md5 and sha1 detected, md5sum/sha1sum match local files, `rclone about` works. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: describe exec commands without naming one client Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: exec hashes cover sparse files and stop with the connection - md5sum/sha1sum read a file's whole logical content, with zeros for the holes and tail no chunk stores, through the same sparse-aware stream an in-place SFTP write uses; it ends with the SSH connection - a trailing escaped space stays part of the file name - df checks that the path exists Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: relative exec operands, hashes of holes stop, setstat size clears MD5 - a command's relative path is relative to the home, as over SFTP, so df and the hashes of a root-home user look up the right entry - writes into the hash check the connection, so a large file that is all holes stops too - a size change through SETSTAT drops the stored MD5, which md5sum reports Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: an exec ends when the client closes its channel The command's context ended only with the SSH connection, so a client that closed one exec channel and kept the connection left a hash running. The channel's request stream closes with the channel, which now cancels it. A second exec on the same channel is refused, as OpenSSH does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: a channel runs one exec or one SFTP session With the exec running beside the request loop, a subsystem request after it would have started SFTP on the same channel while the command was still writing to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: refuse a subsystem request without a name instead of panicking The subsystem name was read as Payload[4:], so a request with fewer than four payload bytes panicked the channel goroutine and stopped the server. Decode the name like the exec command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: test that a running exec keeps its channel from starting sftp Also say in handleExec that its context ends with the channel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: df drops -k only as a whole option "df -kfoo" was read as "df foo"; now -kfoo is the path, which fails unless such a file exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Denis Maier <denis@dAir.lab> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
e32f1aa20e |
filer: don't evict a chunk a stream is still reading (#13276)
* filer: don't evict a chunk a stream is still reading The reader cache map and the budget fell back to evicting a chunk a stream was in as soon as they found no idle one, even while a running download held the rest and would become evictable once it finished. The stream then fetched its chunk again. They now evict a pinned chunk only once pinned chunks alone fill the limit or the budget. A budget wait wakes when a stream enters or leaves a chunk, and when a pinned download reserves. A read across a chunk boundary leaves the stream's chunk before making room, or its pin would count against another stream's chunk, and carries the stream to its last chunk. Its reads of the chunk it leaves hold that download, start first and take no concurrency slot, as evicting the chunk waits for them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: wait for the budget waiter in reader cache tests instead of sleeping A reservation that reaches the budget only after the sleep sees the new state on its first check, so these tests could pass with the wakeup or the wait rule they cover removed. Wait until the reservation is parked in reserve, and fail at once if it finishes without waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: release blocked test fetches when a boundary read test fails A t.Fatal before the gate closed left the deferred cache destroy waiting for the blocked fetch, so the test hung instead of failing. The wait for the head read to pin chunk0 is now bounded too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: hold the chunk a boundary read leaves from one look at the stream The hold pass looked up the stream's chunk per task and the leave looked again, so a concurrent read on the same reader that moved the stream in between got its new chunk detached and unheld, and the boundary read could download that chunk again. Take the stream's chunk once, hold it for the views reading it, and detach only that chunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: tie the budget-wait test check to the test's own reservation waitForBudgetWaiter now starts the reservation itself and only accepts a goroutine parked in reserve that is that goroutine or a download it started, so an unrelated waiter cannot let a test move on early. The direct budget tests cancel their waiter on cleanup, since destroy() does not reach a cacher outside the map. 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> |
||
|
|
ca09dae400 |
filer/postgres: postgres and postgres2 share their connection setup (#13252)
* filer/store_test: conformance suite for filer stores Entries in and out of buckets, byte-ordered and prefixed listings, key-value records, transactions, bucket tables and the snapshot scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: run postgres2 and mysql2 through the conformance suite RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS does the Redis stores; each test gets a schema or database of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: give the go test job Postgres and MySQL services Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of row statements Insert, update, find and delete now take the row key and return their arguments with the query, so a generator decides how a key maps to its columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of directory statements Listing and deleting a directory's children take the directory and return their arguments with the query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: batch lookup takes row keys and matches rows by name and directory A key-value key's directory column already determines its dirhash, so the batch read no longer selects dirhash to match its rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: build the connection string with pgxutil.BuildDSN The credential store already does; it quotes values per libpq, so a password or certificate path with spaces or quotes no longer breaks the connection string. The OpenPGXDB alias has no callers left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: scan pages take the row key of the last row as their cursor Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: postgres and postgres2 share their connection setup ReadConnection reads the settings and their defaults, Connection.Open opens the store's pools. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: test the arguments each generator binds Each statement's arguments must match its placeholders in count and column. Check them for every generator method, including the Postgres UPDATE whose parameters are now numbered key first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres: escape the table name inside its quotes A double quote in it is doubled, as PostgreSQL reads a quoted identifier. Bucket names cannot hold one; the statements no longer rely on that. Reported by CodeQL (go/unsafe-quoting) on the lines this branch changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: keep the nameExpr doc comment on nameExpr Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
abe623c570 |
filer/sql: generators bind their own statement arguments (#13251)
* filer/store_test: conformance suite for filer stores Entries in and out of buckets, byte-ordered and prefixed listings, key-value records, transactions, bucket tables and the snapshot scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: run postgres2 and mysql2 through the conformance suite RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS does the Redis stores; each test gets a schema or database of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: give the go test job Postgres and MySQL services Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of row statements Insert, update, find and delete now take the row key and return their arguments with the query, so a generator decides how a key maps to its columns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: generators bind the arguments of directory statements Listing and deleting a directory's children take the directory and return their arguments with the query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: batch lookup takes row keys and matches rows by name and directory A key-value key's directory column already determines its dirhash, so the batch read no longer selects dirhash to match its rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: scan pages take the row key of the last row as their cursor Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/sql: test the arguments each generator binds Each statement's arguments must match its placeholders in count and column. Check them for every generator method, including the Postgres UPDATE whose parameters are now numbered key first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/postgres: escape the table name inside its quotes A double quote in it is doubled, as PostgreSQL reads a quoted identifier. Bucket names cannot hold one; the statements no longer rely on that. Reported by CodeQL (go/unsafe-quoting) on the lines this branch changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/postgres: keep the nameExpr doc comment on nameExpr Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
889d15b8de |
sftp: refuse paths that are not valid UTF-8 (#13279)
* sftp: refuse paths that are not valid UTF-8 Filer entry names are proto strings and must be valid UTF-8. util.FullPath.DirAndName replaces invalid bytes in the last path element with "_", but leaves the directory part as is. So an SFTP request naming "bad\xfe" silently acted on "bad_": Mkdir created a directory "bad_", Rename moved the source to "bad_", Open/Put uploaded to "bad_", and Stat/Setstat matched an unrelated "bad_" entry. Any later request using the name as a directory then failed to marshal, so the mangled entry could not be removed under the name the client used. rclone's FsEncoding/invalid_UTF-8 test hits this and leaves "invalid utf-8_" behind, breaking every later listing check. Reject such paths in toAbsolutePath, which every request (including the rename target) goes through, with SSH_FX_BAD_MESSAGE, so nothing is created or changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sftp: shorten the invalid UTF-8 path comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Denis Maier <denis@dAir.lab> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
ca4d7939ab |
sftp: fail listing a missing directory (#13280)
The filer streams nothing for ListEntries on a directory that does not exist, or on a file, so OPENDIR succeeded and READDIR returned an empty listing. Clients could not tell a missing directory from an empty one: `rclone lsf remote:does-not-exist` exited 0, and rclone's FsListDirNotFound test got nil instead of "directory not found". When the first page comes back empty, look the path up and return os.ErrNotExist unless it is a directory, which the request server sends as SSH_FX_NO_SUCH_FILE. Non-empty listings pay no extra lookup. Co-authored-by: Denis Maier <denis@dAir.lab> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
2574cedfd3 |
s3: publish a recovered PUT's event at its commit stamp (#13265)
* s3: publish a recovered PUT's event at the stored entry's commit stamp A PUT whose create committed but lost its answer, and that recovery then found stored, published its event at the gateway's clock. A later write to the same key that carries its filer stamp could then sort before it. Both recovery paths now take the stamp the committing filer gave the stored entry, as recovered multipart completions do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: return the context error when it ends a topic configure A start whose context ended during ConfigureTopic on the last broker answered with the RPC's text, so errors.Is(err, context.Canceled) did not hold for it as it does for a context that ends before an attempt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: name the broker whose topic configure failed doConfigureTopic built lastErr with the broker address but returned the bare RPC error, so a failed configure did not say which broker refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
5a8e774e36 |
shell: harden volume.tier.upload for unattended batch runs (#13254)
* shell: harden volume.tier.upload for unattended batch runs
- validate -dest against the master's storage backends before any volume
is marked read-only, instead of failing per volume after the freeze
- mark replicas read-only with canDelete so TTL expiry keeps draining the
volume during the upload, and restore writable marks when the upload or
metadata replication fails partway
- keep going after a per-volume failure in batch mode and report all
errors at the end
- treat an unset -disk as "any disk"; flag.String never returns nil and
ToDiskType("") is the hdd type, so the batch silently skipped ssd and
tagged volumes
Refs #13223
* shell: keep deletes refused while volume.tier.upload copies a volume
A delete accepted during the copy appends a tombstone to the source .dat,
so the attach refuses the upload, and one accepted after a replica's .idx
snapshot is dropped when that replica installs the copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: leave replicas that were read-only alone when a tier upload fails
VolumeMarkWritable persists ReadOnly=false, so the rollback cleared an
operator's read-only mark on any replica that was frozen before the run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: roll back the replica whose read-only mark failed in volume.tier.upload
VolumeMarkReadonly freezes the volume locally before its second master
notification, so an error there leaves the replica read-only although it
never joined the marked list. Also name that replica in the error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: let the tiered source accept deletes once every replica has its index
The copies load as tiered volumes that accept deletes, but the source kept
the no-delete mark until its next reload, so a delete applied on a copy
then failed on the source.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: bound each rollback mark in volume.tier.upload
A stalled VolumeMarkWritable held up the upload error and, in a batch run,
every later volume.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: keep replicas frozen when the tier upload attached before failing
A stream that breaks after the volume server attached the remote copy
returns an error, and reopening the other replicas then let them take
writes the remote copy lacks. Ask the source first; a rerun finishes the
upload from its remote copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* shell: bound the final delete mark in volume.tier.upload
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>
|
||
|
|
e10cf7fd85 |
shell: a moved volume does not keep its source disk id in the model (#13275)
* shell: a moved volume does not keep its source disk id in the model adjustAfterMove added the moved volume to the target's VolumeInfos with the source's DiskId. volumeServer.evacuate moves the normal volumes first and then plans the EC shards on the same topology, where the disk ids of a node come from its volume and shard records. A volume moved off disk 3 of a four-disk server therefore gave its one-disk target a disk 3, the planner sent EC shards there, and the target refused every such move with "invalid disk_id 3: only have 1 disks". The target server picks the disk for a moved volume, so record it with disk id 0 (unknown) on a copy, leaving the source's record as it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: test the EC phase of evacuate on the model the volume phase left Drive evacuateNormalVolumes and then evacuateEcVolumes, the two phases the command runs on one topology, instead of calling adjustAfterMove directly, and check the disk each planned shard move names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: trim comments on the moved volume record 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> |
||
|
|
2b157f2ef1 |
test: clear the codespell hits left after #13290 (#13264)
* test: use a codespell-clean non-ASCII key in TestEncodeKey Codespell reads caf%C3%A9 as the misspelling caf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topictable: reword want's in the CheckSchema comment Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
22abfe2d1b |
shell: leave emptier servers without free slots out of the -byDiskUsage ideal (#13247)
* shell: leave emptier servers without free slots out of the -byDiskUsage ideal volume.balance -byDiskUsage never picks a server without a free volume slot as a move target, but planBalance counted every server in the ideal ratio. A server that is emptier than the rest but has no free slot, as happens to an auto-sized disk (no -max) whose free space is held as growth room for its partly written volumes, pulled the ideal below the usage of the servers that could take a volume. Every target's next ratio then exceeded the ideal, planBalanceMove stopped at the first one, and the run planned no move while the fullest servers kept filling. The ideal of a -byDiskUsage run now leaves those servers out: a server without a free slot below the ideal is dropped and the ideal recomputed over the rest, until none is below it. A server without a free slot above the ideal still counts, as it is drained as a source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * shell: leave servers out of the -byDiskUsage ideal by their raw ratio idealRatioOfReceivingServers compared a server with DensityRatio, which gives a server with no whole volume used a floor of half a volume over its capacity. A small disk without free slots then compared above the ideal and stayed in it, holding the ideal under the targets' next ratio as before. Compare the raw used/capacity ratio, the one the ideal is made of. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
081218bf8a | test: reword misspelled fixtures that trip codespell (#13290) | ||
|
|
9f9c28471f |
s3api: free the parts a multipart completion does not name (#13248)
* s3api: free the parts a multipart completion does not name prepareMultipartCompletionState skipped every entry of the upload directory whose part number the request does not name: it was neither a part of the object nor one of the unused entries freed with their data. The completion then removes the upload directory metadata-only, since the object's chunks are its parts' chunks, so the skipped parts' chunks stayed on the volume servers with nothing referencing them until a volume.fsck purge. Once the upload is completed they cannot be listed, completed or aborted any more. The completion now keeps those entries aside and, once its object is committed and the upload directory is gone, deletes their chunks by file id, resolving manifest chunks first. They are not freed before the commit, as the unused attempts are on the routed paths: until a completion succeeds the upload stays open with all its parts, and the commit transaction can still refuse the write. When another completion of the upload owns the commit (metadataOnlyCleanup), its object can hold them, and they are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: give the unrequested-part cleanup one deadline and check the committed object first The client waits for the completion it already committed, so the cleanup of the parts the request did not name gets one deadline, unrequestedPartsCleanupTimeout, instead of a lookup timeout for each part with manifests: the chunks of the parts without manifests are deleted first, then manifests are resolved part by part while time is left. deleteOrphanedChunksWithContext passes the deadline to the volume lookups and deletes; deleteOrphanedChunks keeps its behaviour. A completion without a ring owner commits under the object lock without the upload-directory precondition, so a routed completion of the same upload can commit after it with a list that names those parts, and remove the directory. The cleanup now frees them only when the key's current object is this completion's commit (this upload, the same chunks), checked once the directory is gone, when no routed completion can commit any more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: deleteOrphanedChunks takes the context its lookups and deletes use Fold deleteOrphanedChunksWithContext into deleteOrphanedChunks instead of keeping a second name; the existing callers pass context.Background(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: check the entry the completion wrote, under the cleanup deadline The check before freeing the unrequested parts resolved the object by its key, outside the cleanup deadline. A key ending in "/" is written inside the directory it names ("dir/" at dir/dir), so the check read another entry and kept the parts, and a filer that stopped answering after the commit could hold the completion without a limit. The completion now records where it writes its object (the version file on a versioned bucket), and the cleanup reads that entry back, from the write owner when there is one, under the same deadline as the deletes. Each part whose manifests resolve is deleted before the next manifest is read, so a read that runs out the deadline no longer strands the parts resolved before it. The cleanup's filer reads, that check and deleteOrphanedChunks' volume lookup, go through withFilerClient with the deadline, so the deadline running out is not booked as a failure of the filer and does not open its circuit for other requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
ab6b1598b9 |
mq/offset: fix a flaky partial-listing test (#13288)
mq/offset: fail the test lookup the way a filer store does TestListConsumerGroupPositionsReturnsWhatItReadOnAFailure flaked (about 1 in 60 runs): its fake filer failed the unreadable position with codes.Unavailable and no details, which pb treats as a dead channel. The shared ClientConn was closed and the concurrent loads of the other partitions failed with it, so the listing returned one position, not two. A real filer answers a store read error with a plain error (codes.Unknown), which keeps the channel. The fake now does the same. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
9e4e1ade67 |
filer: conformance suite for filer stores, run against Postgres and MySQL in CI (#13250)
* filer/store_test: conformance suite for filer stores Entries in and out of buckets, byte-ordered and prefixed listings, key-value records, transactions, bucket tables and the snapshot scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer: run postgres2 and mysql2 through the conformance suite RUN_POSTGRES_TESTS and RUN_MYSQL_TESTS enable them, as RUN_REDIS_TESTS does the Redis stores; each test gets a schema or database of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * ci: give the go test job Postgres and MySQL services Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK * filer/store_test: create the shared fixtures before the subtests The scan and delete-folder-children subtests read the order directory that only the list subtest created, so selecting either one with -run failed on a conforming store. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/store_test: roll back a transaction an assertion abandons A failed assertion between BeginTransaction and the commit left the transaction open with its locks, and the cleanup's DROP SCHEMA then waited on them until the go test timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/store_test: check limited listings without trimming the result The limit-1 checks sliced the listing to one name, so a store that ignored the limit passed, and one that returned nothing panicked. Allow only the one look-ahead entry the SQL stores return and compare the first name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/store_test: give the exclusive limit check three eligible names Starting after a%b left only two names under the prefix, so a store that ignored the limit still met the one look-ahead bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer/store_test: check that a bucket drop removes nested entries A store that reports CanDropWholeBucket gets no recursive walk from the filer, so its DeleteFolderChildren on the bucket has to remove every descendant. With only a direct child in bkt2, a store that deleted the direct children and kept the table passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
51d2b2b712 |
mq: read a table-backed topic's history from its Iceberg table (#13260)
* mq: read a topic table's data files back as log entries A view of a topic's table holds the current snapshot's offset map and, per _partition, its data files with the _offset and _ts_ns bounds from the manifests. A partition's rows are read by offset or by time, skipping files and then row groups whose bounds miss the read, and come back as the log entries they were copied from: key, timestamp, offset, and the message as _value or as the record re-encoded from its columns. Views are cached per topic, rechecked every few seconds, rebuilt only when the metadata location moves, reuse already-parsed manifests, and are evicted past a bound on the data files they hold. A table that is gone or replaced by another UUID reads as empty; one with delete files is refused. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a table-backed partition below its table's high-water mark from the table The merged reader takes the partition's table, looked up on every read so a table attached later is seen. An offset read below the mark reads the table up to the mark and continues into the log files and compacted parquet from the mark; a time read takes the table's rows after the time and then the files' entries at or above the mark. Log files left below the mark by a crash between the writer's commit and its delete are never read. The broker hands its partitions' disk reads to the table through the topic's cached view; a topic without a table, or whose topic.conf is gone, reads its files as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: start a table-backed partition's offsets at its table A partition whose log files below the table's high-water mark were deleted would reload with a high-water mark and log start taken from the files that are left. Loading it now continues its offsets no lower than the table's mark and starts its log at the table's lowest offset, or, when the table holds nothing of it, at the first file offset at or above the mark. A retired range of a repartitioned topic is read and bounded the same way, and a retention purge raises the log start likewise, so purging hot log files never makes the table's offsets out of range. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: keep a flushed data source's finished flag atomic The streaming goroutine sets finished while the merge loop reads it through HasMore, which the race detector reports on any scan that reads flushed data. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: scan a table-backed topic's history from its table The hybrid scanner hands each partition's merged read the topic's table, so a scan reads the table's data files below the partition's high-water mark, pruned by _partition, _offset and _ts_ns, and log files from the mark on, skipping any a crash left below it. Aggregations no longer answer such a topic from parquet statistics and log counts, which hold none of its table's rows; they scan instead. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a schematized row's raw _value back as its message A schematized topic's table can keep a message that is not a record, a tombstone or an undecodable value, as raw bytes in an optional _value with the record columns null. Such a row now reads back as those bytes; a row whose _value is null reads back as its record, and a schemaless topic's row as its _value as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: delete log files a topic table already holds A log file or compacted parquet whose every offset is below a partition's table high-water mark is never read again, so it can go. The mark used is that of the newest snapshot at least a minute old: a reader's view of the table is at most a few seconds old, so it already reads those offsets from the table and never from a file being deleted. Files without an offset range and the file holding the partition's highest offset are always kept. DeleteCoveredLogFiles is for the topic's writer after its commit; a leader also deletes them under its fence on load and on each retention pass, covering a writer that crashed between its commit and its delete. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: report a topic table's rows as parquet_archive A table-backed topic's scan labelled every row live_log, its table's included. The flushed data source now records the high-water mark of the table its merged read was handed and reports the rows below it, which come only from the table's parquet data files, as parquet_archive. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete the log files a topic table holds after each run Every mq_topic_table run now ends by deleting, in each partition, the log files wholly below the offsets of the newest snapshot at least LogDeleteGrace old, never the leader's newest file. A commit is never old enough on the run that makes it, so each run deletes what earlier ones copied; the partition's leader deletes the same files when no run follows. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a time read's position when nothing on disk follows it A time read that found nothing after its position returned a position at time zero: the parquet reader reports the newest time it delivered, which is none. A loop over an empty memory buffer then read the whole partition from the start, came back to the same empty read, and started over, so a query asking a broker for its unflushed messages streamed the partition forever. The merged and the table-tiered readers now keep the position when they deliver nothing past it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: publish a topic table view under the lock eviction reads it with A loaded view was stored under its entry's loading lock while eviction, run by another topic's load, read every entry's view under the cache's lock, so two topics refreshing at once raced. A view is now stored holding both locks: a load reads it under the first, eviction under the second. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep no topic table view larger than the whole view cache Eviction never dropped the view just loaded, so one topic whose table had more data files than the cache's bound stayed cached past it, and evicted every other topic's view on the way. Such a view is now answered and not kept; the others stay. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: look up a topic table's mark again where a read leaves the table A read kept the table mark it started with. One slow over the table's rows could outlast the grace: the writer commits past that mark, the logs below the new mark are deleted, and the read then lists the logs from its old mark and passes over the deleted offsets without a word. The read now asks for the table again each time it leaves it and reads on in the table up to the mark it finds, until the mark stops moving; a time read takes the rows between the marks by offset. A gap where the logs begin is checked against the table once more, and read from the table if it took it meanwhile. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's timestamps back without going through nanoseconds A timestamp or time column was turned into micros by way of nanoseconds, which overflow for dates before 1678 or after 2261, so a year 1 or year 9999 value came back as another date. Each unit now converts to micros directly. The table fixture wrote every topic's rows whole into _value once every table had that column, so the record columns these reads take went untested; it now writes a schematized topic's rows as columns. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: order a compaction bin by the first sort field that varies in it A topic table sorts by _partition, then _offset, and is partitioned by _partition, so every file of a bin holds one _partition. Ordering the bin by it kept the files in manifest order, and a merged file's offsets came out of order for the topic table reader, which delivers a data file's rows as offsets in order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: list a retired range from its table's lowest offset A topic lookup lists each retired range with the bounds of its own files, so once the table held a range's history and its log files went, the range was listed from its newest file on, while its reader serves the table's offsets below it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iceberg: never merge compaction inputs across a file left out of the merge A file already at the target size takes no part in compaction, yet small files on both sides of it in sort order went into one bin, so the merged file's bounds spanned it. For a topic table that is a data file whose _offset range overlaps another's, which a reader finishing one file before the next cannot read in order. An ordered bin is now cut wherever a file left out of the merge falls between two of its files, so every merged file covers a range no file outside its run lies in. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: merge a topic table's overlapping data files by offset when reading A partition's data files were read one after another by their lowest offset, which only reads in offset order while no two ranges overlap. A rewrite by another engine can leave a file spanning another one, and then a read from inside the overlap delivered the spanning file's later rows first, and a read that stopped early left the rows in between behind. Files whose offset ranges overlap are now read together, their rows merged by offset and an offset held twice delivered once. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: open a topic table's data files only as a read reaches them A merged read opened every file of an overlapping group before it delivered a row, and a file the manifest records no offset bounds for overlaps every other one, so a short fetch held a reader for each file of the partition's history. The files of a read now wait in a heap keyed by the lowest offset each can hold, and a file is opened only once nothing before that offset is left to deliver; a file without bounds is opened where the read starts, and its row groups' statistics skip what they rule out. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: retire no log file a topic's table does not hold yet Retention deleted a table-backed topic's log files by age alone, so with the table writer behind it deleted messages the table did not hold, and they were gone from both. On such a topic a file now expires only once all it holds is below the table's mark of a grace-old snapshot, the same files the leader deletes as covered; what the table holds ages out with table retention. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a table-backed range's bounds by its caller's deadline The table lookup that widens a partition's bounds ran under a background context, so a retention pass or a retired-range lookup with a deadline waited on a stalled table catalog for as long as it stalled. It now runs under the caller's context. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table's mark again when a time read reaches its files A time read caught up with the table and then read the files above the mark it last saw. A view that had moved on meanwhile, with the logs below its new mark deleted before the files were listed, left the offsets between the two marks to neither. The time read now asks for the table again at the first file entry it would deliver, or after the files if they held none, and on a moved mark reads the table up to it before reading the files again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: bound the topic table views kept, empty ones included, and keep those in use Eviction only counted data files, so views of tables holding none, and entries a failed first load left behind, were never dropped; and it could drop an entry while a caller was loading it, so the next caller loaded the same table again alongside. A failed first load now leaves no entry, at most maxCachedTopics views are kept, and an entry a caller still holds is never evicted. The eviction test now requires exactly the one eviction that makes room. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check a topic table afresh before deleting the logs below its mark A leader's covered-log delete and log retention took the table's mark from the cached view, up to a few seconds old, so a table rolled back to a lower mark meanwhile had its logs above that mark deleted although it no longer held them. Both now check the table before acting: the cache takes a maximum age, a read passes ViewRefresh and a delete zero. A cached view is also reused only for the same table state, since a commit that rewrote the metadata in place keeps its location. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: leave a sort field holding nulls to order a compaction bin A sort field whose bounds are one value in every file was taken as constant and the bin ordered by the next field, yet bounds leave nulls and NaNs out, so a column holding them besides its one value is not constant. A field is now skipped only when the files also record no null in it, and no NaN for a floating point one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: delete a topic's covered logs only while it still names the table A run's log cleanup used the table metadata the run started with, so after the topic left the table, or the run lost its lock, it still deleted the logs below that table's marks. The cleanup now checks, when it runs, that it still holds the topic's lock and that topic.conf still names the table with its recorded UUID, and reads the marks from the table as it is then. It still runs after a run that failed otherwise. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each covered log it deletes The leader read the table's mark once, listed the files below it, then deleted them one by one, so a rollback or a detach landing in between went unseen and files the table no longer held were deleted. The delete now holds the table writer's lock, so the topic cannot leave the table meanwhile, and before each file reads topic.conf and the table afresh, stopping at the first file not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: let a caller waiting on a topic table's load give up at its deadline A caller wanting the view a stalled load of the same table was making waited on a mutex, past its own deadline, for as long as the load stalled. The entry is now held by a one-token channel a waiter selects on with its context, so it returns at its deadline and lets go of the entry. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: give up a scan's table lookup when the query is cancelled The table a scan reads below each partition's mark was looked up under a background context, and the flushed data source waited on its channels alone, so a cancelled query stayed blocked on a stalled table catalog. The scan's context now reaches the topic.conf read and the table lookup, and the data source returns once it is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: take a topic table's lock only when a covered log is left to delete The leader's covered-log pass took the table writer's lock for every table-backed partition it leads once the table had a mark, every five minutes, even with nothing to delete. While a copy run held the lock, each such partition waited out the lock wait and logged a failure, holding up the rest of the retention tick. List the covered files first and take the lock only when there are some; the per-file checks under the lock stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: drop a topic table view only with the last caller holding it An oversized view was removed while other callers still held it, so the next caller loaded it again alongside; an entry no load filled was removed only by a failing load that was its sole holder, so one whose callers failed or gave up in another order stayed; and eviction that found every candidate held left the cache above its bounds with nothing to evict again. Callers now let go through one release: the last one removes an entry no load filled or one marked to drop, as an oversized view is, and each release runs eviction again. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: check a topic's table again before each covered log the cleanup deletes The cleanup checked the lock, topic.conf and the table once, then deleted every file below the marks it read, so a detach, a dropped or replaced table, or a lapsed lease landing during the deletes went unseen. The deletes now check all three again before each file, with the mark of the table as it is then, and stop at the first file not below it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: let a flushed data source's producer close its own channels Next can return on the query's cancellation while the producer is still sending, and the merge then closes the source, which closed the result and error channels under that send. The producer now owns them: Close only signals it to stop, every send also selects on that signal, and the producer closes the result channel when it exits, after sending its one error if it has one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: fail a scan whose data source fails after its first row The merge only logged an error from a source past its first row, the query's cancellation included, and returned the rows read so far, so a cancelled or timed-out COUNT or SUM answered with a wrong number. It now closes its sources and returns the error, and the scan wraps it, so a caller can tell the context's error from others. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: check a topic table again before each group retention deletes Retention read a table-backed partition's deletable mark once, chose its expired groups, then deleted them with no further look, as the covered-log delete did before it rechecked; a rollback in between left groups deleted that the table no longer held. The live and retired purges and the covered-log delete now share one guard: it holds the table writer's lock and, before each group or file, reads topic.conf and the table afresh, stopping at the first one not below the mark it finds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound a partition load's reads of what it already stores Loading a partition reads its files' offset range and, for a table-backed topic, the table's, while holding accessLock, under a background context, so a stalled filer or table catalog held every other partition operation for as long as it stalled. The reads now get the bound a load's fence take has; past it the load fails, as it does when the stored offsets cannot be read, and the caller retries. Falling back to the log files' bounds would start the log above the table's offsets with no later refresh to lower it, so consumers resetting to the earliest offset would skip the table's history. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: count a flushed source's pending error as more to read The merge asks HasMore before reading a source again, and HasMore looked only at buffered rows and whether the producer finished, so a producer that failed after its last row and finished before the merge asked had its error never read, and the scan returned the rows so far as its answer. An error waiting counts as more to read now, so Next returns it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the table's files of a topic that left it before the delete A topic that left its table between the listing of what the table held and the guard the delete takes got no guard, which let every listed file go, though readers take those offsets from the logs again. Files chosen by the table's rules, the covered logs and the groups retention trimmed to the table's mark, are now kept when no table remains; files of a topic that had no table when the pass began still expire as before. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query: order the pending-error merge test's row before its error The test's producer could send its error before the first Next took the row, and Next then picked either one, so on some runs the error came through the first read and the test passed without exercising HasMore. The producer now holds its error until the first Next has the row, and the merge asks again only after the producer has finished, so the test fails every time without the pending-error fix. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: read a topic table's chunk-backed files under the caller's context A manifest or manifest list stored in chunks was read through a stream reader built without a context, and the stream reader looked up and fetched each chunk under a background context even when built with one, so a stalled volume server held a partition load past its bound while it held accessLock. A chunk stream reader now looks up and fetches its chunks under the context it was built with, and a table's chunk-backed files are read with the caller's. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: keep the expiredLogFiles doc comment on expiredLogFiles Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: let the table catalog read chunk-backed table metadata The broker's table catalog reached its filers through a client with no way to look up chunk locations, so a table whose catalog record holds only the location of its metadata, as one whose metadata outgrew a request does, failed to load once that file was stored in chunks: the topic's history could not be read. The client now resolves chunks the way the broker's own filer client does. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * iceberg: read chunk-backed table metadata under the caller's context A catalog record holding only a metadata location had its chunk-backed file read by StreamContent, whose lookups and fetches run under a background context, so a stalled volume server held a table load past its caller's deadline: a broker loading a table-backed partition under accessLock past its bound. The read now streams under the read's own context, which already bounds its other filer calls. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * filer: give up a LookupFn volume lookup's retries at its caller's deadline LookupFn retried a failed volume lookup through util.Retry, which sleeps its backoff without looking at the caller's context, so a lookup failing near a deadline outlived it by up to the whole backoff; a table load under a broker's accessLock held it that long. The lookup now retries through util.RetryWithBackoff with the same transient-error rule and about the same total wait, which stops when the context is done. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
284d491587 |
s3: forward notification topics to webhook targets (#13245)
* util: move the guarded dialer out of the volume server The deny list and the dialer that re-checks every resolved address at connect time move into weed/util/netguard, with the allow-private knob as a policy, so other outbound clients can dial through the same guard. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: fence consumer group position saves by generation A position saved with a generation is written only while the stored one carries no newer generation, or the same generation from another writer: the save reads the stored position and writes on the condition that it is unchanged, routed to the entry's owner filer, and re-reads when another writer got there first. A single consumer that elects itself can then store its offsets without a deposed predecessor overwriting them. Saves without a generation keep overwriting as before. Loading a missing position now reports ErrNotFound instead of trying every filer and marking each one failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: post bucket event batches to a webhook target A webhook destination renders a batch of records as one {"Records":[...]} body, posts it with the target's bearer token, and takes any 2xx as delivered. The renderer is a function the destination holds, a stand-in that refuses until the record renderer lands. It dials through the guarded dialer under a new Local policy, which refuses metadata-service, link-local and unspecified addresses at connect time but lets an operator point a target at a private host or a sidecar on loopback. Redirects are followed only to the endpoint's own host and never down from https. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: forward each target's topic to its destination A Forwarder runs beside the Publisher on every gateway. Each enabled target with a destination gets a lock, s3.notify.<target>, held through LockClient.StartLongLivedLock, so one gateway forwards a target and targets spread across gateways; a topic target has none. The holder runs one loop per partition of the target's topic: fetch from the stored offset at the partition's leader, decode the records, deliver them as one batch, store the next offset. A fetch that stops short at a segment boundary just continues from its next offset. A failed send, a rejected one included, blocks the partition and is retried with capped backoff, and the offset is stored only after the destination took the batch. An offset that retention removed skips to the earliest one and counts the gap. Offsets go to the consumer group offset storage under group forwarder, fenced by the lock generation. On taking the lock a forwarder stores each partition's offset back under its generation, so an older holder's saves are refused and it stops. A stored generation at or above its own means the lock was lost, unless the forwarder has since held the lock through a full renewal, which happens only when the lock server's counter restarted; it then fences above the stored generation. Metrics per target: records delivered, send retries, retention gaps, and lag from the forwarding gateway. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: run notification forwarders beside the publisher Every gateway with filers starts a Forwarder with the publisher. It elects itself per target through the gateway's object-write lock client, stores offsets in the filer, reads through the same brokers the publisher uses, follows the target registry as the publisher does, and releases its locks on shutdown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: post a test event to a webhook on its own The renderer refuses an s3:TestEvent that shares a body with other records, so a webhook splits a batch around each one and posts them in order, the test event as its own body. The test is a stand-in until the renderer's lands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: skip a bucket event record that can never be delivered A record that does not decode, or that the renderer refuses, used to be retried like a failed send and would block its partition for good. The webhook now renders a whole batch before posting any of it and names the records that cannot render; the forwarder drops those, counts them per target and reason in notification_skipped_records_total, logs each offset once, and sends the rest. Only transport and HTTP failures are retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: read a fenced position save at the filer that applies it The fenced save read the stored position from whichever filer answered and then sent its conditional write to the key's owner, so with filers that keep their own stores the condition could be checked against an entry other than the one read, failing until replication caught up or judging a stale copy. The storage now takes the ring's owner lookup, the one route-by-key writes already use, and sends both the read and the write to that filer. The gateway hands its object-write lock client's PrimaryForKey to the forwarder offsets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: follow a repartitioned notification topic A forwarder listed its topic's partitions once, when it took the lock, so a repartition left the new partitions unforwarded until the lock moved. It now lists them again every 30 seconds, starts a loop for each new partition, and marks the loops of partitions no longer listed as replaced; such a loop keeps delivering what its partition holds and ends once it has caught up. A failed fetch now looks up the leader of that exact partition, not of any partition with the same range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let the first forwarder take the lock before the second asks The election test synced both gateways at once, and each forwarder asks for its lock from its own goroutine, so the second could ask first and store the offsets the test expected from the first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: warn when a partition returns nothing below its high-water mark A fetch that returned no records and kept its next offset below the high-water mark looked like an idle partition, so the forwarder waited without a word while its lag stayed up. It still waits, since skipping would lose the records, but now warns at most once a minute with the topic, partition, offset and high-water mark, so the lag has an explanation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: render webhook bodies with the bucket event renderer The webhook now renders through Render and posts each s3:TestEvent alone by IsTestEvent, replacing the stand-ins it held until the renderer landed. The tests send real records and read the object keys and test request ids back out of the bodies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * netguard: refuse the IPv6 and Alibaba metadata service addresses AWS's IPv6 metadata address fd00:ec2::254 is unique-local and Alibaba's 100.100.100.200 sits in the CGNAT range, so the Private and Local policies let a webhook or remote endpoint reach them. Refuse both under every policy, like 169.254.169.254. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * grafana: chart the notification forwarder metrics Add an S3 Notifications row with delivered records, lag, send retries, and records skipped or lost to retention per target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: follow only webhook redirects that keep the POST On a 301, 302 or 303 Go resends the request as a GET without a body, so an endpoint that redirected and then answered 2xx counted as delivered while it received no records. Only 307 and 308, which keep the method and resend the body, are followed now; any other redirect fails the send and is retried. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep webhook endpoint secrets out of errors and logs The guarded dialer names its endpoint in every refusal, and the forwarder logs that error, so a webhook endpoint carrying credentials in its userinfo or a token in its query had them written to the log. The dialer now gets the endpoint as scheme, host and path only, and the parse and request errors no longer echo the URL. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: load a consumer group position from its owner filer A forwarder taking over read its start offset from whichever filer answered, while its fenced saves read and write at the key's owner. With filers that keep their own stores, a replica still holding an older offset handed the new holder that offset, which it then stored under its higher generation at the owner, replaying everything delivered since. Loads now go to the owner too when the storage knows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound consumer group position loads and saves by the caller LoadConsumerGroupPosition and SaveConsumerGroupPosition ran their filer calls under context.Background(), so a filer whose store stalled held a forwarder's save forever: ending the lead waited on it, the lock was never released, and Close hung while the lock kept renewing. Both now take the caller's context; the forwarder gives each call its RPC deadline under the lead's context, so stopping returns and the lock is released. The offset wrappers the broker uses keep their signatures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: list a consumer group's positions across partition generations ListConsumerGroupPositions walks every generation and range directory of a topic and returns the group's stored position in each, keyed by partition directory, so a consumer can tell which ranges it holds offsets for that the topic no longer lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: stop forwarding ranges a repartition removed A repartition drops the old assignments, and the broker serves only assigned ranges, so the loop draining a removed range retried a refused fetch forever, and after a restart nothing looked at it at all. Reading a removed range's flushed data would need a read-only path in the broker. Until then a removed range's loop delivers the batch it holds and ends, and the forwarder logs an error naming each range it stops and, when it takes the lock, each partition directory holding a stored offset the topic no longer lists. The fake broker now refuses unassigned ranges as the real one does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: deliver what a repartition left in the retired ranges The lookup now offers the sealed ranges a repartition retired, and any broker serves them from their files, so the forwarder no longer drops them. On taking the lock and on each re-list it asks for the retired ranges too and runs a loop for each, from its stored offset up to its high-water mark, after which the loop ends; a range it was forwarding as current and that is now retired gets the same end. A read below a retired range's log start counts as a retention gap, as for a live one. A key's records in a retired range precede its records in the ranges that replaced it, and loops running side by side would not keep that order. So the retired ranges go first, one generation at a time, oldest first, and the current ranges start only once none is left. A range listed neither as assigned nor as retired, as while a drained range is not sealed yet, pauses until it is offered again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: match a retired range to its forwarding loop by directory The broker lists a retired range at the second its generation directory is named for, while the assignment the forwarder started its loop from carried nanoseconds. After a repartition the retired entry missed the running loop, so a second loop started on the same stored offset and delivered the batch the first was still retrying. Key the loops by partition directory; the fake broker now lists retired ranges and the fake positions store offsets at that resolution, like the real ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: replace a paused forwarding loop only once it ended A range drained but not sealed yet is listed neither as assigned nor as retired, so its loop is paused and dropped from the lead's loops while it may still be retrying a batch. Once the range was offered as retired a new loop started at the stored offset and sent that batch again. Keep a paused loop until it ends, and start the range again only then. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: hold the new ranges while a drained one is not sealed yet A repartition saves the new ranges before it drains and seals the old ones, so for a while an old range is offered neither as assigned nor as retired, and the forwarder started the new ranges at once: a key's new records could go out before its records still waiting in the old range. On each look at the topic the forwarder now lists the directories holding a stored offset that the topic does not offer, and probes each at its offset; one that may still hold records past it, refused because it is not sealed, holds the new ranges until it is offered as retired and drained. One that answers with nothing past the stored offset is settled, sealed and empty or already delivered, and stays so for the lead. While holding, the forwarder logs at most once a minute and keeps looking even with no loop running. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: have the fake broker serve only the generation a fetch names The broker now refuses a fetch naming a generation other than the one it assigns for the range, unless that generation is sealed and read as retired. The forwarder tests' fake broker matched an assigned range by its range alone, so it served the live generation to a fetch for an older, unsealed one; it now matches the generation too, as the broker does. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold the current ranges until the stored offsets can be listed A lead whose first look at the stored offsets failed took that as no old range left unsettled and started the current ranges, delivering a key's newer records ahead of the ones still in a drained range that is not sealed yet. A failed look now holds the current ranges as an unsettled range does, and is retried with backoff and on each partition refresh; the current ranges start only after a look succeeds. Retired ranges and loops already running carry on meanwhile. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3api: leave forwarding off on an unusable broker TLS config The forwarder loaded the grpc.msg_broker client TLS config with LoadClientTLS, which exits the process on a bad one, and every gateway with filers builds a forwarder whether or not it has webhook targets. It now loads it as the publisher does: an unusable config is logged and leaves forwarding off while the gateway keeps serving. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold the new ranges for an unsealed old range with no stored offset The check for old ranges still unsealed looked only at ranges holding a forwarder offset. A forwarder starting for the first time while a drained range was not sealed yet had stored none in it, so it started the new ranges and delivered a key's newer records ahead of its older ones. The consumer group listing now names every partition directory of the topic, with no position where the group stored none, and such a range is probed from offset 0. A range with nothing left past that offset, including one whose records retention already removed, is settled. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: check the load in the fenced save race test The test read the stored position back ignoring the load's error, so a failed load panicked on a nil position instead of reporting the error. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: take a partition over at the offset its last holder committed A new forwarder generation claimed a partition by writing the offset it had loaded. When the old generation committed again in between, the claim rewound the stored offset and the new lead replayed what had been delivered since. A fenced save that takes over from an older generation now keeps the offset that generation committed last, rereading it on a conditional write miss, and hands it back in the position, and the forwarder starts from it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: wait for a position's owner filer instead of asking another A position store routed by owner fell back to any filer while the owner of a key was not known yet, as before the lock ring is learned. That filer's not-found ended the load there, though it may only not have caught up, and a claim on it would start the partition over. Loads and fenced saves now fail until the owner is known, and the forwarder retries them; a store without an owner routing still uses any filer. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: wait for the last checkpoint before a forwarder handoff in tests The resume, repartition and election tests stopped the first forwarder once its records were delivered but possibly before their offsets were stored, so they could pass on a replay rather than on a committed handoff. They now wait for the final offsets first. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: have Close wait for removed targets to release their locks A target removed from the registry had its forwarder cancelled and dropped from the targets, so a Close soon after did not wait for it and returned with that target's lock possibly still held. Removed forwarders are now kept until they are done, and Close waits for them as well. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold newer retired generations behind an unsealed older one A range of an old generation still unsealed held back only the current ranges. A generation retired after it was offered and delivered right away, ahead of the older generation's records of the same keys. The unsealed range's generation now counts as the oldest one left, so only that generation's own sealed ranges are forwarded until it is sealed. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: check the forwarder lock right before each send A lead checked its lock at the top of each fetch and after a failed send's backoff, so a lead that lost the lock while it fetched a batch still sent it, and the next holder sent it again. The lock is now checked right before each send. Delivery stays at-least-once: a lock lost during a send cancels that send once the lead notices, which may be after the endpoint took the batch. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: read a retired range past a broker that answers with an error Any broker serves a retired range from its files, but a fetch took the first broker's answer even when it was a storage error, and each retry asked that broker first again, so one broker that could not read the files held the range up for good. A retired fetch answered with an error other than an offset out of range now goes on to the next broker, and returns the error only when none could read it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: count ranges held back behind an older generation in the lag The lag gauge summed what each running loop reported, so the current ranges held back while an older generation was still unsealed, and the retired generations waiting their turn, showed no lag however much piled up in them. On each partition refresh the lead now reports their lag from the stored offset to the high-water mark, read from the range's leader or the retired listing, and drops the lag of ranges it no longer has. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: hold retired generations too while stored offsets cannot be listed A lead whose look at the stored offsets failed held only the current ranges and went on forwarding retired generations, though an older generation it could not see might still be unsealed and hold earlier records of the same keys. A failed look now holds every range not yet running until a look succeeds; loops already running carry on. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: read stored offsets only of the ranges a lead does not know yet The check for unsettled ranges listed every partition directory and read every stored offset in it one by one under one deadline, before dropping the ranges the topic offers and those already found settled. A topic with many past generations could take longer than the deadline on every refresh and hold a new lead for good. The listing now takes the directories to skip and reads only the remaining offsets, a few at a time, and the lead skips the offered ranges and those it found settled. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: test the failed-listing hold with no unsealed range The failed-listing test also had an older generation unsealed, which holds the newer ranges on its own once a listing succeeds, so it did not show the listing guard by itself. A second case has no unsealed range: nothing goes out while the listing fails, and both the retired and the current range do once it succeeds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: stop the lead before marking a failed loop ended A forwarding loop that failed, as on being deposed, was marked ended before it cancelled its lead. A partition refresh in between saw a retired range's loop ended, took the range as delivered, and started the next generation's ranges on the lead that was about to stop. The lead is now cancelled first, so no refresh acts on the failed loop. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: count no retention gap below an offset only claimed A lead claiming a partition with no stored offset wrote offset 0 to fence it before reading anything. A lead that stopped there left 0 behind, and the next one, finding the log start past it, counted those offsets as lost though no forwarder had ever been at them. A claim made before any read is now marked as such, a takeover keeps the marker of the entry it replaces, and only an offset a lead read from counts a gap. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: retry a takeover save at the offset it kept A claim's save that took a partition over from an older generation kept that generation's last offset, but when its reply was lost the retry went out with the offset the claim had loaded. The stored entry was by then the claim's own, so the retry kept nothing and rewound the partition, replaying what had been delivered since. A failed save now retries with the offset and marker the attempt settled on. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: store an offset as read from once the first fetch succeeds A claimed offset lost its claimed marker only when a later save moved it, so a lead that read an empty partition and stopped left it marked as never read. Records published and then removed by retention while no gateway forwarded the target were skipped without a gap counted or logged. The first successful fetch now stores the offset as read from, once per claim, even when it has not moved. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: wait for the stalled topic's publisher before reading it in a test The worker sets the topic publisher up on its own goroutine, which on a loaded host can start after Publish has stopped waiting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep what a timed-out offset check settled for the next one A check for unsettled ranges that could not read every stored offset within its deadline returned nothing, so each retry read the same ranges again and a long enough history kept the new ranges held for good. The listing now returns the positions it read along with the error and goes on past one that fails, and the check probes those and keeps the ranges it finds settled before reporting the failure, so the next check reads only the rest. The ranges stay held until a check covers them all. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * s3: say which records the notification lag counts The lag gauge's help, and the dashboard panel with none, read as every undelivered record, but the records of an old range still being sealed after a repartition cannot be read and are not counted. Both now say the gauge covers the current ranges, the ranges held back behind an older generation, and the sealed retired ranges. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
960230f86d |
mq: keep keyless and valueless messages in compacted parquet (#13258)
* mq: keep keyless and valueless messages in compacted parquet mq.topic.compact treated every message without a key, every message without a value, and every value that happened to parse as a DataMessage with a Ctrl as a control entry, and left it out of the parquet it wrote. Kafka records with a null key and tombstones were gone once retention removed their logs, and so was a JSON string value whose bytes parse that way. The only control entry a log holds is a publisher's close marker, which the broker logged without its Ctrl, as an entry with neither key nor value. That is now the whole rule, for compaction and for reading parquet back. A schematized topic's message without a value is still left out, since its row has no column to hold one. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: ack a publisher's close marker without logging it The marker a publisher sends when it finishes was appended to the partition log like a message, minus its Ctrl, so it took an offset and sat in the log as an entry with neither key nor value that every reader had to recognize and skip. The broker now acks it and moves on. Every message the publisher sent before it on the stream was acked first, so the publisher's wait for its last ack is unchanged. Logs written before still hold markers, which readers keep skipping. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: log a Ctrl message that carries a key or value The close-marker branch dropped every DataMessage with a Ctrl, though one carrying a key or value was published before. Only a bare marker, a Ctrl with neither, is acked without an offset now; anything else is stored at its offset as it was. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * query engine: skip only close markers, as compaction does Compaction now keeps keyless messages and values that happen to parse as a DataMessage with a Ctrl, but the SQL engine still dropped both from log scans and live-log counts, while COUNT(*) took parquet row counts from file stats. After compaction COUNT(*) included messages SELECT did not show. Scans and counts now use the same rule as compaction and parquet reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: leave out a schematized message without a value, as compaction does Compaction writes no row for a schematized message without a value, so a live log count that included one dropped by one once its log was compacted. Scans and live-log counts now skip what compaction skips. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: count only rows among broker-buffered messages The COUNT(*) fast path added every unflushed broker message, so a close marker or a schematized message without a value counted until its flush, when the live-log count left it out. Unflushed messages now count by the same row rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * query engine: test the broker-buffered count against the scan COUNT(*) adds the broker's unflushed messages by the row rule a scan of them uses, but nothing tested it. The count moves into countRows, and the scan test checks it gives the number of rows the scan returns for a schemaless and a schematized topic, so close markers and schematized messages without a value stay out of both. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6a9fe874d7 |
mq: keep a time read's position when nothing on disk follows it (#13259)
A time read that found nothing after its position returned a position at time zero, since the parquet reader reports the newest time it delivered. A loop over an empty memory buffer then read the partition again from the start. The broker's unflushed-message query does exactly that, so once a partition's buffer was flushed and empty it streamed every flushed message as unflushed, and weed sql counted each row twice. The merged reader now keeps the position when it delivers nothing past it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 |
||
|
|
bc1b805c82 |
mq: copy a table-backed topic's sealed log data into its Iceberg table (#13256)
* mq: export logstore's log file offset range and control entry checks The topic table writer decides what is sealed from a partition's file offset ranges and drops the same control entries compaction drops, so it calls these instead of keeping copies. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: tell which of a partition's files its leader will not write again A topic table may only take what is sealed. The fence names a writer and an epoch, not a file, and each flushed window lands whole as a new file under it, so every log file but the one holding the highest offsets is sealed; the newest may still be followed by a window in flight. A sealed fence takes no more windows, so all of its files are. Parquet left by mq.topic.compact rewrites earlier logs and is always sealed. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a topic table's copied offsets in its snapshot summary Each append records seaweedfs.mq.offsets, the first offset of every partition not yet in the table. A snapshot that rewrote files without carrying the map defers to its newest ancestor that has one; a table with snapshots and no map anywhere holds rows of unknown offsets and is not written to. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: build a topic table's rows from log entries A message becomes a row of its table: the system columns from the log entry, then the record's fields by name, or the whole message in _value for a schemaless topic. Rows are laid out in the table's current schema through iceberg-go's Arrow mapping, so the Parquet file they are written as carries the table's field ids and the types Iceberg readers expect. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: compare topic tables by name in topictable The table writer in the worker has to tell whether topic.conf still names the table a job was proposed for, by bucket ARN, namespace and name, the same way the broker compares a configure request with what is stored. The comparison moves next to the rest of the topic table layout so both call it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep a topic table's offset map through maintenance snapshots Compaction, delete rewrites and manifest rewrites keep a table's rows, so the offsets a topic table holds are unchanged by them. Their snapshots now carry the parent's seaweedfs.mq.offsets, so the topic writer and readers find the map on the current snapshot rather than only on an ancestor that snapshot expiry may remove. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: start a table's running totals at its first snapshot Totals were only carried from a parent that recorded them, so a table whose first snapshot the worker wrote never got total-records or total-data-files, and no later snapshot could carry them. A snapshot without a parent adds to an empty table, whose totals are zero. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy a topic's sealed log data into its Iceberg table copyTopicTable reads each partition from the offset the table's current snapshot records up to what its leader has sealed, through the merged reader that already serves log files and compacted parquet, and writes the rows as data files under data/<_partition>/ named by their offset range. A file holds one partition value, so it never spans partitions or days, and its rows are one contiguous offset run in offset order. The append goes through commitWithRetry and records the advanced offset map in seaweedfs.mq.offsets. Each attempt re-checks that topic.conf still names the table and that the table still names the topic, and re-reads the map: a partition another writer moved since this run planned keeps that writer's offset, and this run's files for it are removed, so no offset is appended twice. A run that dies before its commit leaves only unreferenced files for orphan removal. Log files are left in place; the broker cannot read the table yet. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: run mq_topic_table for topics that name an Iceberg table The worker registers an mq_topic_table job beside iceberg_maintenance and runs it in the Iceberg lane. Detection reads every topic.conf under /topics; a topic naming a table is due once one of its partitions has 128 MiB sealed past the table's offsets or a sealed file 5 minutes old. Execution takes the filer lock mq.table.<namespace>.<topic>, so one writer copies a topic at a time, and copies only while topic.conf still names the table the job was proposed for; a topic that left it ends the job without failing it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy only into the table whose UUID topic.conf recorded A table dropped and replaced at the topic's table name still carries the name, and may carry the topic's property if its creator copied it. The broker records the UUID of the table it created or adopted in topic.conf, so the writer checks it before planning and again before each commit attempt, and stops rather than append the topic's offsets to a table that is not the one the topic holds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep keyless and valueless messages in a topic table The table becomes a topic's only copy once copied logs are deleted, and the writer dropped what compaction drops: every message without a key or without a value. Those are data; a Kafka record with a null key is one. The only control entry the log holds is a publisher's close marker, which the broker stores without its Ctrl, as an entry with neither key nor value. IsControlMarker names exactly that, IsControlEntry keeps its wider rule for compaction, and the writer skips markers only. A keyless message gets a null _key. A skipped marker's offset stays below the partition's offset in the map, so the table records it as an offset that held no message rather than a gap left to fill. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: change a topic's table under its table writer's lock A configure that left a table checked it for snapshots, then saved topic.conf. The table writer checks topic.conf before each commit, so a detach saved between that check and the commit's CAS left a table holding the topic's data with no topic. The broker now takes the writer's filer lock, mq.table.<namespace>.<topic>, before the release check and keeps it through the topic.conf save, so it sees what the writer committed, and the writer sees the change before committing. The wait is bounded at 15 seconds: a configure behind a long copy is Unavailable and retried rather than holding the configure RPC. The lock key moves to topictable so the broker and the worker share it. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: make a topic table's record columns optional A field's is_required became a required column, so a message missing that field could not be written and the table writer stopped at its offset. Once copied logs are deleted the table is the topic's only copy, so every message needs a row. Record fields now map to optional columns at every level; the system columns stay required. Adopting a table still refuses one whose record columns are required, since it could not take such a message. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a message its topic's record type cannot hold in _value A schematized topic's tombstone, or a value that is not a RecordValue of its type, stopped the table writer at its offset, and once copied logs are deleted the table is the only copy. Every topic table now has an optional _value column. A message whose value is empty, does not parse, carries bytes a RecordValue does not have, names a field the table lacks, or holds a value its column cannot take gets null record columns and its raw bytes in _value. A decoded message leaves _value null. A row is checked whole before any column takes it, so a fallback leaves no partial row behind. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: copy a topic's history into its table in bounded runs A run read every sealed offset past the table's map and committed only at the end, so a topic attached with a long history could not finish within the job's one-hour timeout: each attempt rewrote the same files, removed them on cancel, and the map never moved. A run now stops at a file boundary once it has written 4 GiB and commits the offsets its files cover; the next detection picks up the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: decode a record read back from compacted parquet into its columns logstore's parquet reader hands back a schematized row as its RecordValue, which still holds the file's _ts_ns, _key and _offset columns. The row writer took those for fields outside the table, so every message the copy read from mq.topic.compact's parquet landed as raw _value with null record columns. Those three fields are the entry's own and are now passed over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: map a repeated field already typed as a list to one list The Kafka protobuf and JSON Schema decoders describe a repeated field with both a ListType and IsRepeated, and their values are one ListValue deep. mapField wrapped the list type again, so the column became list<list<T>> and every message with a non-empty repeated field fell back to raw _value. Avro gives the item type with IsRepeated, which still gets wrapped once. MQ's own parquet schema already ignores IsRepeated on a list type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: keep a decimal past its column's precision in _value rescaleDecimal checked only that the rescaled value fit 128 bits, so an unscaled value from 10^38 up to 2^127 was written into the decimal(38,18) column, which engines then read as an overflow or null. The value is now checked against the column's precision, so such a message keeps its raw bytes in _value like any other value the record type cannot hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound a published decimal before rescaling it A DecimalValue's scale, precision and bytes come from the publisher, and rescaling to the column built 10^|18-scale| before checking anything, so one message with an extreme scale could hold a worker's CPU and memory on every retry of the copy. A scale or precision beyond the column's 38 digits, or a magnitude longer than 32 bytes, cannot fit decimal(38, 18) and is refused before any arithmetic; the message keeps its row with its bytes in _value like any other value its column cannot take. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep a topic table's files when its commit's outcome is unknown A commit whose update of the table entry failed without an answer, a reset connection or a deadline, may still have been applied by the filer. The run then deleted its data files and manifests, and commitWithRetry its new metadata file, leaving a committed snapshot pointing at files that were gone. Such a failure is now errCommitOutcomeUnknown, and commitWithRetry keeps the metadata file for it. The topic table writer reads the table again: a snapshot it built that is in the current lineage is a commit, kept and reported as one. Otherwise, or when the table cannot be read, the files stay for orphan removal, since an update still in flight could land after the read. Only a refused commit, a conflict or a stopped run, deletes them. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: count a partition's rows after its last flush copyPartition returned total and flush() in one statement, and Go does not order reading total against calling flush, so the rows of the last file could be left out of the count. The last flush now runs first. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: report the rows a topic table commit kept A run's rows_written was every row it staged, though a commit attempt drops the files of a partition another writer already moved, and a run that commits nothing reported its staged rows all the same. It is now the record count of the files the committed snapshot added. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: wait for a topic's table writer outside topicConfLock A configure that moved a topic off its table waited up to 15 seconds for the table writer's lock while holding topicConfLock, which every configure, lookup cache miss and rebalance of every topic takes, and a caller that gave up kept waiting. The configure now reads topic.conf first and, when the request moves the topic off the table it names, takes the writer's lock before topicConfLock, the order the writer keeps since it never takes topicConfLock. The wait ends when the caller's context does, and a grant that arrives after that is released. A configure that finds the table changed under topicConfLock without holding the writer's lock is Unavailable and retried. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq broker: bound the topic.conf read a table change starts with The read that decides whether a configure must wait for the table writer runs before topicConfLock, and so before the 30 second bound lockTopicConf puts on calls made under it. A caller without a deadline then hung on a filer that took the read and never answered. The read now gets the same bound of its own, still outside topicConfLock. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: keep what an unanswered maintenance commit may reference Compaction, delete rewrite and manifest rewrite delete everything they wrote when their commit fails. When the failure is an update of the table entry that went unanswered, the filer may have applied it, and the table then points at data files, manifests and a manifest list that were just deleted. Those are now left for orphan removal on errCommitOutcomeUnknown, as the topic table writer already does; conflicts and other definite failures still clean up. Snapshot expiry deletes nothing before its commit succeeds and needed no change. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: test a topic table retry that keeps only one partition's files A run whose commit loses to a writer that copied only one of its partitions keeps the other partition's file. The test checks that the retry reports only that file's rows and that each offset lands once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: wait for the detach's refused lock request in the table lock test A fixed sleep did not show the detach had reached the table lock, so a late goroutine let the lookup pass with nothing waiting. The fake filer now counts refused lock requests and the test waits for the first one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: check the table writer's lock before saving a table change A configure that moves a topic off its table holds the writer's lock from its release check through the topic.conf save, but never looked at it again. A lease that lapsed meanwhile, its renewals failing, may already be the writer's, which can then commit to the table the configure is about to detach. The configure now checks that it still holds the lock right before the save and is Unavailable otherwise. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: check a topic table copy's lock and topic last before committing Each commit attempt checked the lock, topic.conf and the table's owner before writing its manifests and manifest list, and nothing after, so a lease that lapsed or a detach that landed while they were written went unnoticed. The attempt now checks again once they are written, the last step before commitWithRetry saves the metadata file and updates the table pointer. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * worker: read a topic's conf with the topic table job's context The table writer and detection read topic.conf with ReadConfFile, which takes no context, so a filer that took the read and never answered held the job, its worker slot and its renewed table lock, and held up detection, past any cancel. They now read through ReadConfFileWithMetadata with the job's or the detection's context, so a cancelled job ends and lets its lock go. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |