Skip to content

Molecule details: batches share four places and stop when the client goes - #629

Merged
adamjohnwright merged 3 commits into
mainfrom
fix/molecule-details-bound
Oct 23, 2026
Merged

adamjohnwright merged 3 commits into
mainfrom
fix/molecule-details-bound

Conversation

@adamjohnwright

@adamjohnwright adamjohnwright commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review finding (local stand-in for an ultra review over 4b4c9157..#624). Spec: specs/006-content-service-to-node (the interactor endpoints, ported).

The risk. POST /interactors/static/molecules/details runs one graph query per accession, one at a time, as Java asks. A real diagram's proteins take about a second (R-HSA-69620's 273: 1.2s on beta). But the body may be up to 10MB, hundreds of thousands of short accessions, with no cap and no stop when the client disconnects. One such request is about an hour of queries on the shared graph; a few in parallel are the load that has taken the graph down before. Java does the same, so this protects the service rather than changing what it answers.

The fix follows the xrefs batch (#571):

  • A share of its own: batches take one of four places, apart from the deep routes the site reads. A fifth is the 503 with Retry-After: 5, the service's busy answer.
  • Stopping: no lookup starts once the client has gone.
  • Unchanged: the checks before any query (415, the paging answers, 413, 422) and every answer. Accessions are still asked one at a time, in the HashSet's order.

Proof.

  • molecule-details-bound.spec.mjs uses a stand-in graph that holds queries open. Four batches run at once and a fifth is refused, then each batch gives its place back. A client that drops after the first lookup gets no second lookup. Both cases fail on main.
  • Beta, before and after: the R-HSA-69620 answer's hash is the same, and every POST capture is identical.
  • vitest run tools deploy passes (2,240 tests). Lint, types, totals and dead code are unchanged.

🤖 Generated with Claude Code


Follow-up from this PR's review. The production code had no findings: the place is always given back through finally, the close listener is on the response (a request's close would misfire), the 503 matches the service's other busy answers, and POST /molecules/summary is a single query, not this shape. The spec's check that a dropped batch gives its place back proved nothing: with a leak, three places remain and the next batch is still answered. Now four run and a fifth is refused after the drop. That fails with leave() skipped on abort, a mutation I checked, and still fails on main. The fixed 50 ms sleep is replaced by counting the server's open connections. Five runs in a row pass.

adamjohnwright and others added 3 commits October 23, 2026 02:35
…goes

POST /interactors/static/molecules/details runs one query per accession,
one at a time as Java asks. A diagram's proteins take a second (273 for
R-HSA-69620: 1.2s on beta), but a 10MB body holds hundreds of thousands,
with no cap and no stop when the client disconnects -- an hour of queries
on the shared graph for one request, as Java would run it too. As the xrefs
batch (#571): batches take a share of their own (four at once; a fifth is
the 503 with Retry-After), and no lookup starts once the client is gone.
The checks before any query (415, 413, 422) and every answer are as they
were.

A spec with a stand-in graph that holds queries open shows both; both fail
on main. On beta the R-HSA-69620 answer's hash and every POST capture are
the same before and after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From the review: after a dropped client, one more batch being answered
proved nothing -- a dropped batch that kept its place leaves three, and
the next is still answered. Now four run and a fifth is refused, which a
leaked place fails (checked by mutation: leave() skipped when aborted).
The server's open connections are counted, not slept on, to know the drop
has been seen; each request has a connection of its own for that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adamjohnwright
adamjohnwright merged commit e469b0a into main Oct 23, 2026
7 checks passed
@adamjohnwright
adamjohnwright deleted the fix/molecule-details-bound branch October 23, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant