Share one fetch and transcode among concurrent misses (closes #65) #160

Merged
clawbot merged 3 commits from issue-65-share-concurrent-misses into next 2026-10-04 01:58:50 +02:00
3 Commits
Author SHA1 Message Date
clawbot ef3ebc462e Share one fetch and transcode among concurrent misses (closes #65)
check / check (push) Successful in 4m20s
Requests that missed the same variant at once each fetched and
transcoded it. They now share one call through
golang.org/x/sync/singleflight, keyed on the variant cache key. The
first request processes the variant with a context that ignores its
cancellation but keeps its deadline; the others wait for its result,
holding no connection or processing slot, and return as soon as their
own context ends. The processing request waits even then, up to its
deadline. Each request counts one miss; the processing counts its fetch
and transcode once. A panic while processing is reported through the
request's Sentry hub, when there is one, and becomes an error instead
of stopping pixad.

Model: opus-5-5
2026-10-03 15:54:43 +00:00
clawbot 2777d3f784 Test that a shared miss keeps its deadline and reports panics (closes #65)
A request with a deadline whose fetch waits on its context, as the
fetcher does while it waits for a free connection to the host, must
return by that deadline. A panic while a variant is being made must be
reported through the Sentry hub on the request's context, where the
Sentry middleware puts one when sentry_dsn is set. The panic test fails
on next, where the panic leaves Get.

Model: opus-5-5
2026-10-03 15:53:34 +00:00
clawbot b36b1abbc8 Test that concurrent misses for one variant share one fetch (closes #65)
Requests that miss the same variant while its fetch is held must make
one fetch and one transcode between them, all get the same image and
each count one miss. Variants differing only in quality or fit stay
apart. A waiting request whose context ends returns at once; the first
request's client leaving does not stop the work. A shared failure
reaches every request, the negative cache answers the next one, and an
uncached failure is fetched again. A request that has already ended
fetches nothing, and a panic comes back as an error. All but the
variants test fail on next.

Model: opus-5-5
2026-10-03 15:50:55 +00:00