Removing a foreign record is judged against the store as it is, not the last load
A removal of a key the cache does not hold writes nothing, so it never reached the apply; it was checked against the foreign list of the last load, and a foreign record that arrived since was reported removed. Each store now reads its durable state for such a removal (RefuseRemovalOfUndeclared) and refuses through the apply's own RefuseUndeclaredOnDisk, which reloads and lists the record. The load-time check (RefuseRemovalOfForeign) is deleted: the durable read refuses everything it refused, and it could not save that read. A store kind that cannot read its durable state keeps the view check as its default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b636a69f9d
commit
43a63b0792
3 changed files with 57 additions and 16 deletions
|
|
@ -1024,14 +1024,28 @@ namespace GameCult.Caching.Tests
|
|||
}
|
||||
|
||||
// A removal of a foreign record, which the cache does not hold, is refused typed: the caller is never told it removed what the
|
||||
// store still carries.
|
||||
// store still carries. The store is read as it is at the removal, so a foreign record another writer added after the load
|
||||
// is refused too, and listed foreign from then on.
|
||||
[Test]
|
||||
public void RemovingAForeignRecordIsRefusedNotReportedAsDone([Values] bool directory, [Values] bool batch)
|
||||
public void RemovingAForeignRecordIsRefusedNotReportedAsDone([Values] bool directory, [Values] bool batch, [Values] bool appearedAfterLoad)
|
||||
{
|
||||
var path = Seeded(directory ? "remove-foreign-dir.cc" : "remove-foreign-file.cc", directory);
|
||||
var before = Fingerprint(path);
|
||||
var path = PathOf(directory ? "remove-foreign-dir.cc" : "remove-foreign-file.cc");
|
||||
using (var seed = Open(path, Full, directory))
|
||||
{
|
||||
seed.Commit(stage => stage.Upsert(Deck, DeckOf("d"), D));
|
||||
if (!appearedAfterLoad)
|
||||
seed.Commit(stage => stage.Upsert(Widget, WidgetOf("w"), W));
|
||||
}
|
||||
|
||||
using (var cache = Open(path, DeckOnly, directory))
|
||||
{
|
||||
if (appearedAfterLoad)
|
||||
{
|
||||
using var other = Open(path, Full, directory);
|
||||
other.Commit(stage => stage.Upsert(Widget, WidgetOf("w"), W));
|
||||
}
|
||||
|
||||
var before = Fingerprint(path);
|
||||
var refusal = Assert.Throws<CultSchemaConflictException>(() =>
|
||||
{
|
||||
if (batch)
|
||||
|
|
@ -1041,10 +1055,10 @@ namespace GameCult.Caching.Tests
|
|||
})!;
|
||||
Assert.That((refusal.RecordKey, refusal.SchemaId), Is.EqualTo((W.Value, WidgetId)));
|
||||
Assert.That(cache.IsDirty, Is.False);
|
||||
Assert.That(StoreOf(cache).ForeignRecords.Select(record => record.Key), Is.EqualTo(new[] { "w" }));
|
||||
Assert.That(cache.Remove(new CultRecordKey("absent")), Is.False, "a key nothing holds is still no removal");
|
||||
Assert.That(Fingerprint(path), Is.EqualTo(before));
|
||||
}
|
||||
|
||||
Assert.That(Fingerprint(path), Is.EqualTo(before));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue