Skip to content

updateTaskNode(): same-field concurrent writes can still transiently clobber each other (self-correcting, low severity) #2097

Closed

Description

@mstomar125

Found during

Adversarial review of #2096 (fix for #2090: updateTaskNode()'s success-path field clobber via shared-reference mutation for a DIFFERENT field). Flagged as a non-blocking observation, explicitly not a regression from #2096 and outside #2090's verified scope — filing separately so it isn't lost.

The gap

#2096 fixed the case where write A (changing field X) and write B (changing field Y, a different field) race for the same task node: A's success response no longer clobbers B's still-in-flight optimistic value for field Y, because the fix limits each write's applied patch to only the fields that write's own request actually asked to change.

That fix does not close the analogous case where write A and write B both change the same field (e.g. both change status). If:

  1. Write A changes status and is executing (RPC in flight).
  2. Write B, for the same node, also changes status while A is still executing — collapses into PersistenceCoordinator's queued slot, applies its own optimistic status value immediately.
  3. Write A's RPC resolves. Its response's status field (A's own confirmed value, which does NOT reflect B's change — B hasn't been sent yet) gets applied via the (correctly, now field-scoped) Object.assign, since A's own request DID include status.
  4. The store transiently reverts to A's confirmed status, clobbering B's optimistic value, until B's own real write is later promoted and resolves — at which point B's own response re-applies the correct final value.

This is not a regression introduced by #2096 — the pre-fix code had the identical (in fact strictly worse — unscoped to any field) exposure for the same-field case. It's self-correcting: once B's own real persist attempt completes, the store converges to the correct final value. The only observable symptom is a transient flicker/revert in the UI between A's response landing and B's own response landing (typically well under a second, given PersistenceCoordinator serializes real RPCs per node so B is promoted immediately after A settles).

Suggested fix (if pursued)

Not urgent — evaluate whether the transient flicker is actually user-visible/bothersome enough to justify a fix before investing in one. If it is, options include: skip applying a field from a write's response if a newer optimistic value for that exact field has landed since this write's request was sent (would need to track per-field "last optimistic write token" alongside the node), or coalesce same-field writes at the call site before they ever reach PersistenceCoordinator.persist().

Scope note

Purely an observation from #2096's review — not verified with a dedicated repro/test. Confirm the flicker is actually perceptible/worth fixing before investing effort; this may be acceptable as-is given it self-corrects quickly and is pre-existing (not worse than before #2096).

Activity

  1. mstomar125 commented on Aug 17, 2026

    @mstomar125
    ContributorAuthor

    Resolved in #2099.

    Read the current updateTaskNode() implementation (post-#2072/#2088/#2090/#2092) and confirmed the same-field race described here is still live: field-scoping (from #2096) stops a write's response from clobbering a different field a concurrently-resolving write touched, but a write's own confirmed value for a field it DID change can still transiently overwrite a newer optimistic write for that SAME field — the response reflects server state as of this write's own request, which predates the newer same-field write.

    Went with the small, targeted fix rather than documenting-as-known-behavior: added a per-node, per-field write-sequence counter. updateTaskNode() bumps it for each field at optimistic-apply time and captures the number; when its RPC resolves, it only applies its confirmed value for a field if the sequence hasn't moved on since (no newer same-field write raced in). A newer write's own RPC still applies its own confirmed value when it resolves either way, so this only closes the transient wrong-value window — it doesn't change the self-correcting nature the issue described.

    Verified with a new regression test that reproduces the exact race and fails pre-fix (confirmed by temporarily reverting the source change and re-running — asserted the stale value instead of the expected one), plus a convergence check and a field-scoping-preserved check. Full suite (211 files / 4661 tests) and quality:fix both green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions