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:
@@ -461,11 +461,30 @@ internal sealed record ProjectedEventMarker(object? Identity, NodeId ConditionId
|
||||
/// <c>ProjectedNotificationRewriter</c> sees this instance on every Publish and Republish and drops it when the re-check
|
||||
/// fails.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// A3 review round 2 (root cause of the OI refresh failures): SDK 2.0.1 POOLS <see cref="EventFieldList"/> process-wide
|
||||
/// (<c>EventFieldListActivator : PooledEncodeableType</c>). <c>SentMessageQueue</c> calls <c>Reuse()</c> on every list of an
|
||||
/// acknowledged/evicted message, and the base <c>ReuseCore</c> returns the instance — whatever its runtime type — to the
|
||||
/// shared stock pool, from which ANY server's <c>MonitoredItem.GetEventFields</c> rents its next list. A recycled
|
||||
/// instance of this subclass therefore became some unrelated session's RefreshStart/RefreshEnd or local condition event,
|
||||
/// still carrying THIS marker: the rewriter judged it by another condition's (possibly revoked) gate and dropped it.
|
||||
/// Like <c>ProjectedSdkNotification</c> on the data path, this subclass stays out of the stock pool.
|
||||
/// </remarks>
|
||||
internal sealed class ProjectedEventFieldList(ProjectedEventMarker marker) : EventFieldList
|
||||
{
|
||||
internal static long s_unservable, s_droppedOnPublish, s_droppedUnmarked, s_keptUnmarked;
|
||||
|
||||
public ProjectedEventMarker Marker { get; } = marker;
|
||||
/// <summary>The captured authority; null once the SDK has released the list (it is never published again).</summary>
|
||||
public ProjectedEventMarker? Marker { get; private set; } = marker;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void ReuseCore()
|
||||
{
|
||||
// ACK, eviction and message disposal reach this through IPooledEncodeable.Reuse: reset, drop the marker (and with it
|
||||
// the closure over the condition and identity), and let the GC have it — never the shared EventFieldList pool.
|
||||
Marker = null;
|
||||
ResetForReuse();
|
||||
}
|
||||
|
||||
/// <summary>Imported events an item could not receive through the marked path (fail closed).</summary>
|
||||
internal static long Unservable => Interlocked.Read(ref s_unservable);
|
||||
|
||||
@@ -938,7 +938,7 @@ internal static class ProjectedNotificationRewriter
|
||||
{
|
||||
if (list is ProjectedEventFieldList marked)
|
||||
{
|
||||
if (marked.Marker.Permits()) kept.Add(list);
|
||||
if (marked.Marker?.Permits() == true) kept.Add(list); // a released list (no marker) fails closed
|
||||
else Interlocked.Increment(ref ProjectedEventFieldList.s_droppedOnPublish);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user