fix(grpc-data): A3 verification r2 — N1 runner predecessor chain dropped after hand-over + stopped runner clears its record sets; correct the SentMessageQueue clone comment and pin the EventFieldList MemberwiseClone dependency
This commit is contained in:
+28
@@ -149,6 +149,34 @@ public sealed class ImportedConditionClassifierTests : IAsyncDisposable
|
||||
ProjectedNotificationRewriter.Project(message, republish: false, null).NotificationData.Count.ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verification review r2: the rewriter never sees the queued instance — SDK 2.0.1 <c>SentMessageQueue</c> hands Publish
|
||||
/// and Republish a <c>CoreUtils.Clone</c> of the stored message. The gate holds only because
|
||||
/// <see cref="EventFieldList.Clone"/> is <c>MemberwiseClone</c>, which keeps the subclass, the marker and the handle. Pins
|
||||
/// that dependency: an SDK that cloned through the activator (a stock list) would turn this red.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Cloning_a_marked_event_list_the_way_the_SDK_does_keeps_the_subclass_and_the_marker()
|
||||
{
|
||||
var marker = new ProjectedEventMarker(null, new NodeId("c", 9), 1, () => false);
|
||||
var marked = new ProjectedEventFieldList(marker) { ClientHandle = 42 };
|
||||
|
||||
var direct = marked.Clone().ShouldBeOfType<ProjectedEventFieldList>();
|
||||
direct.Marker.ShouldBeSameAs(marker);
|
||||
direct.ClientHandle.ShouldBe(42u);
|
||||
|
||||
var message = new NotificationMessage { SequenceNumber = 11,
|
||||
NotificationData = [new ExtensionObject(new EventNotificationList { Events = [marked] })] };
|
||||
var delivered = CoreUtils.Clone(message)!; // exactly what SentMessageQueue returns for Publish / Republish
|
||||
delivered.NotificationData[0].TryGetValue<EventNotificationList>(out var list).ShouldBeTrue();
|
||||
var events = list!.Events;
|
||||
var cloned = events[0].ShouldBeOfType<ProjectedEventFieldList>();
|
||||
cloned.ShouldNotBeSameAs(marked, "the SDK delivers a copy, not the queued instance");
|
||||
cloned.Marker.ShouldBeSameAs(marker);
|
||||
ProjectedNotificationRewriter.Project(delivered, republish: false, null).NotificationData.Count
|
||||
.ShouldBe(0, "the copy is still judged by its marker (and dropped when the re-check fails)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void S2_a_cached_positive_verdict_is_re_proved_past_the_credential_expiry_and_past_the_positive_TTL()
|
||||
{
|
||||
|
||||
+29
@@ -461,6 +461,35 @@ public sealed class GrpcDataProjectedConditionAccessTests
|
||||
f.Sink.Live.ShouldBe([Key("y")], "x was handed over (not orphaned) and the new complete set removed it");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task N1_demand_cycles_and_mapping_changes_do_not_chain_runners_so_an_old_runner_is_collectable()
|
||||
{
|
||||
// Verification review r2 N1: each runner kept its predecessor (and that one's record sets), so every linger expiry
|
||||
// + re-subscribe or mapping change added a link R3 → R2 → R1 and memory grew without bound.
|
||||
await using var f = new Fixture(("map-a", DataRealm.Raw, 10));
|
||||
var demand = f.Access.AcquireEventDemand(null)!;
|
||||
await CompleteFirstAsync(f, ("map-a", [Record(Key("x"), 3)]));
|
||||
var first = f.Access.RunnerReference(Connection)!;
|
||||
var version = 3L;
|
||||
for (var cycle = 0; cycle < 3; cycle++)
|
||||
{
|
||||
demand.Dispose();
|
||||
await f.WaitAsync(() => !f.Access.IsRunning(Connection)); // linger expired
|
||||
demand = f.Access.AcquireEventDemand(null)!;
|
||||
await CompleteFirstAsync(f, ("map-a", [Record(Key("x"), ++version)]));
|
||||
}
|
||||
for (var change = 0; change < 2; change++)
|
||||
{
|
||||
f.Mappings.Current[0].Mapping.MaxConditions++; // a changed signature ⇒ a new runner, a new stream
|
||||
f.Mappings.Raise();
|
||||
await CompleteFirstAsync(f, ("map-a", [Record(Key("x"), ++version)]));
|
||||
}
|
||||
f.Sink.Live.ShouldBe([Key("x")], "the hand-over still works across every cycle");
|
||||
for (var i = 0; i < 3; i++) { GC.Collect(); GC.WaitForPendingFinalizers(); }
|
||||
first.IsAlive.ShouldBeFalse("the current runner must not keep a chain of predecessors reachable");
|
||||
demand.Dispose();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
internal static string Key(string seed) =>
|
||||
|
||||
Reference in New Issue
Block a user