Avoid registry lock during first-byte attribution - #5
Conversation
Verified tree: 7395984 Policy: f6b77f17eafcfc1feefc4567319da0e564d02ed90cc71129956ec97444f4781d
Numinous Forge · Change and verificationResult: repaired and merged into this fork. This is a separate streaming problem found while checking the reconnect work. What was wrong: A provider could already be processing a request while the client waited for its first response bytes. Response bookkeeping needed another registry lookup, which could wait behind the global registry write lock. What changed: Use the matching provider already held by the request. Primary dispatch, backup dispatch, and live response attribution no longer need that extra global lookup. Finished-request attribution stays frozen; missing or mismatched providers yield unknown attribution. What we proved:
Review focus: Provider identity must match the request, including backup paths. Finished-request attribution must not change when a later serving attempt begins. Earlier incomplete and timed-out attempts were retained and followed by a verified revision; their output was not accepted as a passing result. Review summary for 9fadac3bf465. Live task and CI progress are reported separately. |
A registry write lock could stall the first response bytes after the provider had already received the request. Serving-slot bookkeeping looked the provider up again through
Registry.GetProviderduring primary dispatch, backup re-latching, and live winner attribution.Use the matching provider already held by the dispatch state. Preserve frozen terminal attribution and existing paged/contiguous expectations; an absent or mismatched provider yields unknown attribution. The deterministic HTTP regression holds the registry lock before the latch executes, while helper tests cover backup and winner paths.
flowchart LR subgraph Before B1[Provider receives request] --> B2[dispatchPrimary or backup race] B2 --> B3[noteServingSlotFor or kvBackendAttribution] B3 --> B4[Registry.GetProvider read lock] B4 --> B5[Wait behind registry writer] B5 --> B6[First client bytes delayed] endflowchart LR subgraph After A1[Provider receives request] --> A2[dispatchPrimary or backup race] A2 --> A3[noteServingSlotFor or liveSlotBackend] A3 --> A4[Matching retained Provider.SlotKVBackendTags] A4 --> A5[First client bytes without global registry lookup] A3 --> A6[Missing or mismatched provider yields unknown] A2 --> A7[Terminal snapshot stays frozen] endValidation: focused race tests pass three repetitions. Restoring the old lookups makes the deterministic HTTP regression fail at its original two-second assertion and makes the affected helper tests fail. The original first-byte assertion remains unchanged. Forge separately verifies the complete coordinator race suite with real PostgreSQL and checks documentation, then PR CI verifies the merge with the target branch.
The task history retains the first incomplete candidate, a superseded source revision, and a timed-out implementation. Its successful edits were recovered from the retained transcript and reviewed before this continuation. The timeout itself was not treated as a verified result. Publication evidence below identifies the final candidate and separate verification runs.
This change was prepared by Numinous Forge and independently verified on a fresh worker.
Task:
30589095b35cf00ef20dee1214ba0e27Base:
9ad2aa17bcb13598804d074c3cdada2aeed80b72Verified tree:
73959842c03bd84c15a1fd52e99695888909e72aPolicy:
f6b77f17eafcfc1feefc4567319da0e564d02ed90cc71129956ec97444f4781dVerification runs:
5acedec2fdea5c235c246cedc079b22f,7691910dcb0e9db936f1356ca80fb7e2Export full evidence with
numinous-forge task export 30589095b35cf00ef20dee1214ba0e27 ./evidence.Before:
After:
This draft requires maintainer review of behavior, tests, and any workflow changes before merge.