Repository navigation
ocr: hand the caller credential to the worker before the card commits - #4
Merged
Merged
Conversation
Every upload whose transaction outlasted a worker poll (the sheet-split call alone can take 15 s) ended 'unavailable' within seconds. Writes are serialized by an advisory lock, so the worker's claim queued behind the upload and ran the instant it committed - before the handler enqueued the bearer afterwards. The worker then found the card with no credential and recorded it unavailable. The credential is now enqueued inside the transaction, forgotten if it fails, and the worker is woken after the commit.
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.
Problem
On Craftsman (Contacts 0.3.1, CPU-only
llm), an uploaded card becameocrState: unavailablewithin 4 s, twice out of two uploads; pressing retry then started a real read.Writes take
pg_advisory_xact_lock. A worker poll that fires while the upload transaction is open (it contains the sheet-split call, up to 15 s) queues behind it and claims the card the instant the upload commits, before the handler reachesEnqueue.processCardfinds no bearer and marks the card unavailable.Change
Enqueue inside the transaction (credential present whenever the card is claimable),
Forgeton failure,Kickafter commit. The two tests that pinned enqueue-after-commit now assert the credential is handed over before the card is visible and that the wake-up follows the commit.Checks
go vet ./cmd/server/...,go test -p 1 -count=1 ./cmd/server/...against PostgreSQL 16: pass.