C#: no store writer restamps a record; the directory store has one source of arrived entries

Deleted the heuristic that rewrote a record the cache held "unchanged since read" (same key and
storedAt) under the registered id, in the single-file commit and in the directory generation. It
could overwrite a record another writer changed while keeping its storedAt. A commit onto a file
now writes its batch and leaves every other record as the file holds it; a record under an id only
an arrived entry lists is refused, typed, with the file left as it was. Deleted the directory
store's _durableCatalog, a second stale-able source of arrived entries beside the manifest read
under the lease.

Tests: the lost-update probe, the two refusals that replace the restamp tests, the
arrived-overwrites-registered guard in both id orders, the content-hash tie-break against the
compatible-list order, and refusal determinism across record arrival order.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 11:04:12 +02:00
commit 9cee5e3f42
3 changed files with 92 additions and 51 deletions

View file

@ -3625,20 +3625,6 @@ namespace GameCult.Caching
records.Remove(entry.Key.Value);
foreach (var entry in request.Upserts)
records[entry.Key.Value] = ToPersistedRecord(entry, SerializePayload);
if (ontoDisk)
{
// A record this cache holds, unchanged since the file was read, is written under its registered schema's id, as a
// whole-view write writes it: the file's entry that lists an older id for it is then not needed to publish it.
foreach (var record in disk.Records)
{
if (records.TryGetValue(record.Key, out var carried) && ReferenceEquals(carried, record) &&
Entries.TryGetValue(record.Key, out var known) && known.StoredAt == record.StoredAt &&
!string.Equals(known.Descriptor.SchemaId, record.SchemaId, StringComparison.Ordinal))
{
records[record.Key] = ToPersistedRecord(known, SerializePayload);
}
}
}
// Onto the file, only the batch's records are seen: the rest stay as they are, and the header they carry stays. An
// unconditional commit writes this store's whole view, so what its records hold decides. A record this commit