Skip to content

A first source fill raced by a write resolves the caller with its own @createdTime while the row keeps the raced one #3567

Open

Description

@kriszyp

Summary

A first source fill (getFromSource, no stored entry when it started) that replaces a record which landed while the source call was in flight keeps that record's @createdTime in the stored row and its index, as a put would. The fill stamps @createdTime before it resolves the caller, though, so the caller's record and the @embed/@decide hooks carry the fill's own created time, not the stored one.

Why it is not fixed yet

  • The caller is resolved before the commit runs, and the commit is the first point that sees the raced record. Re-reading the entry under the fill lock narrows the window but cannot close it: the fill lock does not exclude puts.
  • Re-running the model hooks when the commit finds a different created time would need a retry loop around a synchronous commit callback, for a guarantee no write path gives today (_writeUpdate runs its hooks before the commit stamps timestamps).

Documented as a known limit in resources/DESIGN.md ("getFromSource() timing"). Pinned behavior for the stored row: unitTests/resources/caching.test.js "first source fill replaces an older raced record".

A related, smaller case: when the fill's commit is skipped (it lost the version race) or fails, the caller's record still carries the candidate @updatedTime/@createdTime stamps, which were never stored. The resolved entry's version already matched that candidate before this change.

Review-Deferral: b7a300556741c229 severity=minor category=correctness
Review-Deferral: 01ef86b77acfdd62 severity=nit category=correctness
Review-Deferral: 80a2a5b70a1eecf4 severity=nit category=correctness

🤖 Generated by Claude Opus 5.5 (Claude Code dev agent); posted via @kriszyp.

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

    No labels
    No labels

    Type

    Fields

    Priority

    P3

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions