fix(grpc-data): bound the unknown-mapping hold of imported conditions (#933)
A key no known mapping lists was kept stale for as long as ANY mapping of the connection was unknown; a durably Denied/Unavailable mapping therefore kept retired conditions forever. Scoping the hold to mappings that could list the key is not provable on the consumer (placements are origin deploy-time config; a dropped key may have moved into the unknown mapping's root), so the hold is time-boxed per key: ProjectedConditionOptions.MaxUnknownHold (20 min) — past it the key is removed (+ RefreshRequired at the sink), never known-inactive. The since-time survives stream ends and hand-overs; the earliest expiry shares the loop's retry timer. DataConnections.md: lifetime rule + troubleshooting row.
This commit is contained in:
+37
@@ -1097,6 +1097,43 @@ public sealed class GrpcDataProjectedConditionAccessTests
|
||||
await f.WaitAsync(() => f.Access.ChargedConditions == 0);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
// Follow-ups #933 / #934 (A4 review)
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public async Task Issue933_a_key_held_for_a_durably_denied_mapping_is_removed_past_MaxUnknownHold_not_kept_forever()
|
||||
{
|
||||
var hold = TimeSpan.FromSeconds(1.5);
|
||||
await using var f = new Fixture(Fixture.DefaultOptions with { LongRetryDelay = TimeSpan.FromMinutes(5), MaxUnknownHold = hold },
|
||||
("map-a", DataRealm.Raw, 10), ("map-b", DataRealm.Raw, 10));
|
||||
using var demand = f.Access.AcquireEventDemand(null);
|
||||
var stream = await f.NextStreamAsync();
|
||||
stream.Ack(DataItemStatus.Denied, "map-b"); // durable: retried only on the 5 min long timer
|
||||
stream.Begin("map-a", total: 1);
|
||||
stream.Records("map-a", Record(Key("x"), 3));
|
||||
stream.Complete("map-a");
|
||||
await f.WaitAsync(() => f.Sink.Live.Contains(Key("x")));
|
||||
|
||||
// map-a retires x; map-b is unknown, so x is held stale (T2) — the stale mark is the must-arrive control.
|
||||
stream.Records("map-a", Record(Key("x"), 4, removed: true));
|
||||
await f.WaitAsync(() => f.Sink.StaleKeys.Contains(Key("x")));
|
||||
var heldAt = DateTime.UtcNow;
|
||||
f.Sink.Removed.ShouldBeEmpty("within the bound an unknown mapping still holds the key");
|
||||
|
||||
// …and past the bound it is removed (+ RefreshRequired at the sink), on the open stream, with no frame to prompt it.
|
||||
await f.WaitAsync(() => f.Sink.Removed.Contains(Key("x")));
|
||||
(DateTime.UtcNow - heldAt).ShouldBeGreaterThan(hold - TimeSpan.FromMilliseconds(200), "not before MaxUnknownHold");
|
||||
f.Sink.Removed.Count(k => k == Key("x")).ShouldBe(1);
|
||||
f.Sink.Live.ShouldNotContain(Key("x"));
|
||||
f.Access.MappingStatuses(Connection)!["map-b"].ShouldBe(ProjectedConditionMappingStatus.Unavailable, "still unknown");
|
||||
(await f.TryNextStreamAsync(TimeSpan.FromMilliseconds(200))).ShouldBeNull("the stream is kept");
|
||||
|
||||
// A later listing re-creates it (the removal was a removal, not a verdict on the condition's state).
|
||||
stream.Records("map-a", Record(Key("x"), 5, message: "back"));
|
||||
await f.WaitAsync(() => f.Sink.Live.Contains(Key("x")));
|
||||
}
|
||||
|
||||
private sealed class Fixture : IAsyncDisposable
|
||||
{
|
||||
internal static readonly DataView DefaultRawPlacement =
|
||||
|
||||
Reference in New Issue
Block a user