feat(resilience): #1047 non-retrying AcquisitionSubscribe capability wraps SubscribeAcquisitionAsync (breaker + /hosts telemetry), OTOPCUA0001 suppression removed
New DriverCapability.AcquisitionSubscribe (appended): RetryCount 0 in every tier and forced 0 by the parser, 30 s timeout (outlasts the actor's 10 s acquisition timeout), breaker 5 (Tier C none). PendingAcquisition.Start routes through the invoker keyed on the driver instance; an open breaker fails fast and the capacity reservation is released. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -47,4 +47,14 @@ public enum DriverCapability
|
||||
/// window, so a Read-sized threshold of 5 could never open on connect failures.
|
||||
/// </summary>
|
||||
Initialize,
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IAcknowledgedAcquisitionSource.SubscribeAcquisitionAsync"/> — establishing an acknowledged gRPC-data
|
||||
/// acquisition (lmxopcua#1047). Does NOT retry (the parser forces 0): a cancelled or superseded attempt can still
|
||||
/// complete with a physical handle the runtime's pending acquisition alone owns, so a pipeline retry would orphan it.
|
||||
/// The tier-default timeout (30 s) is deliberately longer than the runtime's own acquisition timeout (10 s by
|
||||
/// default), which stays the effective bound; the pipeline adds the breaker and the /hosts telemetry.
|
||||
/// Appended last so the existing members keep their numeric values.
|
||||
/// </summary>
|
||||
AcquisitionSubscribe,
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ public sealed record DriverResilienceOptions
|
||||
// timer fires every 10 s, so at most three init attempts fit one window; a threshold of 5
|
||||
// could never open on connect failures.
|
||||
[DriverCapability.Initialize] = new(TimeoutSeconds: 5, RetryCount: 0, BreakerFailureThreshold: 2),
|
||||
// #1047: never retries (a retry would orphan an acquisition handle); 30 s outlasts the runtime's 10 s acquisition timeout.
|
||||
[DriverCapability.AcquisitionSubscribe] = new(TimeoutSeconds: 30, RetryCount: 0, BreakerFailureThreshold: 5),
|
||||
},
|
||||
DriverTier.B => new Dictionary<DriverCapability, CapabilityPolicy>
|
||||
{
|
||||
@@ -98,6 +100,8 @@ public sealed record DriverResilienceOptions
|
||||
[DriverCapability.AlarmAcknowledge] = new(TimeoutSeconds: 8, RetryCount: 0, BreakerFailureThreshold: 5),
|
||||
// See the Tier A Initialize note: threshold 2 is cadence-reachability, not a tuning choice.
|
||||
[DriverCapability.Initialize] = new(TimeoutSeconds: 8, RetryCount: 0, BreakerFailureThreshold: 2),
|
||||
// #1047: never retries (a retry would orphan an acquisition handle); 30 s outlasts the runtime's 10 s acquisition timeout.
|
||||
[DriverCapability.AcquisitionSubscribe] = new(TimeoutSeconds: 30, RetryCount: 0, BreakerFailureThreshold: 5),
|
||||
},
|
||||
DriverTier.C => new Dictionary<DriverCapability, CapabilityPolicy>
|
||||
{
|
||||
@@ -110,6 +114,8 @@ public sealed record DriverResilienceOptions
|
||||
[DriverCapability.AlarmAcknowledge] = new(TimeoutSeconds: 15, RetryCount: 0, BreakerFailureThreshold: 0),
|
||||
// Tier C stays breaker-less like every other Tier C capability (process-level supervision).
|
||||
[DriverCapability.Initialize] = new(TimeoutSeconds: 15, RetryCount: 0, BreakerFailureThreshold: 0),
|
||||
// #1047: never retries (a retry would orphan an acquisition handle); 30 s outlasts the runtime's 10 s acquisition timeout.
|
||||
[DriverCapability.AcquisitionSubscribe] = new(TimeoutSeconds: 30, RetryCount: 0, BreakerFailureThreshold: 0),
|
||||
},
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(tier), tier, $"No default policy table defined for tier {tier}."),
|
||||
};
|
||||
|
||||
@@ -200,6 +200,15 @@ public static class DriverResilienceOptionsParser
|
||||
retry = 0;
|
||||
}
|
||||
|
||||
// #1047: an acquisition attempt that is cancelled or superseded can still complete with a physical handle that
|
||||
// only the runtime's pending acquisition may release; a pipeline retry would orphan it.
|
||||
if (capability == DriverCapability.AcquisitionSubscribe && retry > 0)
|
||||
{
|
||||
AppendDiagnostic(ref diagnostic,
|
||||
$"{capability} never retries (a retry would orphan an acquisition handle); retryCount override ignored.");
|
||||
retry = 0;
|
||||
}
|
||||
|
||||
var breaker = merged.BreakerFailureThreshold;
|
||||
if (breaker < ResiliencePolicyRanges.MinBreakerFailureThreshold)
|
||||
{
|
||||
|
||||
@@ -2246,19 +2246,19 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
_finished.TrySetResult(true);
|
||||
}
|
||||
|
||||
// OTOPCUA0001 (#1001/S-11) is suppressed here ON PURPOSE, not overlooked. The stock Subscribe
|
||||
// pipeline cannot wrap this call safely: it retries (3x on tiers A/B) and times out per attempt
|
||||
// (5-8 s, shorter than the actor's 10 s acquisition timeout), but a SubscribeAcquisitionAsync
|
||||
// attempt that is cancelled or superseded may still complete later with a physical handle, and
|
||||
// the contract makes THIS class (PendingAcquisition) the sole owner of releasing it. A Polly
|
||||
// retry/timeout would orphan those handles and desync the capacity reservation. Establishment
|
||||
// is already bounded by the actor's own acquisition timeout + the _stop token. Follow-up: give
|
||||
// the invoker a non-retrying acquisition capability so breaker/telemetry cover it too.
|
||||
// #1047 (#1001/S-11 follow-up): wrapped on its OWN capability, AcquisitionSubscribe, which never retries
|
||||
// (the parser forces 0) and whose 30 s tier timeout outlasts the actor's 10 s acquisition timeout. The stock
|
||||
// Subscribe pipeline could not wrap this: it retries, and a SubscribeAcquisitionAsync attempt that is cancelled
|
||||
// or superseded may still complete with a physical handle THIS class alone must release — a retry would orphan
|
||||
// it. With no retry the pipeline is transparent to that contract (Polly's timeout awaits the call and passes a
|
||||
// completed result through; only an OCE becomes TimeoutRejectedException, an ordinary failure here), and the
|
||||
// breaker + /hosts telemetry now cover acquisition. An open breaker fails fast without calling the source, which
|
||||
// ObserveAsync handles like any failure (reservation released). Keyed on the driver instance like a bulk Subscribe.
|
||||
internal void Start(IAcknowledgedAcquisitionSource source, AcquisitionSubscriptionRequest request,
|
||||
Action<AcquisitionBatch> callback) => _ = ObserveAsync(Task.Run(() =>
|
||||
#pragma warning disable OTOPCUA0001
|
||||
source.SubscribeAcquisitionAsync(request, callback, _stop.Token)));
|
||||
#pragma warning restore OTOPCUA0001
|
||||
Action<AcquisitionBatch> callback, IDriverCapabilityInvoker invoker, string hostKey) => _ = ObserveAsync(Task.Run(async () =>
|
||||
await invoker.ExecuteAsync(DriverCapability.AcquisitionSubscribe, hostKey,
|
||||
async ct => await source.SubscribeAcquisitionAsync(request, callback, ct).ConfigureAwait(false),
|
||||
_stop.Token).ConfigureAwait(false)));
|
||||
|
||||
private async Task ObserveAsync(Task<AcquisitionSubscriptionResult> operation)
|
||||
{
|
||||
@@ -2418,7 +2418,7 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
else _sourcePublisher.TryPublish(ticket, item.Snapshot);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, _invoker, _driverInstanceId);
|
||||
started = true;
|
||||
var installed = await operation.Completion.WaitAsync(cts.Token);
|
||||
if (installed.Handle is null || installed.DesiredRevision != fence.Revision ||
|
||||
|
||||
Reference in New Issue
Block a user