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:
@@ -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