Skip to content

Fence ClusterWorkflowEngine activity resets against stale runners - #10226

Merged
tim-smart merged 2 commits into
mainfrom
agent/bob/49e5a15be126
Oct 31, 2026
Merged

tim-smart merged 2 commits into
mainfrom
agent/bob/49e5a15be126

Conversation

@tim-smart

Copy link
Copy Markdown
Contributor

Closes EFF-3225

Follow-up to #10001, for one gap that came up while looking at #10058.

resetActivityAttempt called sharding.reset(requestId) with no expectedReplyId, so storage ran an unconditional delete of the activity's WithExit reply. Here is how a runner that has lost its shard can use that to delete the new owner's result:

  1. Stale runner A and new owner B both replay and read the same stored Suspended activity reply.
  2. A gets frozen just before its reset.
  3. B resets, runs the activity and stores Success, then continues with that value.
  4. A wakes up, and its reset deletes B's reply and marks the request unprocessed.
  5. The activity runs again, and the next replay reads a result the owner never used.

Change

  • resetActivityAttempt reads the stored reply. It resets only when that reply is Suspended, and passes the reply's id as expectedReplyId, the same way resume already does. If a newer reply is there, storage skips the delete and the activity loop's next client.activity call returns the stored reply. The code doesn't look at reset's return value, because both memory and SQL storage return success when the compare fails.
  • sendResumeParent now passes the id of the reply it just read too. The worst case there was an extra wake, so this one is mostly for consistency.

There are no storage, schema or RunnerStorage changes. This is not the epoch fence proposed in #10058, and this PR leaves that issue open.

Test

keeps a newer activity reply when a stale Suspended reply resets the attempt in ClusterWorkflowEngine.test.ts uses memory storage. It holds the replay's reset at clearReplies, resets the same attempt as the owner, and waits for Complete(1). Then it releases the stale reset. On main the workflow ends with 2 because the activity ran twice. With this change it ends with 1 and the owner's reply stays in storage.

pnpm test --run packages/effect/test/cluster/ (285 tests), pnpm lint-fix and pnpm check all pass locally.

@changeset-bot

changeset-bot Bot commented Oct 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: edbfcfe

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

This PR includes changesets to release 33 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest 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/platform-browser Patch
@effect/platform-bun 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

@effect-janitor effect-janitor Bot added the 4.0 label Oct 31, 2026
@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 39.41 KB 39.41 KB 0.00 KB (0.00%)
basic.ts 7.23 KB 7.23 KB 0.00 KB (0.00%)
batching.ts 11.08 KB 11.08 KB 0.00 KB (0.00%)
brand.ts 6.87 KB 6.87 KB 0.00 KB (0.00%)
cache.ts 11.54 KB 11.54 KB 0.00 KB (0.00%)
config.ts 22.84 KB 22.84 KB 0.00 KB (0.00%)
differ.ts 22.00 KB 22.00 KB 0.00 KB (0.00%)
http-client.ts 26.95 KB 26.95 KB 0.00 KB (0.00%)
http-router.ts 37.02 KB 37.02 KB 0.00 KB (0.00%)
logger.ts 12.01 KB 12.01 KB 0.00 KB (0.00%)
metric.ts 9.47 KB 9.47 KB 0.00 KB (0.00%)
optic.ts 7.10 KB 7.10 KB 0.00 KB (0.00%)
pubsub.ts 16.03 KB 16.03 KB 0.00 KB (0.00%)
queue.ts 12.82 KB 12.82 KB 0.00 KB (0.00%)
schedule.ts 11.80 KB 11.80 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 14.14 KB 14.14 KB 0.00 KB (0.00%)
schema-binary.ts 41.26 KB 41.26 KB 0.00 KB (0.00%)
schema-class.ts 21.73 KB 21.73 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 29.60 KB 29.60 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.99 KB 27.99 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.35 KB 15.35 KB 0.00 KB (0.00%)
schema-string.ts 12.34 KB 12.34 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.27 KB 16.27 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.95 KB 38.95 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 26.15 KB 26.15 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.90 KB 20.90 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 21.05 KB 21.05 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.14 KB 21.14 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 26.17 KB 26.17 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.23 KB 21.23 KB 0.00 KB (0.00%)
schema.ts 20.82 KB 20.82 KB 0.00 KB (0.00%)
stm.ts 14.20 KB 14.20 KB 0.00 KB (0.00%)
stream.ts 10.38 KB 10.38 KB 0.00 KB (0.00%)

@tim-smart
tim-smart merged commit d190d97 into main Oct 31, 2026
17 checks passed
@tim-smart
tim-smart deleted the agent/bob/49e5a15be126 branch October 31, 2026 09:42
@effect-bot effect-bot mentioned this pull request Oct 31, 2026
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.

1 participant