Repository navigation
Fix the bugs found in S3 (#263 #266 #267 #268 #270) - #275
Merged
Merged
Conversation
serveFallback's handler task is the subscriber's sender. A publish after its loop ended claimed a sender (open(idle) -> open(running)) that only set wake, so finishSubscriber's awaitSender waited forever: the handler hung and the subscriber leaked. finishSubscriber now applies sender_idle for a fallback subscriber after .finish (left(e, s) x sender_idle, an existing cell). Both catches in the loop record the cancel and the task re-raises it with io.recancel() after finishSubscriber. Test: topics_test, a fallback subscriber claimed by a publish after its loop ends (Topics._finish, a test hook).
Between register and a park that fails with Unsupported, a publish past max_queued_bytes moved the subscriber to opening(graceful) and queued the end; abandon dropped the queue and the end with it, and the second register queued only the open line and the replay, so the fallback stream never ended. register's non-draining branch now queues the end again when the life already holds one (pushEnd, shared with beginClose): close_reason stays .slow and closed_slow counts once. The draining branch is unchanged (queueDrainEnd queues its own end). Test: topics_test, both branches through the _register/_fallBack hooks.
Batch.hold chose the backstop or the thread path by the caller's thread, so a hold from a thread with no executor on a joined batch spawned a flusher under the write lock while endIfIdle and Backstop.run write the task under home.mutex: two flushers, or a task left none or running with nobody to flush. hold now takes the backstop path whenever the batch is joined or queued (member != .free), from any thread; the thread path is left to free batches only. Docs updated. Test: a hold off the executors on a joined and on a queued batch queues it and starts no flusher.
register and checkRoute tested isCached on the outermost handler type, so doc(texts, cached(o, h)) got no ResponseCache and compiled on a POST route, while routeInfo and openapi reported it cached. Both now read the peeled markers: handlers.cacheOptions (the outermost cached's options) and anyCached. Tests: ResponseCache rows for cached, doc(cached), cached(doc), doc(cached(noWait)), noWait and doc alone; the peel table checks cacheOptions; compile error 14 (doc(cached) on app.post).
…them (#268) redial and autoH3 kept every replaced connection until Channel.close, so a long-lived channel that redials grew without bound. An owned channel now counts its calls: openOn leases before pick reads a slot, the stream's deinit (or a failed open) gives it back, and the last lease out closes both retired lists with the lock let go. A retired connection is in no slot, so a call that leases after the retire cannot reach it, and one that read it before already holds a lease. The slot loads and stores are atomic (seq_cst, with the lease count), which also closes the plain-load race on conn/h3 (D2). transport() leases around its look; runtime() reads the channel's io instead of a connection's. Owned grows by its io and the u32 count; two uncontended RMWs per call. Test: h3_test, three redials leave nothing retired; a bidi stream on a replaced connection keeps it until it ends; a canceled call gives its lease back.
The End -> result switch, with its unreachable closed arm, is one comptime EnumArray(End, ?NextError) (end_error; null: next returns null). Closed still fails at once, before the messages; every other end after the drain. No behaviour change; the existing next tests cover all six cells.
Upload's sections allocate (copyIn's appends, the finish path, setFailure's dupes) under what was a spin lock. It is a std.Io.Mutex now, taken with lockUncancelable(self.io) in the same lock()/unlock() pair, so no call site changes. The C ABI's upload write takes it from the host thread: zio parks a foreign thread on its own futex.
request.zig and client.zig each declared the same unread / reader_taken / cached union with its own table. It is one pub BodyState in request.zig, with one table documenting both reactions of reader_taken (the request: error.BodyReaderTaken; the client: its debug assert); client.zig aliases it. No behaviour change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bugs I found during S3, one commit each, plus three small leftovers. Specs: research/post070/s3bugs.md.
serveFallback's loop ended claimed a sender nothing would run, andfinishSubscriberwaited for it forever. The end now lets that sender go (sender_idle, an existing cell), and both cancel catches in the loop re-raise withio.recancel(). Before the fix the new test hung (killed after 70 s); after, it passes at once.max_queued_bytesbetweenregisterand a failed park queued the end, andabandondropped it with the queue.registernow queues the end again (pushEnd, shared withbeginClose);.slowis counted once. The draining branch is unchanged. Red before the fix (no end in the queue).holdpicks the backstop path whenever the batch is joined or queued, not only on an executor, so the flusher task has one lock owner. Red before the fix (task == .running).doc(cached(..)):registerandcheckRouteread the peeled markers (handlers.cacheOptions,anyCached). Red before the fix (/m17ran twice; compile error 14 compiled).pickreads a slot; released inStream.deinitor a failed open), and the last lease out closes the retired lists with the lock let go. The slot loads and stores are atomic (closes D2). Two uncontended RMWs per call;Ownedgrows by itsioand a u32.next's end as a comptime table), s3: Upload holds its spin lock across allocations #256 (Upload's lock blocks instead of spinning; zio parks a C ABI host thread on its futex), request and client body state: one shared BodyState union #251 (oneBodyStatefor the request and the client response).Tests: scoped filters per item (sse, WebSocket, ResponseCache, peel, grpc, MessageQueue, nats, s3, body, plus
capi-testfor s3), thentest,capi-testandtest-compile-errors(2352 passed, 178 skipped),test -Dhttp3=false -Dtest-filter=grpctest-stress -Dtest-filter=sse, and ReleaseSafe for the sse, WebSocket and grpc filters. No benchmarks.Not done: the
perf statgate for #270 (one enum compare before the existing branch; no benchmarks during S3), and an.h2row for #268 (the h2 client has no GOAWAY test hook; the.h3row exercises the sameredial).Closes #263
Closes #266
Closes #267
Closes #268
Closes #270
Closes #251
Closes #256
Closes #257