mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
cd0f60a2f0858c07ea202b00ebf8df19e65a10a2
1087
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1858665311 |
util/http, operation, topology: give the DELETE helpers a deadline (#13333)
* util/http, operation, topology: give the DELETE helpers a deadline Delete and DeleteProxied made their request without a context and read the whole answer. Only the shared client's 30 s response header timeout bounded them, and nothing bounded an answer whose body never ends. - The cleanup after a failed chunk upload (deleteChunkFromHolders, used by PutObject and every chunked upload) asks the holder that just failed the write, often the one that stalls. A holder that did not answer held the upload for 30 s per holder and attempt, with the chunk's buffer. One that sent its headers and stalled held it for good, and the holders after it were never asked. Each delete is now bounded by cleanupDeleteTimeout (10 s), as the copy path's cleanup is by copyCleanupTimeout (#13297). A delete that runs out is logged and leaves the needle, as a failed delete did before. - A delete forwarded to a replica that does not answer held the primary's DELETE for 30 s, while a forwarded write fails at replicaRequestTimeout. The delete forward now has the same bound, as the Rust volume server's replica_request already gives deletes. Its timeout is counted as a timeout, through replicaDeadlineError, which the write forward uses as well. Delete and DeleteProxied take a context. benchmark and the unmaintained repeated_vacuum pass context.Background(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: let a replica's failure leave the other replica deletes running DistributedOperation cancels its context when the first replica fails, and the delete deadline was derived from it, so a sibling's failure could cut the deletes to the other replicas short. The old context-free Delete kept them going, and they must: the needle is gone on this server already, so a replica that is not asked keeps its copy. Each delete now takes its deadline from context.Background(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * topology: read the replica delete bound once, before the fan-out A replica delete that outlives ReplicatedDelete read the package bound again after its answer, racing a later caller that changes it. 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> |
||
|
|
5e4b2fc42f |
docker: one FIPS mode for the Go processes and the Rust binaries (#13296)
* docker: one FIPS mode for the Go processes and the Rust binaries In the image, Go processes ran with fips140=on by default (#7590) while the Rust binaries, which take their mode from fips.mode alone, ran with unrestricted TLS; and WEED_FIPS_MODE=off or strict made every Go process refuse to start, since the entrypoint's fips140=on did not match. The entrypoint now states the image's mode once, as WEED_FIPS_MODE_DEFAULT=on, and gives Go processes the fips140 GODEBUG that matches WEED_FIPS_MODE, else that default. The Rust binaries use the default when neither WEED_FIPS_MODE nor fips.mode sets a mode; Go processes check their GODEBUG against it and refuse to start on a mismatch, naming WEED_FIPS_MODE as the way to pick another mode. Setting WEED_FIPS_MODE_DEFAULT empty leaves every process in its own default, as outside the image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docker: take the image's FIPS mode from a fips140 the caller sets GODEBUG=fips140=off, the entrypoint's advice since #7590, made every Go process exit once the Rust binaries joined the image's mode. The entrypoint now maps the caller's fips140 to WEED_FIPS_MODE_DEFAULT, so Go and Rust run in that mode and the old advice keeps working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docker: say fips.mode alone cannot change the image's FIPS mode Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docker: read an empty fips140 as off and debug as on, as Go does Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docker: warn when GODEBUG fips140 picks the image's FIPS mode The entrypoint keeps translating a caller's fips140 into the mode for the Rust binaries, so existing docker run setups keep starting, but logs that WEED_FIPS_MODE is the setting that also covers launches without the entrypoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docker: set the FIPS mode after dropping privileges Running as root, the entrypoint re-runs itself through su-exec, and the second pass took the fips140 the first pass had exported for the caller's own, warning on default starts and prepending fips140 twice. 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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
2cde975c25 |
mq: read, list and purge the ranges a repartition retires (#13249)
* mq: seal a partition's fence when a repartition drains it Draining a partition shut it down and answered at once: its last window was still being flushed, and its fence was left unsealed. A publisher still holding the old assignment could then load the range again on its leader at the same epoch and append to a range the topic no longer lists, so nothing could treat a removed range as complete. The drain now waits for the last flush, waiting out a retirement already pending too, and seals the fence before it answers; a drained range its leader does not have loaded has its stored fence sealed as found. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: serve a sealed range a repartition removed from its files A repartition drops the old ranges from the topic, and a fetch for one was answered partition not found, so whatever a consumer had not read from it was out of reach. A fetch naming a generation and range the topic no longer assigns, whose fence is sealed, is now served read-only by any broker: a stopped log buffer over the range's files, with its log start and high-water mark read from them, answers through the same stateless read as a live partition, out-of-range included. A reader is reused for 30 seconds, so a purge elsewhere shows soon. An unassigned range whose fence is not sealed may still take writes and keeps the old answer. The test filer can now keep what is uploaded to it, so flushed windows read back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: list a topic's retired ranges in the partition lookup LookupTopicBrokers takes include_retired and then also answers retired_partitions: each sealed range of an earlier generation the topic no longer assigns that still holds data, with its log start and high-water mark, read from the range's files. A consumer can find what a repartition left behind and fetch it. Unsealed ranges are left out, since they may still take writes. The test filer lists the directories an entry's path implies, as the filer does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: purge retired ranges past retention The retention pass hands each partition with expired files to its leader, but it walked only the topic's current assignments, so a range a repartition retired kept its files forever. The balancer now purges each sealed retired range itself, deleting its expired files under the sealed fence as read. As for a live partition the newest file stays, so the range keeps its high-water mark and a read below the raised log start is out of range. The purging broker drops its cached reader of the range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: the offset scan of a partition's files stops with its caller Retired fetches and listings, the retention pass and a follower take-over now pass their context to the filer scan, so a cancelled lookup or a broker shutting down does not wait on a filer that stops sending entries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: drain a repartition's old ranges only after saving the new topic.conf A repartition drained the old ranges before saving the topic.conf that replaces them, and a drain now seals them. When that save failed, the ranges topic.conf still assigned were sealed: their leader could not take their fence again, and with every broker healthy nothing moved the epoch on, so the topic took no more writes. The old ranges are now drained after the save, so a failed save leaves them assigned, unsealed and writable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: leave a drained range's fence to a holder still renewing it A drained range its leader had not loaded had its stored fence sealed as found. If a follower had taken that fence over and was still storing the records it acked, the seal replaced its token, so its remaining writes failed the fence check and those records never reached the range. The drain now seals a found fence only once nobody has renewed it for fenceSealWait, the same test a new leader applies; a holder still renewing it seals it itself when done, and the drain waits for that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: seal a range drained while its broker shuts down Once a broker shutdown has started it retires every partition itself, so removing one for a drain reports false, and the drain answered success without sealing the range. It now waits for the shutdown's last flush of the partition and seals the fence like any other drain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: read retired ranges without a log buffer, dropping old readers on access Each retired range's reader was a stopped log buffer, which still allocated the buffers and windows a writer needs, and cached readers past their time were dropped only when another was created. A retired range is now read through ReadFlushedMessagesAtOffset, the stateless disk read with its chunk cache and nothing else, answering out-of-range and end of partition as a live buffer does; the disk read helpers take the read function and cache instead of a buffer. Readers past retiredReaderTTL are dropped on every lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: bound the retention pass over retired ranges The pass over a topic's retired ranges ran under the broker's own context, so a filer that stopped answering its listing or offset scan held the balancer's retention loop for good. Each topic's pass over its retired ranges now has generationPassTimeout, as handing expired partitions to their leaders does. The test also covers a fetch of a retired range returning with its caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: a drain seals a stale fence only as it read it A drained range its leader had not loaded is sealed once its fence has gone fenceSealWait without a renewal. The seal required only the fence's token, which a renewal keeps, so a holder that renewed between the drain's read and its seal still had the fence sealed under it, and its remaining writes failed the fence check. The seal now requires the entry as read, as a new leader's take does, and a drain that loses that race looks again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: finish the drains a stopped balancer left behind A repartition saves the new topic.conf and then drains the old ranges. A balancer that stopped in between left them unsealed, and nothing came back to them: repair looks only at topic.conf, and retired reads, listing and retention skip unsealed ranges, so their records were out of reach. The balancer's periodic pass now also looks for range directories that topic.conf no longer names and whose fence is unsealed, and asks the broker holding the fence to drain the range, which flushes what it holds and seals it. A holder that does not answer is drained by the balancer itself, which seals the fence only once nobody has renewed it for fenceSealWait. Each topic's pass is bounded by generationPassTimeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: finish a predecessor's drains on taking the balancer lock The pass that finishes drains a stopped balancer left behind ran only with the retention loop, so after a balancer restart its old ranges could stay unsealed, and unreadable, for up to five minutes. A broker that finds itself the balancer now runs the pass once right away in the background, bounded per topic as the periodic one is, so the wait is down to the fenceSealWait rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: report a drain's error on the test goroutine Two drain tests ran the drain, which fails the test on error, in a goroutine of their own, where failing only ends that goroutine and leaves the test waiting or passing on what it saw. The drain's error now comes back over the channel the test already waits on, and the test fails there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: drain a repartition's replaced ranges outside the topic.conf lock A repartition drained the replaced ranges while it still held topicConfLock, under the lock's 30-second deadline, and the drain now waits for each range's last flush and seal. A slow flush held every cache-miss read of topic.conf behind the lock, could run the shared deadline out and leave a range unsealed, and left the new ranges' assignment to a context that had already expired. The new ranges are now assigned under the lock, and the replaced ones drained after it is released, with a deadline of their own sized for a flush and a seal that may wait out fenceSealWait. A range the drain does not get to is finished by the balancer's pass over orphaned ranges. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: move a retired read past offsets no stored entry holds A read of a retired range at an offset no stored entry holds, below the high-water mark, answered no records with the same next offset and no end of partition, so a consumer asked for that offset again forever. Such a stretch is a gap in the offsets or entries the log could not place. The read now looks for the lowest stored offset after it and reads from there, and when none is held up to the high-water mark it answers the end of the partition at the high-water mark. Below the log start the read is still out of range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: serve a client only the partition generation it names A partition is found by its range alone, so a fetch naming an older generation of a range the topic still assigns, not sealed and so not read as retired, was answered from the live partition of the newer generation: the client read records of a generation it never asked for, at offsets that mean something else there. A client that names a generation now gets only that one: one that is not the assigned generation, or not the one loaded, is refused with the partition not found a removed unsealed range gets. A client that names none still matches by range. A publisher refused this way looks the topic up again, as it does when the balancer is ahead of the cached topic.conf, and the unflushed-message query and the flush notification check the generation too. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: decide orphaned ranges under the topic.conf lock from the stored conf The pass that finishes unfinished drains took topic.conf from the cache and listed the stored ranges without the topic.conf lock. A balancer just elected with a stale cache, or a repartition saving its new generation between the read and the listing, made current ranges look orphaned, and they were drained and sealed. The pass now takes topicConfLock, reads topic.conf from the filer, lists the stored ranges and decides under it, then drains what it found once the lock is released; a repartition cannot assign a generation that is already gone, so the decision holds. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: drain only the partition generation a drain names A drain found the loaded partition by its boundaries alone. A topic repartitioned 1 -> 2 -> 1 has its first range and its current one on the same boundaries, so finishing the first one's unfinished drain removed and sealed the current range instead. A drain naming a generation now takes a loaded partition only of that generation; otherwise it seals the named generation's stored fence, as for a range its leader has not loaded. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: leave an orphaned range's own drain time when its holder stalls Finishing an orphaned range's drain asks the broker holding its fence first and drains the range itself when that fails. The holder's call had the whole per-topic deadline, so a holder that took the call and never answered used it up, and the drain here then ran on an expired context and did nothing. The holder now gets half the time that is left, keeping the rest for the drain here. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: end an unflushed query a broker would redirect to itself A broker still holding an older generation of a range it now leads under a newer one refuses a query for the newer generation, looks the range up, finds itself as the leader, and redirected the query to itself, which did the same again until the caller gave up. When the lookup names this broker the query now ends with an error saying the generation is assigned here but not loaded; a lookup naming another broker is still followed. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: refuse a loaded generation the topic no longer assigns After a split the old range stays loaded on its broker until the drain unloads and seals it. A fetch naming that generation passed the generation check, since no assignment shares its range any more, and was served from a buffer that is neither assigned nor sealed. A loaded partition is now served by generation only while topic.conf assigns it; the cache is reread once before refusing, so a broker whose cache predates the assignment that loaded the partition still serves it. Once the drain unloads and seals it, the retired reader serves it from its files. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq logstore: retry a parquet reader whose topic.conf read failed The parquet reader reads topic.conf once, when it is built, and a failed read left it a reader that finds nothing, for good. A merged offset read then skipped the compacted offsets to the first log file, and a sealed partition's reader, finding nothing stored, ended the partition at its high water mark. The reader is now set up on its first read and again on each read while topic.conf cannot be read, failing those reads; a topic.conf that does not exist still means no compacted rows. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: keep a drained range from reloading until its seal lands A drain unlisted the range once its last flush landed, before sealing its fence. A publisher whose topic.conf cache still assigned the range to this broker could load it again in between, take the fence at the same epoch, and make the seal fail, leaving the range unsealed after the repartition. The drain now holds the range as retiring until its seal returns, so a loader waits and then finds the fence sealed. A failed seal releases it, unsealed and unassigned, for the orphan pass. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 * mq: seal a drained range only once all it accepted is stored A drain sealed the fence after the partition's last flush returned, without asking whether that flush stored anything. A flush abandoned when a broker stop ran out its flush budget drops the window and breaks the follow stream so the follower stores its copy, but the seal could land first, and the follower, finding the fence sealed, gave up records the leader had acknowledged. The drain now seals only when the flushed watermark reaches the last accepted offset; otherwise it leaves the fence to the follower and fails, and a later drain or the orphan pass finds it sealed by the follower or seals it once it is stale. Claude-Session: https://claude.ai/code/session_011Upvai5AjLiNE5B1HCAn34 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
a8f13e7db2 |
filer: keep a PUT under /etc inline like a POST (#13241)
* filer: keep a PUT under /etc inline like a POST The write handler marks /etc paths (and saveInside=true) to be stored as inline content, but only the multipart POST path honoured it. A plain PUT went through the chunk uploader, which keeps content inline only below saveToFilerLimit, 0 by default, so `curl -T x.json http://filer/etc/...` stored chunks and the loaders that read /etc files from inline content saw nothing. Both paths now share one saveInside write: read the body, check Content-Md5, store it as the entry's content. An append to a chunked file is refused for PUT as it already was for POST, and an offset write is refused for both instead of being treated as a whole-file write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: skip the saveInside PUT digest checks under fips140=only GODEBUG=fips140=only refuses MD5: the filer neither checks Content-Md5 nor reports Content-MD5, and crypto/md5 panics. The bad-digest test is skipped there, and the inline-store test checks the digest only when MD5 is available while always checking the content is inline with no chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: answer a malformed write offset with 400 A negative, non-numeric or overflowing ?offset, and an offset with op=append, were plain errors that the write handler answered with 500, while a positive offset to inline content got 400. Both the inline and the chunk path now parse it through one helper whose error carries the ErrMsgInvalidOffset prefix, mapped to 400. offset=0 stays a whole write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: charge a saveInside PUT its whole body like a POST A PUT stored inside the entry is now buffered whole by saveInsideEntry, but uploadCharge still charged it by chunks, so -concurrentUploadLimitMB no longer bounded the memory it holds. It is charged as the POST is: its declared length, at most the whole budget, or the whole budget when the length is unknown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound a body stored inside the entry at 16 MiB A saveInside or /etc upload is read into memory whole, and nothing capped it: one PUT or POST could grow the filer's memory without bound, as the upload charge limits concurrency rather than bytes. The read now stops at 16 MiB, far above any config file, and a larger body is answered 413 with nothing stored, whether or not its length was declared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep inline storage to entries inside /etc/ The /etc check was a bare string prefix, so a PUT to /etcd-backup/snap.db or /etcetera took the saveInside path and a large body was refused with 413 instead of chunked. Match /etc/ as a directory for the write, upload charge and zip extract paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound a zip member kept inline like a saveInside upload A zip member extracted under /etc/ (or with saveInside=true) is read into memory whole, but was bounded only by the 1 TiB archive limit. Refuse a member over saveInsideMaxBytes, as a PUT or POST body is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep a multipart POST to the bare /etc directory inline A POST to /etc with a file name lands the file inside the /etc directory, but the /etc/ prefix check missed the bare path and stored it as chunks. Match /etc itself as well as entries under it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
52afabbf1b |
mq: avoid a deadlock when retiring a partition with a full flush queue (#13225)
* mq: let partition retirement drain a full flush queue outside broker locks * log_buffer: queue the final flush from ShutdownLogBuffer itself Every ShutdownLogBuffer caller already waits afterwards with WaitForShutdown or IsAllFlushed, so queueing the final flush in the background changes no caller's outcome and lets every caller holding a lock a flush callback needs avoid the full-queue deadlock, without a second shutdown entry point. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ec1032d642 |
filer.remote.sync: a source chunk gone for good no longer wedges the write-back (#13220)
* filer.remote.sync: a source chunk gone for good no longer wedges the write-back
An entry whose chunk the volume servers answer 404 for, even with
readDeleted=true, can never be uploaded: the bytes no longer exist in the
cluster. A volume lost with its disk leaves such entries behind (for
example a filer restored from a metadata backup onto a new volume server
while some chunks had not been written back yet). filer.remote.sync
retried the create event forever, every ~2 s, and since a failing event
holds the directory's processed watermark, no later change under the
mount was ever written back again. We hit this in production: one photo's
chunk answered 404 for hours and more than 11,000 later changes waited
behind it.
Now, once the filer confirms the entry is still the one the event
described (the existing supersession check), the upload ends with
errSourceGone when:
- every location answered 404 for sourceGoneGrace (5 min) over
sourceGoneMinAnswers (3) attempts in a row, or
- the master cannot locate the chunk's volume at all ("failed to locate",
the whole volume lost with its disk) for sourceGoneLookupGrace (30 min,
the filer deletion retry's figure for "volume not found").
It logs one ERROR line naming the path, the chunk's fid and the
destination, with a per-process count, and every caller treats the event
as handled so the offset advances. A path found gone is remembered with
its fid (bounded to 10,000), so later events of the same entry are skipped
at once; any other outcome (success, superseded, another error, a failed
supersession lookup) forgets it and starts the grace again, so a volume
server that has not loaded its volume yet, or a stale location, is not
mistaken for lost data.
Only the source decides. The upload body is wrapped in a recorder that
keeps the first error the chunk reader returned, because remote clients
wrap a body read failure in their own errors (the AWS SDK's RequestError
has no Unwrap). The recorder forwards ReadAt and Seek, so s3manager keeps
reading parts in place. A 404, 5xx, timeout or any other error from the
remote itself never reaches the recorder and keeps retrying as before.
A rename of an entry that was written back now deletes the old key only
after the new one is written: when the entry's local data is gone, the old
key keeps the last remote copy (logged) instead of being deleted before an
upload that can never succeed. The gateway's rename path, which deletes
first, does not acknowledge errSourceGone and keeps failing visibly.
util/http:
- GetAuthenticated (the encrypted chunk read) reports a 404 as ErrNotFound,
as the unencrypted read paths already do, with the same error text;
readEncryptedUrl wraps with %w instead of %v and treats a 404 as
retryable, like the plain read, so it tries the other locations.
- A chunk read is ErrNotFound only when no location of the pass failed
differently (NotFoundEverywhere): a 404 from one replica while another is
down, answers 5xx or is throttled does not mean the chunk is gone. This
is applied once in hedgedChunkPass (both RetriedFetchChunkData paths) and
in the manifest's retriedStreamFetchChunkData loop.
Tests:
- filer_remote_sync_gone_test.go: a plain and an encrypted chunk served 404
by a test volume server end in errSourceGone on the third attempt and are
counted once; a remote that answers 404 with readable chunks never does;
the tracker's grace, answer count, reset, fid change and remembered path;
the lookup-miss grace; ReaderAt kept by the recorder; a rename keeps the
old key when the entry is gone and deletes it after the write otherwise.
- TestGetAuthenticatedNotFound; TestRetriedFetchChunkDataNotFoundEverywhere
(plain direct, plain stream, encrypted; a 404 and a 503 in either order
is not ErrNotFound).
- Mutation checks: each fails with readEncryptedUrl back on %v, with the
write error classified instead of the body's read error, with
NotFoundEverywhere dropped from hedgedChunkPass, with the old key deleted
first, and with the recorder hiding ReadAt.
- go vet and go test of weed/util/http, weed/command, weed/filer and
weed/replication/... pass; weed/util/http also with -race.
* filer.remote.sync: renames keep the old key until the new one holds the content; gone is per entry; missing volumes opt-in
- A sighting is counted per entry content (the sorted chunk file ids),
not per failing chunk. An uploader reads the parts of a ReaderAt body in
parallel, so the chunk that fails first changes between attempts; keyed
on it, the grace restarted every time and a large file missing several
chunks held the offset forever. The tracker's `seen` map is bounded, and
the log names the first chunk "and N more" instead of every fid.
- On every rename the old key is deleted only after the new one holds the
content: also when the event's old entry carries no stamp (an upload
whose stamp a rename in between refused leaves an unstamped copy), and
in the superseded branch, where the old key is what uploadCurrentEntry
copies a remote-only entry from. uploadCurrentEntry reports when the
current entry's data is gone, and the old key stays then. A multipart or
system path whose old key cannot be deleted no longer skips the stamp.
- A volume the master cannot locate counts only with
-sourceGoneVolumeMissing=<duration> (default 0: never): a volume server
that is down or in maintenance looks the same, and an entry written off
is not retried. It suits a deployment whose master and volume server run
as one process.
- filer.remote.gateway's rename writes the new key first, deletes the old
object after, and keeps it when the source data is gone.
Tests: TestRetriedWriteFileSourceGoneAcrossChunks (two lost chunks read in
turn), TestSupersededRenameUploadsCurrentEntry "uncached between the check
and the upload" and "current entry's chunks gone: the old key stays",
TestRenameOfGoneEntryKeepsTheOldKey "old entry unstamped",
TestSourceGoneGraceFor (lookup miss off by default, on with the flag);
each fails with its fix undone. The test remote's DeleteFile removes the
object, as a real remote does.
* filer.remote.sync: evidence kinds apart, a gone entry counted once, the copy owns its source's cleanup; gateway keeps the old object on a superseded rename
- Lookup misses and 404s no longer share one run of sightings
(sightingKey = content + grace): with -sourceGoneVolumeMissing set, a few
minutes of "failed to locate" followed by one 404 met the 404 grace with
the misses' start and answers.
- observe reports whether this call found the entry gone; a replayed event
of an entry already gone is skipped without another log line or count.
- A superseded rename whose current entry is remote-only leaves the old key
to completeRemoteOnlyRename, which removes its source only while it is
the object the stamp describes; an unconditional delete after it could
remove a replacement.
- filer.remote.gateway: a superseded rename keeps the old object (logged)
instead of deleting it before the superseding event has written the new
key.
Tests: TestSourceGoneTrackerCountsOnceAndKeepsEvidenceApart,
TestSupersededRenameUploadsCurrentEntry "the old key replaced during the
copy"; each fails with its fix undone. The gateway change has no test of its
own (its rename path needs a reachable filer).
* filer.remote.sync: drop -sourceGoneVolumeMissing, a lookup miss keeps retrying
A volume the master cannot locate looks the same whether it was lost or
its server is down, so no default can write such an entry off safely, and
a flag for the one-process layout is not worth carrying. Only a 404 from
every location counts as gone; a lookup miss retries as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.gateway: a superseded rename settles its old object
A rename the filer has moved past kept the renamed-from object for good,
so every rename followed by a delete or a rewrite before the gateway
reached it left an orphan on the remote. Settle it the way
filer.remote.sync's uploadCurrentEntry does: copy from it when the entry
has become remote-only, and otherwise delete it, since it no longer holds
the entry's content.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.sync, filer.remote.gateway: a superseded rename copied from a later rename's source settles its own old key
When the entry became remote-only through another rename onto it, the copy
reads that rename's source and removes it, and nothing read or removed the
event's own old key any more. Delete it then, in both commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.remote.gateway: reset cached remote clients after the superseded-rename test
A cached client kept the previous run's recorder, so the test failed under
-count above one.
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>
|
||
|
|
746cae3895 |
mq: enforce topic retention (#13210)
* log_buffer: find a fetched offset in a disk chunk by its offset A stateless read caches disk reads in chunks aligned to 1000 offsets and picked the requested message by its distance from the aligned start. A chunk read from disk begins at the first offset stored at or above that start, so once the partition's oldest files are gone the chunk begins later and the read returned messages from further on, under the requested offsets. The message is now found by its offset, and the next offset follows the last message returned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: start a loaded partition's log at its earliest stored offset A loaded partition reported its earliest offset as 0 and its log start as the start of its memory, so neither said where the stored data begins. The log buffer now keeps the earliest offset still stored: a leader seeds it from the offset ranges on its files when it loads, it only moves up, and the partition's offset info and log start report it. A stateless read below it fails with ErrOffsetOutOfRange instead of being answered from a later file under the requested offsets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: purge a partition's files past its topic's retention A topic's retention was stored but never applied, so a topic that is not re-partitioned kept every flushed file. Every five minutes the broker now purges each partition it leads whose topic has retention enabled. It deletes the oldest run of files whose newest message is older than the retention, stopping at the first file still retained so the stored offsets stay contiguous, and always keeps the file with the highest offset, which a later load continues offsets from. A log file is judged by when it was flushed and a parquet file by its newest row; a parquet file is deleted together with its source log files. The partition's log start is raised before the deletes, and each delete is a transaction conditioned on the partition's fence token, so a leader that lost its fence deletes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/kafka: map an unknown broker error to UNKNOWN_SERVER_ERROR (-1) The gateway's error table gave UNKNOWN_SERVER_ERROR the code 1, which Kafka uses for OFFSET_OUT_OF_RANGE, and the broker's table carried the same value for its unknown and publisher-not-found errors. Today the mapped code only reaches error text, but a fetch path that answers OFFSET_OUT_OF_RANGE by its Kafka code would make every unknown broker failure reset a consumer. The code is now -1. The gateway only tests these codes against 0 and against specific codes, and the cached assignment is still dropped on the broker's own code 1, so nothing treated 1 as success or depended on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: answer a fetch below retention with OFFSET_OUT_OF_RANGE A read below the earliest retained offset failed like any other read, so FetchMessage reported a storage error and the gateway answered KAFKA_STORAGE_ERROR, which a consumer retries at the same offset forever once retention has purged it. FetchMessage now answers ErrOffsetOutOfRange with its own broker code, the earliest retained offset as LogStartOffset, and the requested offset as NextOffset. The gateway carries it as ErrOffsetOutOfRange and answers the partition with OFFSET_OUT_OF_RANGE, so the consumer applies auto.offset.reset; a reset to earliest asks ListOffsets, which reports the retained start through the leader's range info. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * log_buffer: keep a disk chunk's entries in offset order A disk read filled its 1000-offset chunk with the first 1000 entries in the order the files listed, and the lookup searches the chunk by offset. Files whose names sort out of offset order deliver entries out of order, so the chunk held the wrong offsets and was cached that way. It now keeps only the chunk's offsets, wherever they come, and sorts them before caching. * mq broker: purge a partition's files in offset order The purge walked a partition's files in name order and stopped at the first one still retained. Names sort by the start of a window, which can be earlier than older files' after a reload, so a file holding higher offsets could be purged ahead of a retained one below it, leaving a hole. The walk now goes by each file's first offset, taking a parquet file that records none from its first source, and by name among equals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: round a log file's flush time up to bound its messages A log file without a recorded newest timestamp is judged by its Mtime, which the filer keeps in whole seconds, so a file flushed later in the cutoff's second looked older than messages it may hold. The purge now takes the end of that second as the bound. A recorded newest timestamp is still used as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * log_buffer: keep one entry per offset in a disk chunk A disk read goes through a partition's log files and then its parquet files, and a parquet file holds the same offsets as the log files it was compacted from, so a chunk could take an offset twice and a fetch returned the duplicate as the next message. The chunk now keeps the first entry for each offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * log_buffer: reread a cached disk chunk that lacks the fetched offset A disk chunk can be cached while its later offsets are still in memory. Once those are flushed and memory moves on, a fetch past the cached part hit the cache, found nothing, and returned no messages until the chunk was evicted. A cached chunk that does not hold the fetched offset is now dropped and read from disk again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: record a parquet file's offset range from its sources The compactor took a parquet file's offset range from its entries' offsets above 0 and recorded it only when the lowest was above 0, so a file compacted from a partition's first window recorded no range, and one whose entries started at 0 would have claimed to start at 1. The range now comes from the source log files' recorded ranges, including one that starts at offset 0, and is left out unless every source records one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq: keep the earliest offset at or below files that record no range The earliest stored offset was the lowest offset any file records, so a file that records none, such as a parquet file compacted from a partition's first window or a log file flushed without a range, was left out. A reload or a purge could then start the log above offsets a read can still return, and ListOffsets for the earliest offset left them out. OffsetRange now takes the whole entry and keeps the earliest offset at 0 while a log or parquet file records no range, except a parquet file whose listed sources are all present, as their ranges cover it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: keep a partition whose files cannot all be placed by offset The purge ordered a data file that records no offsets, and whose sources give none, as if it held the lowest, so an expired one could be deleted while a retained file below its offsets stayed, leaving a hole. A partition holding such a file is now left alone; only files written before offsets were recorded lack them. * mq broker: purge a parquet file only when each of its sources has expired The purge deleted every source of an expired parquet file along with it, judging the whole group by the parquet file's newest timestamp. Message timestamps are not ordered across reloads, so a parquet file can hold an expired source next to one still retained, and the retained one went early. A parquet group is now purged only when the parquet file and each source in it are past the cutoff on their own; otherwise the walk stops there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: record a parquet file's lowest and highest timestamps The compactor recorded a parquet file's timestamp range from its first and last rows. Message timestamps are not ordered across reloads, so the last row need not be the newest, and the recorded ts_max could sit below messages the file holds, making it look older to the retention purge and to readers that skip files by time. It now records the lowest and highest timestamps over all rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: keep each compacted row's offset in the _offset column The compaction schema had no _offset column, so a schematized row's offset was dropped and a schemaless row never carried one, while the parquet reader expects the column and a fetch places rows by offset. The compactor now adds the column when the schema lacks it and fills it for every row, schemaless ones included, when the source files record their offsets; otherwise it is left null. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: read a parquet file by its own columns and mark unknown offsets The parquet reader always expected an _offset column and read rows by column position, so a file compacted before the column existed was read out of alignment and panicked with an index out of range. A row with no real offset also read back as offset 0, so a disk chunk, which keeps one entry per offset, collapsed such rows into one. The reader now uses the _offset column only when the file has it, trusts it only when the file records its offset range, and reports any other row with offset -1, which keeps it out of reads by offset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: keep a purge group that reaches past the first retained offset A parquet file is purged with its sources as one group, and the sources need not be contiguous: an expired parquet file could list expired files on both sides of a retained one, so purging the group left a hole above the retained file. A group now goes only when every offset it and its sources cover lies below the first offset left behind; the walk keeps the first group that does not, and the ones after it. A log file whose offsets a retained parquet file also starts at now stays until that parquet file goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: give compaction test fixtures file ids no other fixture uses The parquet reader caches chunks in a package-wide cache keyed by file id, and each compaction fixture numbered its file ids from 1, so one fixture could read another's cached bytes; with -count=3 a test read a parquet file from an earlier run and failed. File ids are now numbered across all fixtures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq/logstore: compact legacy log files apart from ones that record offsets A compaction group could hold a legacy log file without an offset range next to files that record one, and a parquet file keeps its rows' offsets only when every source records them, so the ranged rows lost their offsets and could no longer be fetched by offset. Groups now split where a file's having an offset range differs from the group's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: treat a parquet file's end as unknown when a source is gone A parquet file that records no offset range took its last offset from the sources still present, so one whose later source was already gone looked as if it ended below a retained file and was purged, though it may hold that source's offsets above the retained one. A gone or unranged source now leaves the end unknown, and the group stays. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d63c225d78 |
mq: replicate each partition to a follower and hand it to a new pair when one is lost (#13203)
* mq: carry offsets, epoch and heartbeats on the follow stream The follow stream sent the publisher's raw message, so the follower could not keep the leader's offsets, and nothing named the generation or told a quiet leader from a dead one. The stream now carries log entries with their offsets, the epoch and leader in its init, heartbeats, and the flushed offset; acks report the follower's offset. EndPartitionGeneration lets a broker of a broken pair report it to the balancer. * mq broker: hand a partition's fence between generations A fence could only be taken by the next leader, at once. A pair that breaks needs more: the survivor must keep persisting what it holds before a new leader writes, and a follower must be able to take the fence from a leader it lost. The holder can now renew the fence, which tells a new leader it is still persisting, and seal it when it is done; a new leader takes an earlier generation's fence once it is sealed or left unrenewed for 30 seconds. Within one generation the fence moves only from the leader to its follower, and a sealed one stays sealed. Sealing writes a new token, so a follower that read the fence before the seal cannot take it over after; a plain renewal keeps the token, so flushes under way still match. A stale leader that reloads seals its old fence once its last flush lands, so the reload does not wait. * mq broker: ack a publish once the follower holds it The leader acked a publish as soon as it was in its own memory, sent the follower the raw message without its offset, learned its follower only from the publisher's init message (which the Kafka gateway never sets), and wrote to one follower stream from every publisher at once. The leader now takes its follower from the partition's assignment when it loads the partition and streams each entry, with its offset, from one sender goroutine in offset order; a publish is acked once the follower acks that offset. Heartbeats and a 5 second silence limit tell a lost follower from a quiet one, and a broken pair answers the publisher GENERATION_ENDED. The follower holds the entries the leader has not stored yet, drops them as flush notices arrive, and the leader closes the stream gracefully once it has stored everything, when the partition unloads. A partition with no follower acks from memory as before. * mq: give a partition whose pair broke a new pair Nothing reassigned a partition whose leader or follower was lost while the other half lived on: the balancer only replaced brokers that had left its broker set, and only on its own schedule. A broker of a broken pair now reports the epoch with EndPartitionGeneration, and the balancer assigns a new pair and the next epoch, preferring brokers outside the old pair. A report for an epoch that already moved on is ignored, so both halves can report, and reassignments are serialized. * mq broker: a leader that loses its follower stores what it holds and ends the generation When the follower stream broke, the leader kept serving alone, acking from memory again. A broken pair now ends the generation on the leader: it stops taking publishes, renews its fence so a new leader waits, stores everything it holds under that fence, seals it, and reports the epoch so the balancer assigns a new pair. A follower that cannot be reached when the partition loads ends the generation the same way. * mq broker: a follower takes over from a leader it lost When the follow stream broke, the follower dropped what it held, so entries the leader had acked but not stored were gone with it. The follower now moves the fence from the lost leader to itself, unless the leader sealed it first, reads what is already stored, stores the entries above that, seals the fence and reports the generation ended. The leader acks only what the follower holds, so every acked entry is stored once, and a leader still writing is fenced out. * mq broker: reload topic.conf when the balancer names this broker leader A broker made leader by a reassignment could still hold the previous topic.conf in its 30 second cache, so it either found no assignment for itself or tried to take the fence with the old epoch, and refused publishes until the cache expired. A publish that finds either now drops the cached config and loads the partition again. * mq broker: stop routing subscriptions through the follower A subscription dialed the follower named in its init and advanced its committed position only while that follower stream existed, so a partition without a follower never saved a consumer position, and a dead follower failed every subscription. The leader now tracks the position itself and saves it when the subscriber leaves. * mq broker: tell a partition's leader its follower when assigning it The balancer created a topic's partitions on their leaders with only the partition and epoch, so a partition made that way never knew its follower and acked from memory. It now sends the whole assignment. Only the named leader creates the partition; the follower learns of it from the leader's follow stream, so the old forward of the leader's request to the follower, which would have made the follower take the fence too, is gone. * mq broker: report an ended generation until a settled balancer takes it A broker reported a broken pair once. When the lost broker was also the balancer, the report failed and the partition stayed at a sealed epoch nobody would serve. The report is now retried with backoff until a balancer takes it, and a balancer takes reports only after its settle window, so the new pair is picked from every live broker rather than the few that reconnected first. * mq: describe the replicated pair in the failover notes * mq broker: break a pair whose follower stopped reading The follower's silence was checked in the loop that sends to it, so once a send blocked on a follower that stopped reading but kept its connection, nothing checked again and publishers waited on acks that never came. The check now runs on its own and cancels the stream. * mq broker: a follower that cannot ack its leader takes over An ack that failed to send ended the follow stream with an error and dropped the follower's entries, though they may include messages the leader had already acked to publishers. A failed ack now takes over the partition, as a broken receive does. * mq broker: retry a takeover through filer errors A follower taking over gave up on the first failed fence or offset read, dropping the entries its lost leader had not stored, which may be the only copy left. It now retries until the fence has moved on or the broker stops. * mq broker: keep the fence renewed while a survivor persists A leader that lost its follower renewed its fence once before storing what it held, and a follower taking over not at all after moving the fence, so a store that ran past 30 seconds let a new leader take the unsealed fence, refusing the survivor's write and dropping what it held. Both now renew every 10 seconds until they seal. * mq broker: leave the follower its copy when a retiring leader dropped a flush A retiring leader closed its follow stream gracefully once its buffer shut down, which tells the follower everything is stored, but a flush that failed until shutdown is dropped. With the filer unavailable both copies of acked messages went. The stream is now closed only when the flushed offset reached the last one assigned; otherwise it is broken, so the follower takes over and stores its copy. * mq broker: order every topic.conf read-modify-write on the balancer Only the generation handoff held a lock around its read and save of topic.conf, so a concurrent ConfigureTopic or assignment refresh that read the old assignments could save them back over the new pair, after the reporter had been told the generation was taken. All of them now take the same lock. * mq broker: stamp a fence write when it lands, not when it was first tried A fence write took its mtime before retrying, so a renewal that landed after a long run of store errors was already older than the seal wait, and a new leader could take the fence from a survivor still persisting. Each attempt now stamps the time it is sent. * mq broker: watch a leader's follower only once its partition is listed The lost-follower watch started before the partition was registered, so a pair that broke in that gap ended its generation while the partition could not be removed, and the partition was then registered and served after its fence was sealed. Both load paths now start the watch after registering it. * mq/kafka: answer a produce on an ended generation with NOT_LEADER_OR_FOLLOWER A partition whose pair broke answers publishes with GenerationEnded while the balancer hands it to a new pair, which the gateway mapped to UNKNOWN_SERVER_ERROR: it kept the session and Kafka clients did not refresh their metadata. It now maps to NOT_LEADER_OR_FOLLOWER, so the gateway drops the session and clients look the leader up again. * mq broker: take a stale fence only if its holder has not renewed it since A new leader judged an earlier generation's unsealed fence stale by its mtime, then wrote under the token alone. A renewal keeps the token and moves only the mtime, so a holder that renewed in between, still persisting what it held, lost the fence and the write that followed. Taking a fence judged stale now requires the entry as it was read. * mq broker: bound the seal when a leader cannot reach its follower A leader whose replica failed to start sealed its fence and reported the generation under the broker's access lock with no deadline, and a fence write retries until it lands, so a filer that kept failing held every partition operation on the broker. The seal now gives up after the fence take timeout and the generation is reported regardless. * mq broker: bound each report of an ended generation A generation report called the balancer with no deadline, so a balancer that accepted the call and stopped answering held the retry loop and the partition stayed unassigned. Each attempt now gives up after 30 seconds and is retried; a repeat after a save that landed finds the epoch moved on and returns without writing. |
||
|
|
e9fa5802e1 |
volume: keep a low-disk location read-only until free space is back by a margin (#13199)
* volume: keep a low-disk location read-only until free space is back by a margin The volume server checks each disk location once a minute and sets the location's low-disk flag from that reading alone. A disk whose free space hovers at -minFreeSpace (writes use space, deletes and vacuum give a little back) flips the flag on and off, and every volume on the location with it. The master hears each flip in a heartbeat, so it keeps assigning writes to volumes that are about to turn read-only, and the write fails with a read-only error. Nothing smooths this: the volume reads the location's flag directly, and the master's volume layout takes the heartbeat's read-only bit as it comes (its recovery delay and size band apply to full volumes, not to read-only ones). A location that went low now stays low until its free space is 1% of the disk above the limit, for a percentage limit and a byte limit alike (MinFreeSpace.IsLowFrom). Going low is unchanged. The margin is a constant, not a flag: what flips a disk at the limit within one check is a vacuum, a volume copy or the writes of one minute, each about one volume (30 GB by default) at most. 1% of a multi-TB disk is about that much, so a swing of that size does not clear the state, while an ordinary cleanup of a few volumes does. The disk check runs on one goroutine per location and is the only writer of the flag, so the previous verdict it reads cannot change under it; readers only load it. Every consumer of the flag (heartbeat max volume counts, read-only flags, volume allocation, EC shard placement) reads the same flag, so they all see the held state. The live checks of volume copy and preallocation, which read the disk instead of the flag, only ever refuse more than the flag does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: do not remember a low verdict from a reading without space values When statfs fails or times out before any good reading is cached, the disk status has All, Free and PercentFree at 0, and MinFreeSpace.IsLow calls that low. With the hysteresis, that verdict was remembered, so a later good reading between the limit and limit+1% kept the location read-only, where it used to clear it: a disk whose first check timed out stayed read-only until its free space cleared the margin. A reading without space values (All is 0) is now judged by IsLow alone, as before, and does not change the remembered verdict, which lives in its own atomic field that only readings with space values update. A failed reading between two good ones leaves the held verdict as it was. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep a low-disk location read-only until free space is back by a margin Mirror Go's MinFreeSpace.IsLowFrom: once a location goes low it stays low until free space is 1% of the disk above the limit, for percentage and byte limits alike. A failed statfs reading (total 0) already leaves the flag untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: trim the low-disk hysteresis comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): test the low-disk hysteresis with fixed readings 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> |
||
|
|
24951dbfe7 |
mq: one offset assigner per partition, continued from disk (#13191)
* mq: assign publish offsets inside the partition's log buffer A publish took its offset from the offset manager under one lock and appended it to the log buffer under another, so two publishers on one partition could append offsets out of order. The buffer now assigns the offset under its own lock when the entry asks for one, and an entry that already carries an offset moves the buffer's next offset past it instead of bumping it by one. * mq: give the entry that rolls a window over to the new window Both append paths widened the window's offset range before checking for a rollover. The sealed window then claimed the entry that started the next one, and the new window's range started without it, so a window holding only that entry was flushed as offsets 0..0 and readers skipped it. The range is now widened after the rollover. * mq: seed a partition's offsets from all of its own files A loading partition continued its offsets from the highest offset recorded on disk, but the scan listed without a limit, so the filer returned only its default page (1000 entries under weed server and mini) and offsets below the real maximum were handed out again. It also read the newest version directory rather than the partition's own, and a filer error left the partition counting from 0. The broker and the Kafka gateway now share mq.ReadOffsetRange, which lists every file, the broker reads the partition's own directory, and a partition whose stored offsets cannot be read is not loaded, so the publish fails and is retried. * mq: reload a partition only after its retired copy has flushed Idle cleanup and a drain retire a partition and return while its last flush is still queued. A publish right behind them created a new copy, which read the stored offsets before that flush landed and handed out its offsets again. Loading a partition now waits for a retired copy of the same range, outside the broker's access lock that the flush takes. * mq broker: report a partition's high water mark from its buffer The range reported to the Kafka gateway took the larger of the offset manager's count and the buffer's, so it followed the manager's checkpoint rather than what the partition had assigned. It now comes from the loaded partition's buffer, which assigns the offsets, or from the ranges stored on disk when this broker has not loaded the partition. * mq: drop the offset manager's assignment, checkpoint and subscription code Publish offsets now come from each partition's log buffer and its high water mark from that buffer or the stored ranges, so the separate assigner, its checkpoint.offset writer and the offset subscription layer built on it have no callers left. Only consumer-group positions remain in BrokerOffsetManager. Existing checkpoint.offset files are left alone; readers already skip them. * mq broker: recheck a retiring partition under the lock when assigning AssignTopicPartitions waited for a retiring copy before taking the access lock, so a drain in between could retire the partition and the assignment then seeded a replacement before that flush landed. The check now runs under the lock, which is released only to wait. * mq topic: mark a partition retiring before it leaves the list RemoveLocalPartition took the partition out of the active list before recording it as retiring, so a replacement loaded in between saw neither and read the stored offsets before the last flush landed. The partition is now recorded as retiring first. * mq topic: gate the retired-flush test on a channel instead of a sleep The test relied on a 200ms flush delay to observe the partition as pending, which a paused test goroutine could outlast. * mq topic: remove a partition by its instance under one lock RemoveLocalPartition looked the partition up, marked it retiring and then removed by range in separate steps. A second remover of the same copy could take out a replacement loaded in between, leaving it neither listed nor retiring, and a removal that found nothing still left a stale retiring entry. Callers now pass the copy they hold; it is marked retiring and taken out of the list under the partition lock, and only if it is still listed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: look a partition up once per assignment pass The retirement wait checked one lookup and the load used a second one, so idle cleanup retiring the partition between them let the assignment load a replacement from stored offsets before the retired copy's last flush landed. The wait and the load now use the same lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: let a cancelled assignment leave the retirement wait AssignTopicPartitions waited for a retired copy's last flush without watching its request, so while that flush kept failing a cancelled call still held its handler. WaitRetired now takes a context and returns its error, leaving the retirement pending; the publish and subscribe loader keeps waiting as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq topic: share one flush signal per retirement A cancelled WaitRetired left its goroutine blocked on the retired buffer's flush, so repeated cancelled assignments piled up goroutines until that flush finished. The retirement now owns one channel, closed after its last flush, and every waiter selects on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: load the assigned generation for any request of its range Subscribe and fetch pass the partition from the request, and the loader built the local partition from it after matching only the range. A stale or zero generation then scanned a directory the broker was not assigned, found no offsets, and registered a partition that restarted at zero over stored data. The loader now takes the assignment's partition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
81b83b155f |
fix(mq): copy flush buffers before queuing follower data (#13183)
* fix(mq): copy flush buffers before queuing follower data * fix(buffered_queue): release references after dequeue |
||
|
|
ac2efbac01 |
fix(buffered_queue): synchronize enqueue with input closure (#13168)
Check isClosed while holding the queue mutex so the check and insertion are atomic with respect to CloseInput. This prevents a producer from successfully enqueueing after a consumer has exited a closed, empty queue. Add concurrent enqueue, close, and drain coverage with a bounded wait, plus checks for both sequential close orderings. The concurrent regression reproduces the original data race and stranded item under the race detector. Co-authored-by: Master <Master@node0.8m510.lpad-pg0.utah.cloudlab.us> |
||
|
|
53206f16be |
fix: reject NaN minimum free-space percentages (#13153)
Signed-off-by: guagucai <guagucai@outlook.com> |
||
|
|
ec2d96888d |
pb: use the slot allocator as gRPC's buffer pool (#13136)
* pb: power-of-two gRPC buffer tiers up to 1 MB ## Problem gRPC's default buffer pool has tiers of 256 B, 4 KB, 16 KB, 32 KB and 1 MB, and zeroes a pooled buffer's whole capacity on every `Get`. Every message between 32 KB and 1 MB therefore zeroes 1 MB, in the proto codec's marshal and in every receive. A filer entry that holds a table's Iceberg metadata (inline content, extended attributes) is such a message, several times per commit. Profiled on `weed mini` under an Iceberg commit load (8 DuckDB writers, one table each, 30 s CPU profile): `runtime.memclrNoHeapPointers` under `sizedBufferPool.Get` was 2.39 s of 30.0 s sampled, 8% of the process's CPU. With the tiers below it is 0.74 s of 22.2 s. ## Fix `weed/pb` sets the process-wide default pool at init (`experimental.SetDefaultBufferPool`, which gRPC documents as init-time only) to a binary tiered pool with every power of two from 4 KB to 1 MB (plus 256 B), so zeroing is bounded by twice the message size. Buffers are still zeroed; only the tier sizes change. The proto codec reads only the default pool; `NewGrpcServer` and `GrpcDial` also pass the pool as an option (`experimental.BufferPool`, `experimental.WithBufferPool`), because gRPC's own default server and dial options captured the old pool before this package's init ran. Messages up to 32 KB and above 1 MB use the same tiers as before. Each extra tier is a `sync.Pool`, emptied by the GC like the others. ## Tests `weed/pb/grpc_buffer_pool_test.go`: - `TestGrpcBufferPoolIsTheDefault`: the default pool is the tiered one. - `BenchmarkGrpcBufferPoolGet`: a `Get`+`Put` with gRPC's default tiers against these (Apple M-series, `go test -bench GrpcBufferPool -count 3 ./weed/pb/`): | message | default tiers | power-of-two tiers | |---|---|---| | 40 KB | 9.8–10.1 µs | 0.59–0.71 µs | | 100 KB | 10.1–10.8 µs | 1.24–1.29 µs | | 300 KB | 11.1–14.7 µs | 5.6–5.7 µs | `go vet ./weed/pb/` reports nothing in the touched files; `go test ./weed/pb/`: ok. `go build ./weed`: ok. * pb: test the buffer capacity each gRPC pool tier hands out Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: rely on the default pool for dials, which read it per connection grpc's defaultDialOptions() reads mem.DefaultBufferPool() at dial time, so only the server, whose defaults were captured at grpc's init, needs the pool passed as an option. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mem: return only slot-sized buffers to the slot pools Free put any buffer into the slot its capacity rounds up to, so a nil or odd-capacity buffer made a later Allocate of that slot panic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mem: serve the slots through a Get/Put pool type SlotPool satisfies gRPC's mem.BufferPool, and Allocate and Free now go through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pb: use the slot pool as gRPC's buffer pool The slots round up to the next power of two and do not zero, so gRPC shares buffers with Allocate and no longer clears them on every Get. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
576eb98ce9 |
mount: leave -cacheMinFreeSpace free on the chunk cache's disk (#13124)
* mount: leave -cacheMinFreeSpace free on the chunk cache's disk weed mount sizes its on-disk chunk cache by -cacheCapacityMB alone and preallocates each cache file in full when it creates it. With a capacity larger than the free space of the disk holding -cacheDir, the cache takes that disk down to nothing: the preallocations run until fallocate fails, and chunk writes fill the rest. The mount's metadata cache (a leveldb store under -cacheDir) and the swap files of dirty pages (-cacheDirWrite, which defaults to -cacheDir) live on the same disk, so once it is full their writes fail with ENOSPC, and writes whose dirty pages spill to swap return EIO to the application. The same happens when several mounts share a cache disk and together are configured beyond it. -cacheMinFreeSpace is the free space the cache leaves on that disk, written like the volume server's -minFreeSpace: a percentage like 1 or a size like 10GiB, 1 by default, as for volume servers. - When the cache opens, its disk layers shrink to the space above the floor, counting the cache files already in the directory as the cache's own. With no room the disk tier keeps no files. - Each new cache file preallocates only what the disk holds above the floor at that moment, so the files of one cache, or the caches of several mounts opening together, stop reserving at the floor. - A chunk write that lands in blocks its file already holds, preallocated or written, goes ahead as before, even with the disk under the floor. A write that takes new disk space, into a file a rotation truncated or where nothing could be preallocated, goes ahead only while the space above the floor covers it. The disk is read at most once a second, and the cache counts what it takes in between, so it cannot run past the floor between readings. A rotation gives the truncated file's blocks back, so the write after it reads the disk again. A chunk the cache cannot place is not cached, like any other miss. The webdav server's cache passes no floor and behaves as before. * mount: read the cache disk on every write that takes space, leave the index files room Review follow-ups. - take reads the disk each time, instead of once a second less what the cache took since, so a write sees what other mounts sharing the disk wrote, and what a rotation gave back. It runs only for writes past the blocks a file already holds, and a statfs costs little next to the write. - The index files (.idx and the leveldb maps) grow by a few dozen bytes a chunk beside the data files that the cache size counts. Sizing leaves them a sixteenth of the room above the floor. - The cache's own files count as room by the blocks they hold, so a file that was preallocated but not yet written when the mount exited counts in full when the cache reopens. - weed fuse checks -o cacheMinFreeSpace in the parent as well: the parent waits for the child's signal, and a child that rejects the value never sends it. * mount: keep the resolveCacheDirs doc comment on resolveCacheDirs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: say -cacheMinFreeSpace stops new disk space, not every chunk Under the floor the cache still fills the blocks its files already hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
604d391012 | 4.56 | ||
|
|
a9fda6b50f |
filer clients: authenticate filer gRPC calls with per-call admin tokens (#13039)
* Add per-call filer authentication sources and pooled client wrappers * Authenticate gateway filer calls with per-call admin tokens * Authenticate shell admin and synchronization filer calls * Authenticate workers MQ and remaining filer client paths * Cache filer client signing keys and sign subscriptions with the shared key Re-reading security.toml on every filer RPC cost about 125us against 8us for signing. Keep the keys for up to a second, re-reading at once when a WEED_ override or the configuration directory changes. When the file exists but cannot be read, keep the last keys read, else the startup keys, as FilerAdminKeys does, so a process without a key stays tokenless. Metadata subscriptions prefer the shared key, as filer peers do, because older filers verify subscription admin tokens only with it. * Authenticate admin-script, maintenance and filer.conf shell paths Plugin worker admin scripts and master maintenance scripts build their own shell options and carried no filer token source; fs.configure and s3.bucket.quota.check read filer.conf without it. * filer.cat: report a failed read; isolate key overrides in the admin-script test filer.cat ignored the error from its filer call and exited successfully, leaving a truncated -output file. Report the error and exit with failure. The admin-script token test now clears the WEED_ signing-key overrides, which take precedence over security.toml. * security: refuse gRPC keys too short to sign; query engine uses client TLS Under GODEBUG=fips140=only, hmac.New panics on keys under 14 bytes. The startup check now covers jwt.filer_signing.grpc_key and grpc_previous_key, and filer client token sources check the keys they read, so a reloaded or per-endpoint security file with a short key is refused instead of panicking when the next RPC signs. The query engine's broker client dialed every master, filer and broker in plaintext, so the admin token it now sends could cross the network in the clear. It dials with the grpc.client TLS settings instead, and weed-sql loads security.toml as weed-db does. * security: per-endpoint admin tokens ignore WEED_ key overrides FilerAdminTokenFromFile honored WEED_JWT_FILER_SIGNING_GRPC_KEY and WEED_JWT_FILER_SIGNING_KEY. Those are process-wide, so filer.sync with -a.security and -b.security signed both clusters' admin tokens with the one key, handing each cluster a token valid on the other. A per-endpoint file now supplies its own keys only. * weed-sql, weed-db: refuse to start on an unreadable security.toml Both only warned when security.toml was present but could not be read or parsed. They then dialed without the grpc.client TLS settings while the filer token source could still sign admin tokens from WEED_ environment keys, so the tokens could travel in plaintext. They now exit with an error that does not quote the file; a missing file is still fine. * pb: take the filer token source in WithGrpcFilerClient and WithOneOfGrpcFilerClients Fold WithGrpcFilerClientAuth and WithOneOfGrpcFilerClientsAuth into the existing helpers instead of keeping two names for each. Callers without a token source pass nil. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: return the read error from ReadConfiguration Fold ReadConfigurationWithError into ReadConfiguration. The error is returned and not logged, since parser errors can quote values; the existing reload callers already warn when no file was read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: keep the test-only filerAdminToken helper in the test It had no production caller. The test helper now resolves keys through filerClientKeysFrom, as the token sources do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read security.toml once in LoadSecurityConfigurationOrError It validated the file, then merged it with a second read whose failure was ignored and whose parser error was logged. It now merges with one read and logs nothing from the parser. Viper's search also treats a directory the process cannot search as holding no file; a candidate that cannot be checked for lack of permission is now refused too. * security: verify admin subscription tokens with the gRPC clock leeway CheckGrpcMetadataSubscription checked admin tokens strictly, while unary filer calls allow jwt.filer_signing.clock_leeway_seconds. With ten-second client admin tokens, a subscriber whose clock trailed the filer's by more than ten seconds was refused with a matching key. It now takes the leeway, and the filer passes its configured one. The leeway check moves from the server package to security.IsFilerAdminTokenWithLeeway so both use it. * util: start without security.toml only when every candidate is confirmed absent A candidate whose check fails for any reason other than not existing, such as a symlink loop, is refused like one the process cannot search. --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
397a156104 |
security: a fips.mode setting that Go checks against GODEBUG and the Rust binaries apply to TLS (#13029)
* util: refuse to start when fips.mode in security.toml disagrees with GODEBUG security.toml gains [fips] mode = "off" | "on" | "strict", also settable as WEED_FIPS_MODE: one setting that states the FIPS 140-3 mode of every process in a deployment, so the Rust binaries, which do not run on the Go runtime, can follow it. Go processes keep taking their behaviour from GODEBUG=fips140 and now check it against the setting: LoadSecurityConfiguration and `weed worker` exit when "off" runs without fips140=off, "on" without fips140=on, or "strict" without fips140=only, naming the setting and the GODEBUG value it needs. An unknown value is refused; unset or empty changes nothing. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust: fips.mode with FIPS-mode TLS in weed-volume, weed-worker and weed-vector seaweed-common gains a fips module: FipsMode resolved from fips.mode in the security.toml a binary uses, with WEED_FIPS_MODE over it. Each binary resolves it once at startup, logs it and installs the matching rustls provider as the process default, refusing to start on an unknown value or when another provider was installed first. Under "on" and "strict" the provider is aws-lc-rs filtered to the lists Go's crypto/tls applies in FIPS mode: TLS 1.3 AES-GCM suites and TLS 1.2 ECDHE AES-GCM suites (no ChaCha20-Poly1305), X25519MLKEM768, SecP256r1MLKEM768, P-256 and P-384 (no plain X25519), Go's ten signature schemes (no ML-DSA). Configurations SeaweedFS builds require the Extended Master Secret in that mode, and the volume server refuses a non-FIPS suite in tls.cipher_suites instead of falling back. sw-client installs the same provider instead of ring. Unset or "off" keeps aws-lc-rs's default provider unchanged. This is behavioural parity only: the provider still runs on the non-validated aws-lc-rs build. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: refuse a fips.mode that is not a string viper's GetString turns an array or a table into "", so mode = ["strict"] under [fips] skipped the GODEBUG check while the Rust binaries refused the same file. RequireFipsMode now reads the raw value (ViperProxy.Get, under its lock) and exits when it is not a string, naming its source; an absent or empty value still means unset, and WEED_FIPS_MODE still wins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * rust: read fips.mode with the parser that reads the JWT keys seaweed_common::fips::resolve parsed security.toml with the toml crate, while the volume server reads the rest of the file with its own lenient loader. A file with [fips] mode = "on" beside an unquoted value the loader accepts resolved to off and logged "fips.mode unset", although the JWT keys from the same file were applied. Each binary now reads fips.mode with the loader it uses for everything else and hands the value to resolve: the volume server through its line parser, the worker and vector engine through their parsed Security table, which already refuses a file that is not TOML. A security.toml the volume server finds but cannot read stops startup. A missing setting is still off, and WEED_FIPS_MODE still wins. seaweed-common no longer depends on toml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * sw-client: offer only FIPS signature schemes with insecure_skip_verify With https.client.insecure_skip_verify, reqwest installs its own verifier, which advertises a fixed scheme list including SHA-1 and Ed448 whatever the process provider allows. In FIPS mode the volume transport now builds its rustls configuration itself on the process provider: the server certificate and host name are not checked, as the setting asks, but handshake signatures are verified with the provider's algorithms, only its schemes are offered, and TLS 1.2 requires the Extended Master Secret. Outside FIPS mode the reqwest path is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * seaweed-common: sign only with Go 1.27's FIPS schemes, allow ML-DSA The FIPS provider kept aws-lc-rs's key provider, so a FIPS-mode listener signed handshakes with whatever scheme its key and the peer agreed on, outside the list the provider verifies with. Keys now load through a provider that limits each key to the FIPS signature schemes and refuses a key that can sign none of them, such as Ed448; the volume server and the worker's gRPC TLS name the certificate and key files in that error. The lists follow Go 1.27.4, which go.mod now requires: its defaults_fips140.go allows ML-DSA-44, -65 and -87 as signature schemes and ML-DSA certificate keys (for Go's native module only), so they are allowed here as well. Go also allows MLKEM1024 but does not enable it by default, so it stays out of the key exchange list as in Go's defaults. "off" keeps the default key provider. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: skip the truncate manifest test on freebsd like its fake filer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> |
||
|
|
be8eb02ac0 |
util: remove multipart temp files parsed on the idle-timeout pause's request copy (#13044)
* util: remove multipart temp files parsed on the paused request copy net/http removes the temporary files of a multipart form parsed on the Request it passed to the handler. PauseIdleTimeoutWhileHandling hands the handler a shallow copy when the request has a body, so a form parsed there (ParseMultipartForm, or FormValue on a multipart body) left its temporary files behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: test that the idle-timeout pause removes multipart temp files Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: point the multipart temp-file test's temp dir at Windows' TMP and TEMP too Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e743f99bb5 |
util: keep a request's context while its handler works quietly past the idle timeout (#13040)
* util: keep a request's context while its handler works quietly past the idle timeout A request that the server works on for longer than the listener's idle timeout, without reading or writing, lets that timeout end net/http's background read: the read the server keeps waiting while a handler runs, to see a client hang up. net/http takes the failed read for the client's connection failing and cancels the connection's context, so the request in progress, and every later request on the kept-alive connection, run with a canceled context. #10212 covered a long write-only response, whose writes now extend the read deadline; an answer that has not started yet has nothing to extend it. On the S3 gateway (-idleTimeout 120 s) such requests are the ones that answer only when their work is done, e.g. a large CopyObject into a versioned bucket, which the copy keep-alive of #12862 does not cover. After one, the next requests on that connection fail within a millisecond: a ListObjectsV2 answers 500, a GetObject and a PutObject 499 ClientDisconnected while the client is still connected. The filer's HTTP listener has a 10 s idle timeout by default. PauseIdleTimeoutWhileHandling, which newHttpServer now installs next to the ConnContext hook it already sets (S3, filer, IAM and master HTTP), takes reading out of the activity timeout from the moment a request's body has been read to its end (at once when it has none) until its handler returns: the client is waiting for the answer, so a connection that carries nothing means the server is at work. Reading a body, writing an answer and waiting for the next request stay under the timeout, and a client that closes its connection still cancels the context. Over HTTP/2 the frame reader keeps no deadline while such a handler runs and gets it back when the last one returns. Tests: weed/util/net_timeout_test.go (a quiet handler over HTTP/1.1, TLS and HTTP/2, and the next request on the same connection; the same after a 1 MiB body; a stalled body, an idle connection, an idle HTTP/2 connection and a client hang-up still end as before; concurrent requests; a waiting read held by the pause and released at its end; the context loss without the wrapper) and weed/command/server_http_test.go (newHttpServer). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * webdav: serve through newHttpServer so quiet handlers keep their context weed webdav serves a util.Listener with an idle timeout (10 s by default) but built a bare http.Server, so it had neither ConnContext nor the idle timeout pause. A COPY or MOVE of a large file answers only once it is done, and like the S3 and filer handlers it then lost its context, and so did every later request on the connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: pause the idle timeout for HTTP/1.x requests only HTTP/2 has no background read to protect: when its connection carries nothing for the timeout, the frame reader's deadline closes the connection, and no later request runs on it. That deadline is also what ends a stream whose client stopped reading, since the answer waits for flow-control credit, not on the socket, where the write deadline would end it. With the pause on HTTP/2 requests, a download whose client stopped reading held its handler and connection until the client acted, and a stream that declared content-length 0 but never ended could hold its handler the same way. Pause only HTTP/1.x requests; HTTP/2 keeps the timeout it had. Tests: TestStalledDownloadStillTimesOut over HTTP/1.1, TLS and HTTP/2 (the HTTP/2 case was still waiting after 8 s with the pause on HTTP/2) and TestOnlyHTTP1RequestsArePaused; the HTTP/2 quiet-handler cases are gone, with them the HTTP/2 subtest that flaked under -race. TestPauseUnderConcurrentRequests gets a 1 s idle timeout, so that a request waiting for its turn on a slow run does not find its connection closed. 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> |
||
|
|
0fb1387226 |
s3: compare If-None-Match weakly, as the filer and volume servers do (#13033)
* s3: compare If-None-Match weakly, as the filer and volume servers do The S3 gateway matched conditional ETags by trimming quotes, so a weak tag such as W/"etag" in If-None-Match never matched and a revalidating GET got 200 instead of 304. Move the filer's RFC 9110 matcher to weed/util and use it in the gateway: weak comparison for If-None-Match, strong for If-Match. The routed write condition now sets AllowWeak on IF_ETAG_NOT_MATCH so the check under the object lock agrees with the gateway's pre-check. * s3: split write-condition ETag lists the way the gateway matches them etagList split on every comma and kept empty elements, so the filer's locked If-None-Match check (now a weak comparison) could match a fragment of one quoted tag, or an empty element, that the gateway's pre-check ignores. A PUT with If-None-Match: W/"<etag>,x" passed the pre-check and then got 412 under the lock. Reuse the gateway's quote-aware splitter and drop empty elements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Mansur Akhmadi <10739460+mansur-akhmadi@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
e9a5d733b1 |
weed: report host THP policy; build: declare Go 1.27.4 to match the releases (#13025)
* weed: report the host transparent huge page policy at startup Go maps the heap with MADV_HUGEPAGE, so the host THP policy applies to a SeaweedFS process whether or not the operator asked for it, and the advice in the Go GC guide depends on the heap size. Operators had no way to see which mode a node actually runs in. Log enabled/defrag/khugepaged.max_ptes_none once at startup from the long-running commands, and print the Go toolchain in `weed version` so a support bundle identifies the runtime that produced the binary. Nothing changes the policy: THP is host-wide, and GODEBUG=disablethp=1 remains the only per-process control. Refs #5437 * build: declare Go 1.27.4, the toolchain the releases already use The 4.55 release binaries report go1.27.4 (`go version -m` on the published tarball), while go.mod still said 1.26.6, the Dockerfiles pinned golang:1.26, and the release workflows left the Go version to the action default of "the latest stable at build time". A source build, a container and a downloaded tarball therefore ran different toolchains from the same tag, and the next release could silently pick up another one. Set the go directive to 1.27.4 in the root module and in the four modules that build in CI, bump the 16 Dockerfiles, and pin goversion: 1.27.4 in the 16 release and dev action steps. `go mod tidy` now emits the two require blocks Go 1.27 expects; no dependency version changed. Go 1.27's gofmt realigns 8 files. * weed mini: report the THP policy after quieting stderr The startup line ran from the dispatch point before runMini applied quietMiniLogs, so every weed mini start on Linux printed it to stderr, which mini keeps for the welcome banner, warnings and errors. Log it from runMini after quietMiniLogs so it lands in the log file only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report whether the Go heap can use huge pages The runtime advises only GC metadata with MADV_HUGEPAGE and leaves the heap arenas to the host default, so under enabled=madvise the heap stays on small pages. The log still printed go_heap_disabled=false there, which reads as "the heap uses THP". Report go_heap_thp, true only under enabled=always without GODEBUG=disablethp, and drop the struct comment that said the heap is mapped with MADV_HUGEPAGE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: count an inherited PR_SET_THP_DISABLE in go_heap_thp A launcher can disable THP for the process with prctl, and children inherit it, so enabled=always alone does not mean the heap gets huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read GODEBUG disablethp the way the runtime does The runtime applies GODEBUG left to right, so with disablethp=1,disablethp=0 the heap keeps THP, while the helper stopped at the first disablethp=1. The helper also missed other nonzero values such as disablethp=2, which the runtime treats as disabled, and trimmed spaces around keys, which the runtime keeps. Take the last disablethp with an integer value, treat any nonzero value as disabled, and match keys exactly. The parser now takes the GODEBUG string, so it is tested without changing the environment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: honor per-size THP policies in go_heap_thp Since Linux 6.8 each anonymous huge page size has its own policy in hugepages-<size>kB/enabled, and only "inherit" follows the top-level knob. A 64kB size set to "always" gives the unadvised heap huge pages under a top-level "madvise" or "never", and a 2048kB size set to "never" takes them away under "always", but the log judged only the top-level value. Read the per-size policies and report go_heap_thp=true when any size reaches the heap. Under a top-level "never", the "disabled by the host" line is now printed only when no size reaches the heap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report go_heap_thp=unknown when the process setting is unreadable If PR_GET_THP_DISABLE fails, for example because a seccomp profile rejects it, the process THP setting is not known, but the log treated it as allowed and could print go_heap_thp=true. Print go_heap_thp=unknown in that case. It stays false when the host or GODEBUG already rules out heap huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: report go_heap_thp=unknown when a per-size THP policy is unreadable An unreadable hugepages-<size>kB/enabled was skipped, so the log could say the host disabled THP while that size allowed it. Keep it as an empty mode and report unknown unless a readable size already allows huge pages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: take the Go version from go.mod in tests and releases posix-compliance pinned GO_VERSION 1.26 and built go 1.27.4 modules only through the GOTOOLCHAIN auto-switch; nine workflows used go-version ^1.26 and the kafka jobs ran in golang:1.26-alpine. Read the version from go.mod with go-version-file, as the other setup-go steps already do, moving checkout ahead of setup-go where it came after so the file exists. The posix report takes the version from the setup-go output. The release and dev builds pinned goversion 1.27.4 in 16 places. The pinned go-release-action reads the go directive when goversion is go.mod, so the binaries now follow go.mod without a second copy of the version. * weed: report the THP policy from every long-running command mount, worker, iam, master.follower, the filer sync/backup/remote/replicate daemons and the mq agent and kafka gateway keep serving after startup like the commands already listed; mount is likely where heap size matters most. fuse is not listed: its first process starts a child with the same arguments and waits, so logging at dispatch would print the line twice. It logs in runFuse just before handing over to runMount, which only the child reaches. --------- Co-authored-by: Konstantin Lebedev <whitefox@mayflower.work> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
77a6787335 |
Bound upload memory: admission by size, gateway holder writes, 503/SlowDown back-pressure, body deadline (#13021)
* util: one admission rule for upload limits * operation: mark gateway fan-out holder writes as client traffic * volume: bound upload admission, limit gateway holder writes, 503 on timeout * volume: charge unknown-length uploads half the budget, document client wait cap * s3, filer: admit uploads by inFlight+size and charge unknown lengths a chunk * s3: answer a volume overload as SlowDown with Retry-After * operation: cut an upload whose body crawls below the minimum rate on any host * operation: make the slow-commit deadline test honour the request context * s3: stop chunk uploads when the client goes away * operation: treat a body deadline cut as back-pressure, not a same-holder retry A body that crawls past the body deadline returns from retriedUploadData at once, like an overload, and counts toward the single reassign the chunk loop and the filer retry gate give back-pressure. A watchdog cut keeps its retry on a fresh conn. Both still match ErrUploadStalled and stay reassignable. * operation: apply the body deadline only to uploads that opt in UploadOption.BodyDeadline and ChunkedUploadOption.BodyDeadline turn the body deadline on; S3 chunk uploads (relay and fan-out) and the filer's chunk loop set it. Mount, filer.sync, filer.copy and UploadWithRetry keep the stall watchdog only, as before the deadline existed. * s3, operation: check a chunk cancelled with its client is deleted from every holder A volume commits on a context that ignores the cancel, so a chunk whose caller went away after sending the body may still land. The chunk loop already deletes the fid from every holder after a failed attempt; pin that for the relay and fan-out paths and for an S3 PUT whose client goes away. * s3: count a request's declared bytes in the circuit breaker byte limits The per-bucket and global byte counters go back to the declared length (an unknown length counts one chunk), so a bucket bytes limit still rejects a single PUT larger than it. Only the upload budget uses the capped gateway charge. * s3: answer copy chunk overloads as SlowDown, tidy the client-gone checks CopyObject and UploadPartCopy map a volume overload or an exhausted stall to SlowDown, as PutObject does. The client-gone log check matches the mapper's context.Canceled test, the truncated-body case drops a check the first case already makes, and the Retry-After test reads the headers actually sent. * filer, volume: clamp the filer charge chunk, set the upload gauge under the lock A filer with -maxMB 0 charges its default chunk size instead of nothing. The volume server sets its in-flight upload gauge inside the critical section. The upload limit tests wait until the waiter is parked before releasing, check handleUploadRequest gives its charge back, and use CI-safe bounds. * volume: cap the Rust server's client upload-slot wait at 5s Same cap as the Go volume server's volumeClientUploadWaitCap, so a gateway's body deadline never fires before the 503. * operation: reflow the body deadline comment * volume(rs): count a gateway's src=client holder write against the upload limit Mirrors operation.IsReplicaForward: only a primary-to-replica forward skips the upload budget; a gateway's ?type=replicate&src=client fan-out waits like any client write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): admit uploads by inFlight+size, reserved atomically Mirrors the Go volume server's waitForUploadSlot: an upload is admitted by util.UploadAdmits (idle server, or inFlight + size within the limit) and reserves its bytes in the same step, so concurrent waiters cannot all pass one check. Primary-to-replica forwards and unlimited servers are counted but never refused. UploadLimitCond counts once per waiting upload, and the wake-up is armed before each check so a release in between is not missed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): charge an unknown-length upload against the upload limit Mirrors the Go volume server's uploadCharge: a chunked upload without Content-Length reserves one file's worth of budget, at most half the limit and at least 1 byte, instead of 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): a zero -inflightUploadDataTimeout waits the 5s client cap The Go volume server now reads 0 as the 5s cap (its flag help says so); the Rust server used a 2s wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): close a rejected large or unknown-length HTTP/1 upload Mirrors the Go volume server's uploadRejectCloseThreshold: the 503 for a body over 256 KiB, or one without a length, carries Connection: close instead of keeping the connection for a body nobody reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): drop src from a primary's replica forward A client upload carrying src=client kept it on the forward, so replicas treated the forward as gateway fan-out and could refuse it after the primary had already appended. Go's ReplicatedWrite builds a fresh query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): keep the upload admission CAS buildable on rust 1.91.1 Atomic try_update is stable only since 1.95. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): refuse an upload the in-flight counter cannot hold A replica forward added its charge with fetch_add, so a Content-Length near i64::MAX wrapped the shared counter negative and let later client uploads past admission. The forward now reserves with a checked add and answers 503 when the size does not fit; the client CAS adds only after admission passes. With no upload limit the counter only feeds the gauge, so it keeps wrapping arithmetic. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: refuse an upload the in-flight counter cannot hold A replica forward added its charge unchecked, so a Content-Length near math.MaxInt64 wrapped inFlightUploadDataSize negative and let later client uploads past admission. Under the lock the reservation now checks that the counter can hold the charge and answers 503 otherwise, matching the Rust volume server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: keep the request body on a rejected upload Replacing r.Body with http.NoBody hid the server's early close of the unread body from net/http before Go 1.27, so it skipped the FIN-then-wait close and reset the connection under a client still sending. Go 1.26.6, the version go.mod declares, then failed TestUploadLimit503ReachesGoClientForLargeBody with a write error instead of the 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: compare upload admission without forming inFlight+size * operation: reassign a chunk after a 429 as after a 503 * s3: do not count a chunk assignment the client cancelled as a filer failure * filer: charge an upload by its request chunk size, and an inline upload by its whole body * s3: hold an aws-chunked body to its X-Amz-Decoded-Content-Length * volume: answer a rejected small-body upload without waiting for its body * s3: fill the upload budget before testing that a release wakes every waiter --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
25f7e8a0fd |
filer: refuse chunk appends onto inline and remote-only entries (#12993)
* filer: refuse unsafe chunk appends * filer: report append representation preconditions * filer: cover cached remote append eviction safety * filer: cover lazy remote append refusal * filer: refuse HTTP appends and offset writes onto remote-only entries An HTTP append or offset write onto a remote-only entry stored the new chunk with nothing below it, so reads returned zeros where the remote bytes were and the entry stopped being remote-only. Small appends failed with a retryable "inline file changed" error instead. Refuse both with a client error, matching AppendToEntry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: AppendToEntry appends after a sparse tail AppendToEntry placed new chunks at the end of the existing chunks, so a file extended past them by a truncate got the appended bytes inside its logical length instead of after it, and its size did not grow. Use the entry size, as the HTTP append path does. 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> |
||
|
|
8abfdf1e21 |
s3: abort in-flight requests whose access is revoked (#12986)
* s3: abort in-flight requests whose access is revoked S3 checks access when a request starts, so a download or upload that started before an identity, policy or bucket policy change runs to its end. With -s3.abortRevokedRequests the gateway re-checks the requests it is serving after such a change and aborts the ones now denied: an HTTP/1.x request has its connection closed, an HTTP/2 request is canceled. The re-check looks the identity up again and repeats only authorization, not the signature check, so clock skew or an expiring presigned URL never cuts a long transfer. Off by default. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * s3: check revoked requests against whole reloads and configured identities - A re-check pass holds reloadMu, so it never sees identities installed before their policies are synced. - STS and JWT sessions are not tracked: re-validating their token checks its expiry, which a re-check cannot tell from a revocation. - A request whose access changed while it was being admitted is checked again once it is tracked. - The identity source comes from how the request authenticated, and a rotated secret revokes the requests signed with the old one. - An aborted HTTP/2 request also has its body closed. - Browser form uploads, which their handler authorizes, are not tracked. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * s3: track SigV2 requests that carry a session token SigV2 never reads a session token, so a configured key that sent one was classified as a session and skipped the re-checks. Only SigV4 resolves a token, and it marks one it tolerated for a configured key ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: let the admission-race test pass only through the generation check The re-check that the change schedules could run after the request was tracked and abort it, so the test passed without the generation check. Wait for that pass to take its snapshot before the request starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: drop the executable bit from the revocation test file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: bump the re-check generation before its scope can be taken scheduleRevalidation released t.mu before bumping the generation. A pass already kicked could take the new scope in between, before a request was tracked, and that request then saw the old generation and was never checked again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: judge a re-checked request as of when it was admitted A re-check evaluated aws:CurrentTime and a key's expiration at the time of the pass, so an unrelated change aborted a transfer whose time-bounded grant expired after it started. The re-check's copy of the request now carries its admission time, which RequestConditionValues uses for aws:CurrentTime and aws:RequestTime, and a key's expiration is compared with it too. A test covers a revoked HTTP/2 upload: closing its body releases the blocked read, and a download on another stream of the same connection runs to its end. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * stats: let http.ResponseController reach the writer under StatusRecorder Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: reset a revoked HTTP/2 request's stream A deadline in the past resets only that stream, so a download blocked writing to a client that stopped reading is released too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep in-flight requests when their key's secret is rotated A new secret for the same access key is a rotation, not a revocation. Removing or deactivating the key, or losing the grant, still aborts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: always abort in-flight requests whose access is revoked Drop -s3.abortRevokedRequests: the gateway tracks the requests it admits and re-checks them on every change that can revoke access, so a revoked client's transfers stop without a restart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: a catch-up re-check does not advance the revocation generation A request tracked after an access change scheduled its bucket's re-check through the same path as the change, which advanced the generation again. A request that began authenticating before that advance then scheduled another bucket-wide re-check, so overlapping admissions could keep the re-check loop busy, holding reloadMu, with no access change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1815f140b6 |
fips140=only: refuse JWT signing keys and S3 secrets too short for HMAC (#12912)
* fips140=only: refuse HMAC keys too short for FIPS mode where they are configured Under GODEBUG=fips140=only, hmac.New panics on keys shorter than 112 bits (14 bytes). A short JWT signing key starts fine and then kills weed server on the first write (the master's Assign mints a volume JWT in an unrecovered gRPC handler), and an S3 secret of 8 or 9 characters (the SigV4 signing key is HMAC keyed with "AWS4"+secret) makes every request from that identity panic in its handler. Only under crypto/fips140.Enforced(): - security.toml: LoadSecurityConfiguration exits with an error naming the setting when a jwt.signing / jwt.filer_signing key, read key or previous key is under 14 bytes. LoadFilerJwtFromFile (filer.sync -a.security/-b.security) returns the same error, and Guard.UpdateSigningKeys keeps the keys in effect on a reload that brings in a short key. - S3: SigV4 (header, presigned, streaming seed and POST policy) answers InvalidAccessKeyId, as for an inactive key, when the credential's secret is under 10 characters, and logs the access key. Loading such a credential logs a warning; it stays loaded and stored. - IAM CreateAccessKey (IAM API, embedded IAM, admin UI) requires a caller-supplied SecretAccessKey of at least 10 characters. Refs #12839 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fips140=only: check jwt.filer_signing.subscribe.key and the imgproxy key too The filer verifies metadata subscription tokens with jwt.filer_signing.subscribe.key and `weed shell fs.meta.token` signs them with it, so under GODEBUG=fips140=only a short value panics on first use; LoadSecurityConfiguration now refuses it with the other JWT keys. `weed image` signs imgproxy URLs with HMAC keyed with IMGPROXY_KEY; gateway.New refuses a key under 14 bytes in that mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: warn about JWT keys too short for fips140=only outside that mode Outside GODEBUG=fips140=only a JWT signing key under 14 bytes works, so LoadSecurityConfiguration (every weed command but fuse) and LoadFilerJwtFromFile now log a warning naming the setting instead of saying nothing: such a key is refused under fips140=only, and a future release may refuse it in every mode, so the warning asks for a rotation to a longer key with previous_key while it still works. A short previous_key holds the old key during that rotation, so its warning only asks to clear it afterwards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: refuse a short secret under fips140=only with AccessDenied, not InvalidAccessKeyId InvalidAccessKeyId says the access key does not exist, so a client refused for a secret too short for fips140=only went looking for a missing key. The new ErrFips140SecretTooShort answers AccessDenied (403) with "This access key cannot be used while the server runs in FIPS 140 mode. Ask the administrator for a new secret." The message leaves out the length rule: the refusal comes before the request's signature is checked, so any caller that knows the access key ID would learn the secret is short. The embedded IAM API maps it to AccessDenied as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: log an S3 secret too short for fips140=only at error level Under GODEBUG=fips140=only every request signed with such a key is refused, so the identity is unusable; the load-time message is an error, not a warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util, security: name every JWT key too short for fips140=only in one error CheckFips140SigningKeys stopped at the first short key, so a cluster with two short keys failed at startup, was fixed, and failed again on the next one. CheckFips140HmacKeys checks every setting and names each short key ("jwt.signing.key is 10 bytes, jwt.filer_signing.key is 8 bytes; ..."); with one short key the message is unchanged. Guard reloads use it as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fips140=only: say what happened, to what and what to do in the short-key messages The messages about S3 secrets and JWT keys too short for FIPS 140 now start from the process's mode, name the key, its owner or file, the limit, and the fix: - loading S3 identities: "this process runs with GODEBUG=fips140=only, and refuses all S3 requests signed with access key ... (identity ...) because its secret is shorter than the 10 characters FIPS 140 needs for SigV4 secrets; give that access key a new secret of at least 10 characters"; - a refused request logs its request ID, which the client gets back, its client IP (as the audit log records it, s3err.RemoteIP) and the identity; - the startup refusal names security.toml's path and every short key, and links the wiki section on replacing them with or without downtime; - the startup warning outside fips140=only says the server would not start in that mode, and links the same section. A short previous_key no longer gets a warning outside fips140=only: it holds the old key while switching to a longer one, and under fips140=only the startup refusal names it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: a reload under fips140=only drops short previous keys, not the new keys UpdateSigningKeys refused the whole key set when a previous key was too short, so a volume server kept its old keys while the filer's volume signer, which gets no previous keys, took the new ones; proxied chunk reads then failed with 401. Short current keys still keep the keys in effect. A short previous key is dropped with an error log instead: nothing under fips140=only can sign with it, so no token is lost, and every server ends up with the same current keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: check only the filer keys filer.sync uses in its security files LoadFilerJwtFromFile checked every JWT setting in a -a.security/-b.security file, so under fips140=only filer.sync refused to start over a short volume or previous key it never uses. It now checks jwt.filer_signing.key and its read key, after the fallback to the process-wide configuration, which startup checks already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: answer a short secret under fips140=only with SignatureDoesNotMatch A distinct answer before the signature is checked told anyone who knows an access key ID that its secret is short. The refusal now runs where the signature would be checked, after the permission, expiry and signed-header checks, and answers the SignatureDoesNotMatch a wrong signature gets. The server log keeps the cause, the request ID and the client. This drops ErrFips140SecretTooShort and its IAM mapping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security, filer: keep Basic Auth on a reload whose JWT keys are refused When a reload under fips140=only refused the new filer JWT keys, the filer still removed Basic Auth, so a configuration that switches from Basic Auth to short JWT keys left the filer with neither. UpdateSigningKeys and ReloadSigningKeys now report whether the new keys are in effect, and the filer drops Basic Auth only when they are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: do not install a volume read key too short for fips140=only A reload installed jwt.signing.read.key into the read-signing cache without a length check, so under fips140=only a short key made later chunk reads panic signing with it. loadJwtConfig now leaves the key in effect when the new one is too short. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: keep the volume read key when the volume guard would refuse the reload Under GODEBUG=fips140=only a volume server's reload keeps its keys when jwt.signing.key or jwt.signing.read.key is too short. The read-key cache checked only the read key, so it could sign reads with a key the volume servers had not taken. It now checks the same two keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: build the short-key list in one append in CheckFips140HmacKeys Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: keep the blank line before the permission check in verifyV4Signature Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: skip TestFIPS140OnlyShortSecret under real fips140=only enforcement 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> |
||
|
|
9ffb5fe185 |
filer, s3, filer.sync: one digest per cluster, set by the filer's -digest and followed by its clients (#12913)
* util, filer: choose the digest at filer startup with -digest
NewMd5 and NewSha1 returned SHA-256 cut to size whenever the process ran
under GODEBUG=fips140=only, so the kind of digest a cluster stores followed
each process's own environment. They now follow a digest mode set once at
startup: util.SetDigest("md5"|"sha256"), or "" to keep following
fips140.Enforced(). The default is unchanged.
weed filer -digest, weed server -filer.digest and weed mini -filer.digest
set it; fips140=only refuses md5 at startup. The leveldb2/leveldb3
directory-key marker follows the mode, as do the places that compare a
NewMd5 digest with Content-MD5 or pass it on as one: S3 PutObject, filer
HTTP uploads, the Content-MD5 the filer returns, and the uploader's
Content-MD5 to volume servers. Places that verify Content-MD5 with a real
MD5 (volume servers, S3 request bodies and archive uploads) keep keying on
fips140.Enforced(), since they can check it whenever MD5 is available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, command: report the filer's digest and make its clients use it
GetFilerConfigurationResponse carries the filer's digest mode in a new
field 16, digest. weed s3, mount, webdav, sftp, iam and filer.copy adopt
it before they serve or write, so a gateway started with a different
GODEBUG writes the same kind of ETag and chunk digest as the rest of the
cluster. A process under fips140=only refuses a filer that reports md5. A
filer that reports no digest predates the field; the client then keeps
its own mode and logs a warning.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.sync, s3 sink: keep digests within one kind
filer.sync copies entry digests and ETags as they are, so syncing a filer
with digest sha256 into one with md5 left SHA-256 ETags in the md5
cluster. It now reads both filers' digests and refuses to start when they
differ, with a warning when either filer does not report one.
The S3 sink sent the entry digest as Content-MD5 unless its own process
ran under fips140=only. From a sha256 source into a target that checks
Content-MD5 every single-part upload failed with BadDigest and the backup
retried it forever. It now asks the source filer for its digest once and
forwards the entry digest only when that is md5.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup, filer.backup, filer.replicate: keep digests within one kind
filer.meta.backup opened its backup store in its own digest mode, so a copy
of a sha256 filer made by a process outside fips140=only got MD5 directory
keys and could not be opened as that filer's store. It now adopts the source
filer's digest before the store opens.
filer.backup and filer.replicate with a filer sink copied entry digests into
the target filer without comparing digests, as filer.sync did before. Both
now refuse, and exit, when the source and target filers report different
digests. replication.CheckDigestsMatch is the shared check; filer.sync uses
it too.
weed server and weed mini apply -filer.digest before they start the master
and volume server, so every part of the process hashes with one digest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, filer.sync: refuse a peer filer with another digest; exit on mismatch
Filers peering through the meta aggregator now compare digests. A peer with
a store of its own would replay entries holding the other kind of digest
into this filer's store, so its changes are refused and the reason logged
on every reconnect. A fresh filer bootstrapping from such a peer refuses the
copy, so a new filer whose digest differs from the existing filers' exits at
startup. A peer on the same store writes into it directly, and refusing its
stream would only starve this filer's subscribers, so that mismatch is
logged as an error and the stream kept.
filer.sync exits with status 1 when the two filers use different digests,
as filer.backup and filer.replicate do: it is a configuration error a
restart cannot fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: -digest help says a store keeps the digest it was created with
The help text said existing data keeps the digest it was written with,
which reads as if the flag could be changed on a store with data. Stores
that hash keys stop finding existing entries under another digest, so the
text now says to set it when the store is created, and that switching means
copying the metadata into a new store with fs.meta.save and fs.meta.load.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3, replication, admin, iceberg: address review of the digest checks
- A filer checks its peers' digests on every start, not only at the fresh-store
bootstrap: the store signature is written when the store opens, so a fresh
filer refused at bootstrap restarted as an initialized store and served
without its peers' files.
- Under digest sha256 with MD5 available (not fips140=only), a client's
Content-MD5 is checked against a separate real MD5 of the body, in S3 object,
part and directory-marker uploads and in filer HTTP uploads. It goes
unchecked only when no MD5 can be computed.
- filer.backup and filer.replicate exit only on a DigestMismatchError; a filer
that cannot be reached is retried, so a backup started before its target is
up resumes once the target answers.
- The admin file browser and Iceberg compaction write chunks into a filer they
do not follow at process level. They read that filer's digest and pass it to
the chunk upload (ChunkedUploadOption.Digest), so their content and chunk
digests match the filer's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer, s3 sink: retire digest-refused peers; no Content-MD5 for an unknown digest
- A peer refused for its digest counts as unreachable: the check now runs
before notePeerReachable and its error wraps errPeerUnreachable, so the
subscribe loop retires the peer from the low watermarks after the usual
grace instead of keeping its zero watermark, which held every aggregated
subscriber at the settled horizon.
- When the source filer's digest cannot be read, the S3 sink no longer sends
the entry digest as Content-MD5: it may be a SHA-256 digest the target
would reject.
- TestCheckPeerDigest skips the cases that need MD5 locally under
GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* iceberg, util: tests for the per-filer digest
The Iceberg tests' fake filer serves GetFilerConfiguration, which uploads now
call to read the target filer's digest; it reports none, as a filer that
predates the setting does. TestNewContentMd5 computes a real MD5, so it skips
under GODEBUG=fips140=only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: bound each startup peer digest read with a timeout
CheckPeerDigests read each peer's configuration with the caller's context,
which at startup has no deadline, so a peer that accepted the connection but
never answered held the filer's startup. Each read now has its own
peerDigestReadTimeout (10s, inside the one-minute announce cap), after which
the peer is logged and skipped like an unreachable one.
setDigestForTest restores the previous digest setting instead of the default.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, s3, filer: one-shot digests for data held in memory
Md5For hashes with md5.Sum or sha256.Sum256 instead of writing into a
hash.Hash, and the Content-MD5 checks of S3 directory markers and of filer
uploads saved inside the filer use BodyMd5Of on the bytes they already hold.
Streaming uploads keep their io.TeeReader.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: hash Content-MD5 on the upload's digest hash, not on its body
teeContentMd5 wrapped the request body in a TeeReader before
uploadRequestToChunks. CodeQL's go/reflected-xss query follows the body
from r.Body through the chunk upload to upload_content.go's
w.Write(prepared.data), which it resolves to the response-writer
wrappers in s3vectors, s3tables, webdav and server/common.go. Those
flows exist on master from other sources (extract, tagging, the
multipart POST); the wrapped body put them through lines this PR
changed, so CodeQL reported six of them as new.
newUploadHash now builds the digest hash that uploadReaderToChunks and
the inline-append paths already tee the body into, and adds the
separate MD5 there; uploadBodyMd5 reads it back for the check. The body
reaches uploadRequestToChunks as on master. Behaviour is unchanged:
under digest sha256 with MD5 available, Content-MD5 is checked against
the body's MD5, including empty and inline appends.
Checked with CodeQL 2.27.6 (go-queries 1.6.16, ReflectedXss.ql) on this
tree: no flow of the nine reflected-XSS results passes a changed line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* replication: keep the ReadFilerSignature name and return the digest with it
Renaming it to ReadFilerSignatureAndDigest left its other callers with an
undefined function. Keep the name and add the digest to what it returns.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: keep HashToInt32 off the digest mode
HashToInt32 names things that processes derive on their own, such as a
mount's local socket path and MQ partition key hashes. weed mount adopts
a -digest=sha256 filer's digest before it names its socket, while
weed shell mount.configure keeps md5 and dialed a different socket.
Follow GODEBUG only, as before the digest setting.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer.meta.backup: wait for the source filer's digest instead of exiting
A backup with a saved offset used to start its stream loop and retry
until the source filer answered. Reading the digest first made it exit
when started before the filer. Retry the read; exit only when the
digest is refused.
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>
|
||
|
|
9a98047e2a |
util/http: hedge a chunk read whose location goes quiet (#12917)
* util/http: hedge a chunk read whose location goes quiet A chunk read tried its locations one at a time and read each answer to the end. A response that stops arriving holds the read for as long as TCP takes to recover: on a lossy path a lost segment costs at least the 200 ms retransmission timeout, doubled for every further loss, and nothing gives up on the connection meanwhile. A sequential reader waits for its chunks in order, so one stalled chunk stops it, although a replica could send the chunk in milliseconds. A location that never answers holds the read for the transport's response header timeout. In production this showed up as 13 GB checkpoint verifications, read back serially with O_DIRECT through weed mount, crawling at 25-65 MB/s instead of 300 MB/s and more, while the hosts of the volume servers saw 2-5% TCP retransmissions. The volume servers' own GET latency stayed at a few milliseconds: the stall is on the wire, after the handler has written the chunk into the socket buffer. hedgedChunkPass keeps the order and the move-on-at-failure of the old loops. In addition, once every request in flight has been quiet for longer than it may be, the read is asked of the next location as well, or, once every location has been asked, again over a new connection of a location whose server answered. A request may be quiet for 200 ms before its response headers, while the server may still be reading the needle from a busy disk, and for 100 ms in the body, which a healthy server sends without pauses: half the minimum retransmission timeout, ahead of every wait for a retransmission, while shorter pauses that recover on their own go by. The first complete answer wins, and the other requests are cancelled. A read hedges at most twice. The first request reads straight into the caller's buffer, as before. Hedges read into pooled buffers, and a winning hedge is copied over only after the request writing the caller's buffer has ended, so the buffer has one writer at a time and is not written after the call returns. Hedging is budgeted: every read earns a tenth of a token, a hedge spends one, and at most ten are saved up, so hedges stay below about a tenth of the reads when the whole cluster is slow. A location that had sent no response headers when another one delivered the chunk is recorded as unreachable, which leaves it to the background probe of #12776 to put it first again, and counts as a failure for the location refresh. A body that stalled after its headers does neither. Measured with two volume servers whose outgoing links drop packets (netem, MTU 1500, 0.2 ms delay), reading a 1 GiB file of 2 MiB chunks through weed mount with dd iflag=direct bs=4M, before and after: bursty loss ~2.3% on both replicas 26-76 MB/s 162-193 MB/s random loss 3% on both replicas 106-119 MB/s 147-170 MB/s random loss 5% on one replica only 71-81 MB/s 157-158 MB/s no loss no change, 0-2 hedges per 512 reads Under loss 4-8% of the chunk reads were hedged. A 50 ms body limit did better on random loss (179-220 MB/s with 3% on both) but worse and less steadily on bursty loss (108-206 MB/s), where it spent the hedge budget on pauses that recover by themselves. Callers: RetriedFetchChunkData on the streaming and the direct path, which weed mount, the S3 gateway and the WebDAV server read chunks through. Readers that stream a chunk to a writer as it arrives are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: account hedge buffers, go past a throttled hedge, cap hedges per read Three review findings: - A hedge reads into a buffer of its own, which weed mount's reader cache budget did not see, so stalled downloads could hold twice the configured memory. The reader cache now passes its budget in the context (WithScratchBudget), and a hedge first takes room for its buffer with ReaderCacheBudget.TryReserveScratch. Like a download, that evicts idle chunks no stream is positioned in, but it never waits and never evicts a pinned chunk or a download in flight: a hedge that does not fit is not sent. The room is returned when the buffer is freed, also for requests abandoned in the background. - A hedge answered with 429 ended the asking, so the read waited out the stalled request although a third location was idle. The download limit behind a 429 is local to that server, so a throttled hedge now moves on to the next location; the 429 is still returned when nothing else delivers. - Each retry pass earned a new budget share and started a new count of two hedges. Both now belong to the read (readHedges) and carry over its passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: note an error's headers as an answer, take a hedge token before room Second round of review findings: - A location that sent the headers of an error response (a 500, say) and then stalled its body was still taken for one that had not answered while StatusError waited for that body. Had another location delivered the chunk meanwhile, it was recorded as unreachable and the location list refreshed. The response headers are now noted as soon as Do returns, before the status is looked at. - A hedge took room for its buffer before its token, and room can evict cached chunks. With no token left the room was given back, but the chunks were gone. The token now comes first, and is given back when there is no room. - TestReaderCacheBudgetLendsScratchToHedges opens the gate of the download it holds in a defer, so a failed assertion cannot leave the cache's teardown waiting on it. TestChunkReadHedgeCapCoversRetries also checks that the read earned its budget share once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: do not take a location asked again for unreachable A location whose response stalled is asked again over a new connection. When the first request then recovered and delivered the chunk, the new request had not answered yet, so the host that just served the chunk was recorded as unreachable and the location list refreshed. A location any request of the read heard from is no longer counted. 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> |
||
|
|
6adc9f0a21 |
mount: read chunks with filer-issued exact-file read tokens (#12800)
* mount: read chunks with filer-issued exact-file read tokens * mount: preserve read authorization across delayed lookups and hard links * mount: retain response tokens across read cache eviction * mount: keep a shared read-token lookup alive when its first caller is cancelled Token refreshes for one entry share a singleflight lookup that ran under the first caller's context. An interrupted read cancelled that lookup, so every other read of the entry waiting on it got no token, went out unauthenticated, and failed with EIO on a volume server enforcing read JWTs. Run the lookup detached from the caller (each attempt stays bounded by the filer RPC wait) and let a cancelled caller stop waiting at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: serve a cached chunk past the cache cutoff instead of fetching it The full-chunk read path consulted the chunk cache only for chunks below the cache size cutoff. Read-auth and peer-sharing mounts cache every chunk they upload, so a read-after-write of a high-offset chunk went to the volume, where a read-auth mount has no token before the entry is published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: re-track read tokens when this mount renames an open file Writeback mounts skip their own rename event, so only the subscriber path re-tracked an open handle's chunks. After a local rename a token refresh looked up the vacated name and the read failed. The rename response, the subscriber rename and the surviving hard link now share ReadAuth.TrackHandle. 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> |
||
|
|
a98c9e2718 | 4.55 | ||
|
|
c80bf3afac |
util/http: stop waiting on a response body the server stalls (#12875)
* util/http: stop waiting on a response body the server stalls CloseResponse reads the rest of a response body so that the connection can be reused, and StatusError reads the message a server puts in the body of a failed request. Neither had a time limit. The client's only read deadline covers the response headers, so when a server sent its headers and then stopped sending the body, both blocked until the request's context ended. Most callers pass a context that never ends. A chunk read whose replica answered 404 or 500 this way never returned, so it never got to the next replica. That holds for ReadUrlAsStream and for the replica fallback of S3 copies. Both now close the body once 5 seconds have passed. That fails the blocked read, and the connection is dropped instead of reused. A body that arrives in time is drained as before, and its connection is still reused. StatusError reports the status with whatever part of the message arrived. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * util/http: bound a body read that closing the body cannot interrupt The limit worked by closing the body, which fails a read blocked on it. That does not hold when the transport decodes gzip for the caller: in Go 1.26 its decoder reads the gzip header under a lock that Close also takes. A server that announced gzip and stalled before the gzip header kept both the read and the Close waiting, so the limit never applied. Such a response is now read on its own goroutine, and the caller stops waiting when the time is up. The read and the Close stay behind until the connection dies. Every other response keeps the cheaper way, with no goroutine. StatusError now returns the status alone when the message did not arrive in time. A partly read message is no longer safe to use, because the read may still be running. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com> Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com> |
||
|
|
40fe40556c |
filer.meta.backup: list large etcd directories without the 3s request deadline, skip excluded subtrees (#12870)
* filer/etcd: list a directory without the request deadline etcd counts every key left in a range even when the request is limited, so one page of a directory costs time that grows with the entries after it: about 0.3 s at the start of a 4 million entry directory on an idle local etcd, against 1.6 ms near its end. The 3 s request_timeout therefore fails listings of large directories, which a long walk such as filer.meta.backup reaches page after page, with "list <dir> : context deadline exceeded". Listings keep the caller's context like DeleteFolderChildren; keepalive still ends a call to a member that stops answering. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: let a TraverseDfs callback skip a directory's subtree fn returning fs.SkipDir for a directory leaves its subtree unlisted; the directory is still reported as walked, so a resumed walk passes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: do not walk directories the path filter leaves out The walk listed every directory and dropped excluded entries one by one, so -excludePrefixes could not keep it out of a directory: a huge or failing excluded directory was still listed page by page. A directory that is not included and has no include prefix under it is now skipped whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: resume outside a directory the path filter leaves out A walk saved before the filter skipped directories, or before the filter changed, can hold a position inside a directory the walk now leaves out. Resuming there entered the directory without asking the filter and listed it. The resume position moves to the topmost such directory, which a resumed walk treats as done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer.meta.backup: skip the walk when the path filter leaves out its root The root of the walk is never handed to the callback, so a -filerDir the filter leaves out was still listed. Nothing under it would be backed up, so the walk now ends before it starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ebd90c3a45 |
fips140=only: SHA-256 in place of MD5 and SHA-1 so the server starts and serves S3 (#12855)
* util: SHA-256 stands in for MD5 and SHA-1 under fips140=only GODEBUG=fips140=only panics on MD5 and SHA-1. NewMd5 and NewSha1 return those hashes as before, and under fips140=only SHA-256 cut to the same size, so digests keep their length. Md5, HashStringToLong and HashToInt32 use NewMd5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer stores: hash directory keys with NewMd5 and NewSha1 leveldb2, leveldb3, rocksdb and arangodb hash directory keys with MD5, tikv with SHA-1, which GODEBUG=fips140=only refuses, so the filer panicked at startup. They now use util.NewMd5 and util.NewSha1. Keys made under fips140=only differ from MD5 keys, so leveldb2 and leveldb3 mark an empty database opened under fips140=only and refuse a database whose keys are of the other kind instead of showing it empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * operation, volume: no Content-MD5 checks under fips140=only Under GODEBUG=fips140=only the uploader's digest is not an MD5, so it is no longer sent as Content-MD5, which volume servers outside that mode would reject; the digest still becomes the chunk ETag. A Go volume server in that mode keeps a client's Content-MD5 unchecked instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, filer: ETags and content digests with util.NewMd5 ETags, entry Md5 attributes and chunk digests now use util.Md5 and util.NewMd5, so under GODEBUG=fips140=only they are SHA-256 cut to 16 bytes instead of panicking. That digest cannot check a client's Content-MD5, so in that mode Content-MD5 is accepted unchecked, and the filer stops returning Content-MD5. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api, iam, master: SHA-1 names with util.NewSha1 Multipart upload ids, IAM policy ids, the OIDC provider, audit and session revocation file names, and the master's read-only copy dir hash names with SHA-1. They now use util.NewSha1, which GODEBUG=fips140=only turns into truncated SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * postgres, oidc, update: refuse MD5 and SHA-1 checks under fips140=only PostgreSQL md5 authentication, OIDC TLS thumbprints (SHA-1 by definition) and weed update's MD5 check of the download cannot run under GODEBUG=fips140=only. They now fail with an error saying so instead of panicking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: no empty-body MD5 when Content-MD5 is not checked Under fips140=only a bodyless signed request still reached md5.Sum(nil) before the nil check and panicked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: empty copy part ETag from the digest it stores Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: skip the native MD5 test under fips140=only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3sink: no Content-MD5 under fips140=only The entry's Md5 attribute is truncated SHA-256 there, which an S3 destination checking Content-MD5 would reject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: move OIDC provider and revocation records to this mode's name The record names hash the ARN or JTI with util.NewSha1, which differs under GODEBUG=fips140=only. On the first use of a filer, each store renames records whose name does not match the one derived from their content, so lookups, revocation checks and deletes find records written in the other mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: test the rename with the names each fips140 mode derives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * iam: rename a record only if it is unchanged, under its new name's lock Two processes renaming after a mode switch could both list a record; if one renamed it and the provider was then deleted, the other wrote it back. The rename is now one filer transaction locked on the new name, like the stores' conditional writes, that requires the old entry to be unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
1b209f7717 |
util, s3api: AES-GCM via NewGCMWithRandomNonce for fips140=only (#12847)
* util: AES-GCM via NewGCMWithRandomNonce in Encrypt/Decrypt
cipher.NewGCM returns an error under GODEBUG=fips140=only ("use of GCM
with arbitrary IVs is not allowed"), so filer -encryptVolumeData cannot
encrypt or decrypt chunks in that mode. NewGCMWithRandomNonce produces the
same nonce(12) || ciphertext || tag layout, so chunks written by earlier
versions still decrypt and older versions can read new chunks; the tests
check both directions against a copy of the previous code.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: SSE-S3 DEK and KEK wrapping via NewGCMWithRandomNonce
cipher.NewGCM returns an error under GODEBUG=fips140=only, so SSE-S3
PutObject fails in that mode. NewGCMWithRandomNonce yields the same nonce
and ciphertext+tag bytes: the wrapped KEK keeps its magic || salt || nonce
|| ciphertext+tag layout, and the DEK's nonce and ciphertext are still stored
as separate metadata fields. sealGCMSplit and openGCMSplit split and join
them, with the nonce length as gcmNonceSize, because the random-nonce AEAD's
NonceSize() reports 0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util, s3api: keep AES-GCM working for AES blocks NewGCMWithRandomNonce refuses
cipher.NewGCMWithRandomNonce accepts only the standard library's own
*aes.Block. In a GOEXPERIMENT=boringcrypto build aes.NewCipher returns
BoringCrypto's block instead, so Encrypt, Decrypt and SSE-S3 key wrapping
would fail there. util's newGCMWithRandomNonce falls back to cipher.NewGCM
with a nonce from crypto/rand for such blocks, with the same
nonce || ciphertext || tag output. SSE-S3's KEK wrap and DEK wrapping use no
additional data, so they now go through util.Encrypt and util.Decrypt and
build no AES-GCM of their own; the stored bytes are unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* util: keep the GCM fallback test working in boringcrypto builds
cipher.NewGCMWithRandomNonce refuses aes.NewCipher's block in a
GOEXPERIMENT=boringcrypto build, so the test failed there before it
reached the fallback. Compare with cipher.NewGCM and the nonce in front
when the native constructor is unavailable.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: build the SSE-S3 sealed buffers with slices.Concat
Summing the input lengths for make() trips CodeQL's
go/allocation-size-overflow on the DEK path, whose inputs come from
stored metadata.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3api: draw SSE-S3 key IDs from crypto/rand
The math/rand key ID is serialized next to the wrapped DEK, so CodeQL's
go/insecure-randomness follows it from the metadata JSON into the
AES-GCM open of the DEK.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
|
||
|
|
aa95f631f2 |
http: keep the body pieces that arrive after a read is cancelled (#12822)
RetriedFetchChunkData's callback for ReadUrlAsStream skipped every piece once ctx was cancelled. ReadUrlAsStream checks ctx only before each body read, so when ctx is cancelled while the last read is under way, that read returns the last piece with io.EOF, the callback drops it, and the fetch returns fewer bytes than asked with a nil error. Nothing above it checks the length: weed mount answers the FUSE read with the short buffer, and the kernel takes a short buffered read as the end of the file, so the reader sees EOF in the middle of it. The callback now keeps every piece. A read cancelled before its last piece still ends with ctx.Err() from ReadUrlAsStream's own check, so the download still stops; one cancelled during the last piece returns the whole range. An encrypted chunk reaches the callback in one piece, so there the old check lost the whole chunk: 0 bytes and no error. TestRetriedFetchChunkDataCancelledWhileTheLastPieceArrives cancels ctx inside the body read that returns the last piece, for a range read and an encrypted chunk; both fail on master with fewer bytes and no error. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8df716b728 |
volume: make a delete retry after a failed replica fan-out reach the replicas (#12797)
* http: report the status of a failed delete that has no body A replica that answers a DELETE with a bare 500 left the forwarding server reporting "[<replica>]: " with an empty reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: forward a delete retry that finds nothing here to the replicas A delete is applied locally before it is sent to the other replicas, so when the fan-out fails the client is told to retry while this replica already dropped the needle. The retry then read nothing here and answered 404 without asking the replicas, so the replica that missed the delete kept the needle for good. On a replicated volume, a plain delete that finds the needle missing or deleted now cancels a write still queued for it, as a replica delete does, and sends the delete on to the other replicas. A failed fan-out is reported as before, so the client retries until every replica agrees. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): take a replica's 404 to a forwarded delete as done A replica that no longer holds the needle answers a forwarded delete with 404. The Go server folds that into success, but the Rust server reported it as a replication failure, so a delete that only had to catch up one replica failed on the replica that was already in step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): forward a delete retry that finds nothing here to the replicas Mirrors the Go server: on a replicated volume, a plain delete that finds the needle missing or deleted cancels a write still queued for it and sends the delete on to the other replicas, so a retry after a failed fan-out reaches the replica that kept the needle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume: answer a delete whose needle read fails with 500, not 404 A replica's 404 to a forwarded delete is taken as the needle being gone there. DeleteHandler answered 404 for any failed pre-read, so a replica whose disk could not read the needle let the primary acknowledge a delete that replica never applied. Only a missing or deleted needle (or a volume this server does not hold) answers 404 now; other read errors are a 500, so the client retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): answer a delete whose needle read fails with 500, not 404 Mirrors the Go server: a replica's 404 to a forwarded delete is taken as the needle being gone there, so only a missing or deleted needle answers 404; other read errors are a 500 and the client retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * volume(rs): corrupt the needle with portable file writes in the delete read test FileExt::write_all_at is Unix-only, so the test did not build on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
f7323f2b63 |
filer: optional HTTP Basic Auth on the filer HTTP ports (#12778)
* security: add a constant-time HTTP Basic Auth check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: require HTTP Basic Auth on the HTTP ports when configured With filer.basic_auth.password set in security.toml (or WEED_FILER_BASIC_AUTH_PASSWORD), a request on the filer HTTP ports, TUS included, must carry those credentials or a valid filer JWT, and an access level with no JWT signing key is no longer open. Valid Basic credentials grant read and write. 401 responses then carry a Basic challenge so browsers prompt. The credentials reload on SIGHUP with the signing keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * scaffold: document filer.basic_auth in security.toml Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: enable reloaded Basic Auth before swapping the JWT keys Reload cleared the old signing keys before storing the new Basic credentials, so a switch from JWT to Basic Auth briefly left both off and admitted anonymous requests. Store new credentials first and clear old ones last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: refuse Basic credentials on cross-origin browser requests Browsers resend cached Basic credentials on requests other websites trigger, such as a form POST with mv.from, and the default cors.allowed_origins "*" lets them through. Accept Basic credentials only on requests without an Origin, from the filer's own host, or from an origin explicitly listed in cors.allowed_origins. A JWT is still accepted from any origin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: recheck Basic Auth after reading an empty signing key A request that loaded Basic Auth as off, then read the signing key after a JWT-to-Basic Reload had cleared it, was let through anonymously. Open access now also needs Basic Auth to be off after the key read; with Reload enabling the new credential before disabling the old one, the two loads cannot both miss a credential that was on throughout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * security: compare Basic Auth credentials as MACs under a per-process key A plain SHA-256 of the password is what password-hash scanners flag; keying the digests with a random per-process HMAC key keeps the length-independent constant-time compare without holding one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read a configuration file without merging into the shared viper LoadConfiguration merges each read into the shared viper, so a key removed from the file keeps its old value after a reload. ReadConfiguration reads the file into a fresh viper with the same search path and WEED_ environment overrides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: turn Basic Auth off when security.toml no longer sets it The shared viper merges each SIGHUP reload into what it held, so removing [filer.basic_auth] kept the old password valid. Read the credentials from security.toml alone at startup and on reload; an unreadable file keeps the current setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep Basic Auth when security.toml cannot be read A malformed file at startup dropped a WEED_FILER_BASIC_AUTH_PASSWORD from the environment, and viper reports an unsearchable config directory as a missing file, which turned Basic Auth off on reload. ReadConfiguration now always returns the environment overrides and reports whether the file was read; a reload that could not read it keeps the current credentials. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: keep reloading Basic Auth from the security.toml first read A search directory that turned unsearchable made viper fall through to a lower-priority security.toml, and a reload from a file without [filer.basic_auth] turned Basic Auth off. ReadConfiguration now takes the file to read, and the filer reads the file it first found on every reload. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
972f85159e |
util/http: probe dead replicas in the background and key no-answer dials by machine (#12776)
* util/http: probe an unanswering server in the background, not on a read Once the retry interval passed, the first read put the dead server first and waited out the full dial timeout before trying a live replica. Keep it last and dial it from a background probe with a short timeout instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: try every server of a machine that does not answer last Unreachability was kept per host:port, so a powered-off node running one volume server per disk cost one stalled read per server before each was known dead. A dial that times out or finds no route now marks the whole machine; a refused connection still marks only that port and shows the machine is up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: probe an unanswering server with an HTTP request A bare TCP connect cleared servers that accept connections but never send response headers, and could not dial an address without an explicit port. Probe with a HEAD request through the global client instead, and have the tests wait for the probe to settle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: keep a timed-out port last after a sibling port answers A dial timeout stored only the machine verdict, so a success on another port of that machine cleared it and the port that timed out went back to the front. Record the port as well as the machine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: classify refused and unroutable dials with Winsock errnos on Windows Windows reports these as WSAECONNREFUSED, WSAEHOSTUNREACH and friends, which errors.Is does not match against the syscall constants. Test the refusal with a real dial to a closed port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: wait for background probes through a WaitGroup in tests A refused probe can finish before the test reads the claimed record, so inferring completion from the record's timestamp could wait out the deadline on a probe that already settled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: key machine verdicts apart from hosts without a port A host without an explicit port is also its machine name, so a sibling port answering cleared the timed-out host along with the machine verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: group a bracketed port-less IPv6 host with its machine net.SplitHostPort rejects "[2001:db8::9]", so the machine key kept the brackets and missed the verdict stored for "[2001:db8::9]:9501". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
ebc77400ca |
operation: reassign an upload after a proven-expired volume JWT (#12729)
* operation: reassign an upload after a proven-expired volume JWT * seaweed-volume: mark an expired write JWT refused before append Mirror the Go volume server: a multipart POST whose write JWT is signed with the current key, names this fid and fails only on exp gets X-Seaweed-Write-Outcome: expired-jwt-before-append on its 401, so the uploader reassigns instead of failing. Both checks use one guard snapshot, so a key rotation between them cannot drop the marker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * operation: keep same-FID retry for filer-proxy expiries, snapshot the write signing key, and make the RetryForever budget test fail fast * operation: re-mint the filer credential before a proxy same-FID expiry retry * operation: make a proxy marked-expiry terminal in the outer retry too, not only the inner same-FID loop --------- Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
91eaabf371 |
s3: answer ClientDisconnected for a GET the client aborted before the first byte (#12707)
* s3: answer ClientDisconnected for a GET the client aborted before the first byte Fixes #12706 * s3: tell a gone client on TLS and HTTP/2 too, and not on a connection the server closed |
||
|
|
0d3f5a220c |
s3: keep serving for -preStopSeconds after SIGTERM (#12703)
* s3: keep serving for -preStopSeconds after SIGTERM On SIGTERM the gateway closed its listeners at once, so requests a load balancer or Kubernetes Service still routed to it failed until the endpoint was removed. With -preStopSeconds set, the gateway makes /status, /healthz and /readyz return 503, keeps serving for that many seconds, then runs the existing graceful shutdown. 0 (the default) keeps the old behavior. The flag is registered for weed s3 and as -s3.preStopSeconds for weed filer, weed server and weed mini. A cancelled weed mini cluster context ends the wait early. The Helm chart passes s3.preStopSeconds and filer.s3.preStopSeconds through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: assert the preStopSeconds chart render under set -e, drop timing from the probe test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: wait before weed mini cancels its clients; size grace periods in the chart weed mini's interrupt hook runs before the S3 one and cancels the S3 gateway's shutdownCtx, so the pre-stop wait never happened there. The wait is now also registered with beforeMiniClientsShutdown, which runs before that cancel, and a sync.OnceFunc keeps the interrupt hook from waiting a second time. Outside weed mini the registration is a no-op. Helm: the s3 deployment fails to render when terminationGracePeriodSeconds is below preStopSeconds + 15. The filer statefulset and the all-in-one deployment, whose grace period is fixed at 60s, add preStopSeconds to it. allInOne.s3.preStopSeconds is passed through, inheriting s3.preStopSeconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: keep 64-bit counters aligned on 386; let allInOne.s3.preStopSeconds=0 disable the wait draining sat ahead of inFlightDataSize and inFlightUploads in S3ApiServer and shifted them off 8-byte alignment on 32-bit builds, so the atomic upload-limit counters panicked there. It now follows them. Helm: allInOne.s3.preStopSeconds inherits s3.preStopSeconds only when null; default treated an explicit 0 as unset. The s3 values and the grace period error now say a lifecycle preStop hook's time comes on top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * grace: add OnInterruptFirst for hooks that must run before any shutdown Interrupt hooks run in reverse registration order, so a hook cannot run ahead of a service that registers later, such as a volume server that is still loading its volumes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: run the -preStopSeconds wait before every other interrupt hook Under weed server the volume server registers its hook once its volumes are loaded, often after the S3 gateway. Its hook then ran first and shut the volume server down, so the gateway spent the whole wait serving requests that could not read or write objects. 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> |
||
|
|
5ef99c1d8d | 4.54 | ||
|
|
8e15110b4f |
filer: wake metadata subscribers only for directories they can match (#12669)
* log_buffer: let a subscriber skip wake-ups for unwanted partition keys Every append woke every registered subscriber. SetSubscriberWakeFilter lets a reader sleep through appends whose partition key it would filter out; it still reads them on its next poll. Flushes and keyless appends wake everyone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer_pb: decide subscription matches from an event's directories MetadataDirectoryMayMatchSubscription rules out events whose directory no child path of can match the subscription, and ScanMetadataEventDirectories reads an event's directory and new parent path without allocating. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: wake subscribers of a move's destination directory Appends are keyed by the source directory, so a filtered subscriber of the destination would otherwise only see the move on its next poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: wake metadata subscribers only for directories they can match Every metadata event woke and was scanned by every subscriber, so filer CPU grew with the number of subscribers watching other paths. Readers now register a directory wake filter, and the per-entry prefilter rules entries out from their directories before the skeleton scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: test that moves into a subscribed prefix pass the prefilter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6eb2fb4842 |
filer: stop full-chunk reads at the chunk size after a mount truncate (#12632)
* util/http: stop a full-chunk read at the chunk's recorded size weed mount shrinks a chunk's Size in place on ftruncate but leaves its needle untouched. A view covering the whole shortened chunk is fetched without a Range header, so the reader returned every stored byte. The filer GET then wrote past the declared Content-Length and sent an empty body, and the stream reader served the stale tail. ReadUrlAsStream and the cipher path now deliver at most size bytes; size 0 still reads the whole needle for manifest and log chunks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3api: limit a plain chunk read to the requested size A full-chunk read sends no Range header, so a chunk shortened by a mount truncate streamed its whole needle into the S3 response. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util/http: still report a failure past the chunk size The volume server aborts a full-needle response when the needle fails its checksum, and only at the end. Stopping at the chunk size missed that, so a damaged copy read as healthy. Read the rest of the body and return its error so the caller tries another copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
fcfca3fee3 |
s3, filer: bound the wait for an upload slot (#12559)
* util: add WaitUntil, a cond wait bounded by a context and a timeout The caller holds the cond lock. Cancellation and the timeout wake the waiter through a broadcast taken under the same lock, so no wakeup is lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: bound the wait for an upload slot A PUT that arrived while the concurrent upload limits were exhausted waited on the condition variable with no bound. The handler reads nothing from the body while it waits, so a client that gave up and reset its connection went unnoticed: the socket and goroutine stayed pinned until a slot freed, and a stalled volume server grew the gateway's fd count by one per aborted PUT. The wait now ends on InflightUploadDataTimeout with 503 SlowDown, which S3 SDKs retry, and on request cancellation. An admitted upload takes its slot under the lock, and a finished upload broadcasts, so freed bytes admit every waiter that fits instead of one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * filer: bound the wait for an upload slot The filer's PUT/POST upload limits queued requests the same unbounded way. Reuse the bounded wait: reject with 429 after InflightUploadDataTimeout, as the volume server does, and stop on request cancellation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * command: add -inflightUploadDataTimeout for the S3 gateway and the filer weed s3 -inflightUploadDataTimeout, weed filer -inflightUploadDataTimeout and -s3.inflightUploadDataTimeout, weed server and weed mini -filer.inflightUploadDataTimeout and -s3.inflightUploadDataTimeout. The default of 60s matches the volume server's flag of the same name; 0 keeps the old unbounded wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3: reject a queued upload without reading its body WriteErrorResponse drains the request body before answering. Behind the stats recorder the drain has no read deadline, and reading the body sends an Expect: 100-continue client the go-ahead to upload what is about to be discarded. Answer the rejection with an empty-body copy of the request so the drain is skipped; net/http closes the connection when a large unread body remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3, filer: release an upload slot under the cond lock A waiter checks the counters under the cond lock and then waits. A release that decremented and broadcast without the lock could land between the two, so the waiter slept with a slot free until the next release or its timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * s3, filer: close the HTTP/1 connection when rejecting a queued upload net/http reads up to 256 KiB of an unread request body before sending a keep-alive reply, so a client that stalls its body held back the 503 or 429 until the connection idle timeout. Connection: close skips that read. HTTP/2 is left alone: there it would shut down the whole connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
4ab66fb76d | 4.53 | ||
|
|
329ccb8bc0 |
master: tell a warming-up Assign or LookupVolume client when warm-up ends (#12386)
* master: tell a warming-up Assign client when warm-up ends During warm-up the master refuses Assign with Unavailable and now attaches the remaining warm-up as a gRPC RetryInfo detail. RetryWithBackoff may shorten a backoff step to that hint plus 50 ms, never lengthen it, and only for a valid, positive hint, so a writer retries right after warm-up ends instead of up to one backoff step later. The warm-up itself is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: jitter the retry-hint slack and hint LookupVolume too Per review: the slack added to a server hint is now random in [50ms, 300ms], so clients refused at the same moment do not all retry in one instant. The warm-up refusal of LookupVolume carries the same RetryInfo hint as Assign; the masterclient's lookup retry already goes through RetryWithBackoff, so it lands at warm-up end too. Tests: the slow guard tests are replaced by one sleep-free table test of the step logic (zero, negative, huge, malformed, valid and wrapped hints, a hint longer than the step, none). One timing test of the shortened step stays, plus a jitter-bounds test and a LookupVolume hint test. The no-hint control test, which was timing-sensitive, is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: name the shared warm-up test and file the lookup test by topic Rename the no-remaining test to TestWarmingUpErrorWithoutRemainingHasNoHint, since the helper now serves Assign and LookupVolume, and move the LookupVolume hint test next to the other LookupVolume warm-up tests. Tests only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util: read the retry hint through ServerStatus Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * master: bound the warm-up hint in tests by the remaining warm-up around the RPC Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: leave more scheduler margin in the retry-hint timing tests Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * util, master: trim retry-hint comments Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: widen the retry-hint timing bounds to just under the unhinted wait Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: require a refused warm-up call before the hinted assign retry Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: check the hinted retry wait through a test timer, not the wall clock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: move the assign warm-up end to 2.6s for more hinted-retry headroom Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: require the hinted retry to wait out its timer 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> |
||
|
|
d650abe0e7 |
compression: compress JSON uploads, and match file types by extension (#12339)
* compression: compress JSON uploads, and match file types by extension
IsCompressableFileType did not recognise JSON media types, so S3 uploads of application/json (which carry no file name) were never compressed. Its callers also passed filepath.Base of the file name where it expects the extension, so the .json/.js/.html/... extension rules never matched a real file name. Both callers now pass filepath.Ext; the function lower-cases the extension and media type, ignores media-type parameters ("application/json; charset=utf-8"), and treats */json and *+json types as compressible.
* compression: treat application/json-seq as JSON
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* volume(rust): compress JSON uploads and match media types without parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* operation: keep uploader gzip only when it saves at least 10%
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Pat White <5015863+patwhite@users.noreply.github.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|