fix(grpc-data): A3 r2 — a released marked EventFieldList never re-enters the SDK's process-wide pool

SDK 2.0.1 pools EventFieldList (PooledEncodeableType); SentMessageQueue Reuse()s every
list of an acknowledged message and the base ReuseCore returns it, whatever its runtime
type, to the shared stock pool. A recycled ProjectedEventFieldList was then rented by any
server's GetEventFields (an unrelated session's RefreshStart/RefreshEnd or local event)
still carrying an imported condition's marker, and ProjectedNotificationRewriter dropped it
when that marker's gate denied. Root cause of the intermittent OI ConditionRefresh failures
(#854/#855 classes). Mirrors ProjectedSdkNotification on the data path: override ReuseCore,
clear the marker, never return to the pool; a released (marker-less) list fails closed.
This commit is contained in:
Joseph Doherty
2026-11-24 21:36:47 -05:00
parent 159ce9d13d
commit 6be0b8dc4b
3 changed files with 54 additions and 2 deletions
@@ -116,6 +116,39 @@ public sealed class ImportedConditionClassifierTests : IAsyncDisposable
ReferenceEquals(ProjectedNotificationRewriter.Project(plain, republish: false, null), plain).ShouldBeTrue();
}
/// <summary>
/// A3 review round 2 (root cause of the intermittent OI ConditionRefresh failures): SDK 2.0.1 pools EventFieldList
/// process-wide, and <c>SentMessageQueue</c> calls <c>Reuse()</c> on every list of an acknowledged message. A marked
/// list that went back to the stock pool was rented by an unrelated server/session's <c>GetEventFields</c> (its
/// RefreshStart/RefreshEnd), carrying a revoked marker, and the rewriter dropped it. A released marked list must never
/// be rentable, and must not keep its marker (closure over condition + identity) alive.
/// </summary>
[Fact]
public void A_released_marked_event_list_never_returns_to_the_SDK_pool_so_no_other_session_rents_its_marker()
{
var marked = new ProjectedEventFieldList(new ProjectedEventMarker(null, new NodeId("c", 9), 1, () => false)) { ClientHandle = 77 };
((IPooledEncodeable)marked).Reuse(); // exactly what SentMessageQueue.ReuseNotificationPayloads does on ACK / eviction
marked.Marker.ShouldBeNull("a released list holds no authority (and keeps no closure alive)");
// Drain more than the pool can hold: had the marked instance been returned, it would come out here.
var rented = new List<EventFieldList>();
try
{
for (var i = 0; i < PooledEncodeableType<EventFieldList>.DefaultMaximumRetained + 64; i++)
rented.Add((EventFieldList)EventFieldListActivator.Instance.CreateInstance());
rented.ShouldNotContain(l => l is ProjectedEventFieldList, "a stock list rented for any event is never a marked one");
}
finally
{
foreach (var l in rented) ((IPooledEncodeable)l).Reuse();
}
// A released marked list that somehow reached the rewriter fails closed (never judged by a stale marker).
var message = new NotificationMessage { SequenceNumber = 10,
NotificationData = [new ExtensionObject(new EventNotificationList { Events = [marked] })] };
ProjectedNotificationRewriter.Project(message, republish: false, null).NotificationData.Count.ShouldBe(0);
}
[Fact]
public void S2_a_cached_positive_verdict_is_re_proved_past_the_credential_expiry_and_past_the_positive_TTL()
{