0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00

fix(mcp): number a task's attempts across instances

A run recovered after its instance died was traced as attempt #1 and not
marked recovered: core's reclaim of a lapsed lease puts the row back to
pending without touching retryCount, so retryCount + input rounds can't
tell a recovered run from a first one. The background store now keeps an
explicit attempt count in the row's envelope, bumped (fenced on the
claim) when each attempt starts, including the adopted in-request one.

New libsql test kills a traced server mid-task with SIGKILL and checks
the fresh instance's attempt is #2, recovered, under the root, and that
the trace is listed. It fails with the old formula and without the flush
of the root span.

Co-Authored-By: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
This commit is contained in:
Daniel Lew 2026-10-27 18:19:48 -04:00
commit 9b75753bea
4 changed files with 68 additions and 16 deletions