Merge #920/#929: a demand disposed mid-publish no longer republishes a fresh baseline (retained proof-candidate leak); SDK async delivery race in test; memory figures re-measured with GC memory info (~79 KB/condition node tree)
v2-ci / unit-tests (push) Waiting to run
v2-ci / unit-tests (push) Waiting to run
This commit is contained in:
@@ -93,7 +93,7 @@ public sealed record ProjectedConditionOptions(TimeSpan Linger, int MaxImportedC
|
||||
/// <summary>
|
||||
/// Retained managed bytes per imported condition, measured by the A3 L2 harness (1,000 conditions in one mapping on a
|
||||
/// running SDK 2.0.1 server: node + children + ids + registry/indexes + EventId registry + verdict cache; X0's
|
||||
/// node-only harness measured 160,997). A3b review S5: the WORST case — two placements, every EventId slot, three
|
||||
/// node-only harness retains 79,085 B on the same method, #929 — its original 160,997 was a <c>GC.GetTotalMemory</c> delta). A3b review S5: the WORST case — two placements, every EventId slot, three
|
||||
/// event items, the runner's Live + Buffer records. A3 review round 2: measured with the retained heap
|
||||
/// (<c>GCMemoryInfo</c>, not <c>GC.GetTotalMemory</c>, which counted ~125 MiB of committed-but-free regions) and the
|
||||
/// settled working set, 8 EventId slots (§5.6): max of three runs = 158,629 B (working set; heap 111,715 B), rounded up.
|
||||
|
||||
@@ -19,6 +19,8 @@ public sealed class ProjectedDataAccess : IProjectedDataAccess, IDisposable
|
||||
public TimeProvider Clock { get; }
|
||||
internal Func<TimeSpan, TimeSpan>? RetryJitterForTests { get; set; }
|
||||
internal Action? BeforeSuccessorAdoptionForTests { get; set; }
|
||||
/// <summary>#920: runs on the stream pump after a publish passed its demand check, before the duplicate-baseline check.</summary>
|
||||
internal Action<IProjectedDemandLease>? AfterPublishDemandCheckForTests { get; set; }
|
||||
private readonly IFederatedProjectionCatalog _catalog;
|
||||
private readonly IProjectedNodeLookup _nodes;
|
||||
private readonly Func<string, string?> _connectionForMapping;
|
||||
@@ -685,7 +687,11 @@ public sealed class ProjectedDataAccess : IProjectedDataAccess, IDisposable
|
||||
internal bool HasFreshCachedLocked(Demand demand)
|
||||
{
|
||||
var sample = _cachedSample;
|
||||
if (sample is null || _cachedVersion != LastVersion || !sample.SourceProof.IsValid || !demand.IsValid || !IsValid) return false;
|
||||
// #920: deliberately NOT gated on demand.IsValid. This answers "is the sample already published for this version
|
||||
// still fresh at this demand's age limit" — the duplicate-baseline suppression in Publish. A demand disposed
|
||||
// concurrently (a failed SDK item construction) used to turn the answer into "not fresh", so a dying
|
||||
// registration re-published the same acquisition as a new complete baseline to every item on the node.
|
||||
if (sample is null || _cachedVersion != LastVersion || !sample.SourceProof.IsValid || !IsValid) return false;
|
||||
try
|
||||
{
|
||||
return sample.OriginAgeBounds.Advance(_owner.Clock.GetElapsedTime(sample.ReceivedTimestamp,
|
||||
@@ -1775,6 +1781,7 @@ public sealed class ProjectedDataAccess : IProjectedDataAccess, IDisposable
|
||||
{
|
||||
validated = false;
|
||||
if (registration.Removed || !registration.Demand.IsValid || update.SourceProof is not AttemptProof proof) { ProjectedStreamDiagnostics.Count(ProjectedStreamDiagnostics.Event.PublishDemand); return false; }
|
||||
_owner.AfterPublishDemandCheckForTests?.Invoke(registration.Demand);
|
||||
var source = proof.Source;
|
||||
if (!source.TryPrepareSuccessor(registration.Demand, out var successor)) return false;
|
||||
try
|
||||
@@ -1792,6 +1799,8 @@ public sealed class ProjectedDataAccess : IProjectedDataAccess, IDisposable
|
||||
validated = update.IsCompleteSnapshot;
|
||||
if (version == source.LastVersion && update.IsCompleteSnapshot && !registration.Recovery &&
|
||||
source.HasFreshCachedLocked(registration.Demand)) return false;
|
||||
// A demand disposed since the check above publishes nothing (it is no longer anyone's subscription).
|
||||
if (!registration.Demand.IsValid) { validated = false; ProjectedStreamDiagnostics.Count(ProjectedStreamDiagnostics.Event.PublishDemand); return false; }
|
||||
if (_owner._publisher.TryPublish([update]))
|
||||
{
|
||||
if (successor is not null)
|
||||
|
||||
Reference in New Issue
Block a user