Skip to content

fix(cluster): do not store a reply for a request deleteProcessed removed - #10985

Merged
tim-smart merged 4 commits into
Effect-TS:mainfrom
freyzzzz:fix/sql-message-storage-orphan-replies
Nov 27, 2026
Merged

tim-smart merged 4 commits into
Effect-TS:mainfrom
freyzzzz:fix/sql-message-storage-orphan-replies

Conversation

@freyzzzz

@freyzzzz freyzzzz commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

saveReply updated the request row and inserted the reply without checking that the request still existed. A reply saved after deleteProcessed removed its request (for example, one that waited behind the delete) was stored with nothing referencing it, so retention never deleted it.

Fix

saveReply now locks the request row with lockRequest first, as saveEnvelope already does for AckChunk and Interrupt, and stores nothing when the row is gone. This keeps deleteProcessed's request-first lock order.

Test

The existing late-write test, now does not store late envelopes or replies for a request deleteProcessed removed, also saves a late chunk and exit reply and asserts repliesForUnfiltered returns none. It runs on pg, mysql, mssql and sqlite and fails on each without the fix.

The mssql test rejects duplicate exit replies when another table has the same index name now saves its request first, so it still checks the unique exit index.

Checked locally: pnpm check, oxlint, dprint, and SqlMessageStorage.integration.test.ts (121 passed). pnpm test-cluster has 8 Entity.test.ts / Locks.test.ts failures that also occur without this change.

Closes EFF-4558

saveReply updated the request row and inserted the reply without checking the request still existed. A reply saved after deleteProcessed removed its request was stored with nothing referencing it, and retention never deleted it. saveReply now locks the request first, like acknowledgements and interrupts already do, and stores nothing when it is gone.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9d4184d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 40.44 KB 40.44 KB 0.00 KB (0.00%)
basic.ts 7.50 KB 7.50 KB 0.00 KB (0.00%)
batching.ts 11.47 KB 11.47 KB 0.00 KB (0.00%)
brand.ts 7.21 KB 7.21 KB 0.00 KB (0.00%)
cache.ts 11.95 KB 11.95 KB 0.00 KB (0.00%)
config.ts 23.57 KB 23.57 KB 0.00 KB (0.00%)
differ.ts 22.72 KB 22.72 KB 0.00 KB (0.00%)
http-client.ts 28.03 KB 28.03 KB 0.00 KB (0.00%)
http-router.ts 38.92 KB 38.92 KB 0.00 KB (0.00%)
logger.ts 12.37 KB 12.37 KB 0.00 KB (0.00%)
metric.ts 9.85 KB 9.85 KB 0.00 KB (0.00%)
optic.ts 7.46 KB 7.46 KB 0.00 KB (0.00%)
pubsub.ts 16.40 KB 16.40 KB 0.00 KB (0.00%)
queue.ts 13.32 KB 13.32 KB 0.00 KB (0.00%)
schedule.ts 12.17 KB 12.17 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.59 KB 14.59 KB 0.00 KB (0.00%)
schema-binary.ts 43.34 KB 43.34 KB 0.00 KB (0.00%)
schema-class.ts 22.45 KB 22.45 KB 0.00 KB (0.00%)
schema-codegen.ts 33.88 KB 33.88 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 30.94 KB 30.94 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 28.67 KB 28.67 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.89 KB 15.89 KB 0.00 KB (0.00%)
schema-string.ts 12.87 KB 12.87 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.83 KB 16.83 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 40.00 KB 40.00 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 21.61 KB 21.61 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.78 KB 21.78 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.88 KB 21.88 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.91 KB 26.91 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.95 KB 21.95 KB 0.00 KB (0.00%)
schema.ts 21.59 KB 21.59 KB 0.00 KB (0.00%)
stm.ts 14.64 KB 14.64 KB 0.00 KB (0.00%)
stream.ts 10.79 KB 10.79 KB 0.00 KB (0.00%)

Merge the late reply case into the existing test for late acknowledgements
and interrupts, and check stored replies through repliesForUnfiltered.
@tim-smart
tim-smart merged commit 5896612 into Effect-TS:main Nov 27, 2026
15 of 16 checks passed

This branch is waiting to be deployed

1 waiting deployment
fork — 9d4184d9 Waiting Nov 27, 2026 by effect-bot via approval-gate #27750
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants