fix(grpc-data): #966 a modify's replacement no longer emits a live delta before its snapshot
The suspected ordering gap was real. A modify that replaces an item commits on the delivery side (the ack's commit): the replacement enters _items (it was already registered with the delivery scheduler at staging) and its snapshot job goes to _committedSnapshots, which only the NEXT tick moves to the pump. A tick already past that dequeue that then reads a source change (e.g. from a sibling item on the same source, whose interest group survives the modify) marks the source dirty. The scheduler hands it the replacement's handle, and ConsiderAsync sent the newer value as a live delta before SnapshotBegin. The snapshot that followed carried the older captured value. ConsiderAsync now defers an item whose interest group is not snapshot-complete. LastConsidered is left unchanged, and the group's own lease (its cursor starts at the snapshot capture) yields the change once SnapshotEnd commits. The same guard covers added and recovered items. Nothing starves: an undelivered SnapshotEnd stops the stream. Deterministic test (BeforeDirtyTickForTests hold + gated modify ack + publish under the hold): red 3/3 before (value:R:20 | begin | snapshot:R:10), green after, with a positive control that 20 is delivered after the end. Parallel in-process stress of the unhooked scenario (2 items on one source, modify one under continuous publish): 60/40000 violations before (10000 x widths 2/4/6/8), 0/40000 after.
This commit is contained in:
@@ -1031,7 +1031,16 @@ internal sealed partial class DataSubscriptionSession : IDataSubscriptionTranspo
|
||||
|
||||
private async Task ConsiderAsync(Item item)
|
||||
{
|
||||
lock (_gate) if (_challengedHandles.ContainsKey(item.Handle.Handle)) return;
|
||||
lock (_gate)
|
||||
{
|
||||
if (_challengedHandles.ContainsKey(item.Handle.Handle)) return;
|
||||
// #966: no live delta before the item's own snapshot. A modify's replacement (or an added/recovered item) is
|
||||
// scheduler-registered and in _items before its SnapshotEnd commits; a dirty mark for its source (from a
|
||||
// sibling group, or a commit landing mid-tick after the snapshot dequeue) would otherwise emit a newer live
|
||||
// value ahead of its SnapshotBegin. Nothing is lost: LastConsidered is untouched and the group's own lease
|
||||
// (cursor from the snapshot capture) yields the change once the group is snapshot-complete.
|
||||
if (item.Interest is { SnapshotComplete: false }) return;
|
||||
}
|
||||
if (item.Ticket is not { } ticket) return;
|
||||
using var read = _services.SubscriptionHub.Read(ticket);
|
||||
if (read.Readiness != DataReadiness.Ready || read.Sample is null) { CloseWithReset("Source became unavailable."); return; }
|
||||
|
||||
Reference in New Issue
Block a user