You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Instances that were not loaded: put() resets the version, and updates render derived attributes from them #84
Priority: medium (needs a decision for the version).
put() of an instance that was not loaded writes version 1 (repository.py, _prepare), also in batch puts and tx.put. That contradicts "+1 on every write" and lets a stale instance pass its version check again: a stale instance loaded at v1; another writer saves (v2); put(Player(...)) writes v1; stale.save() then succeeds over both writes. Deleting and creating the item again has the same A→B→A problem, so a fix needs a decision (read the stored version, or let put() keep counting).
Derived attributes of updates are rendered from the wrong base. An instance that was not loaded, used as an update target, skips the read and its own values are treated as stored: players.update(Player(player_id="p1", name="Ada"), Player.score.add(10)) with a stored score of 5 stores score 15 but rank SCORE#00000010. Updates by key read the item but add no condition that it is unchanged, so a concurrent write leaves the derived attribute behind, also for versioned models, where docs/guides/single-table-design.md calls it exact (reproduced: score 26 with rank SCORE#00000025).
Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.
The second part (derived attributes rendered from the wrong base) is handled in #142: updates through an instance that was not loaded read the item, and updates that render derived attributes from a stored item require the fields they took from it unchanged, planning the update again when another writer changed them (a transaction fails instead).
Left: the first part, the version put() of an instance that was not loaded writes. It needs a decision, which this session did not make: reading the stored version (a read per put, and still racy without a condition) or keeping the count in put() fixes the overwrite case, but not delete-and-create, which restarts at 1 whatever put() does; only a version that never repeats (a random token instead of a counter, a stored-format change) would close that.
Activity
fix(repository): updates render derived attributes from the stored it…
fctl-sh commentedon Oct 31, 2026
The second part (derived attributes rendered from the wrong base) is handled in #142: updates through an instance that was not loaded read the item, and updates that render derived attributes from a stored item require the fields they took from it unchanged, planning the update again when another writer changed them (a transaction fails instead).
Left: the first part, the version
put()of an instance that was not loaded writes. It needs a decision, which this session did not make: reading the stored version (a read per put, and still racy without a condition) or keeping the count input()fixes the overwrite case, but not delete-and-create, which restarts at 1 whateverput()does; only a version that never repeats (a random token instead of a counter, a stored-format change) would close that.fix(repository): updates render derived attributes from the stored it…
fix(versions)!: version() fields hold a random token, so a stale inst…
fix(versions)!: version() fields hold a random token, so a stale inst…