Rich write: invoker failing before the dispatch delegate on an externally-rejected claim leaks the late-write slot and target forever #967
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while reviewing #964 (read from code, not reproduced).
DriverInstanceActor.RunRichWriteAsync(src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Drivers/DriverInstanceActor.cs) hands the late-write reservation tophysical.Taskviareservation.Observe(...)BEFORE the invoker runs.physicalis completed only by the dispatch delegate, the driver observers, or the catch paths. In theTask.Runcatch (the invoker threw, e.g. an open circuit breaker / bulkhead rejection, without ever calling the delegate):If the claim was already completed undispatched by someone else (state 4 — e.g. an external pre-dispatch deadline, as
GrpcDataDriverOutcomeTestsline ~226 does),Complete(RichRejected)returns false, the branch picksRichUnknown, andphysicalis never completed. Nothing was ever sent to the driver, butLateWriteObserver.ObserveCoreawaitsphysical.Taskforever: the global outstanding slot and the(driver, reference)target stay reserved for the process lifetime, so every later rich write to that tag is rejected with "Outstanding driver write capacity exhausted" (and the ticket's byte lease is never released).The outer
WaitAsynctimeout catch has the same shape.Suggested fix: when the claim is not dispatched (
!msg.Claim.IsDispatched/IsCompletedUndispatched), completephysicalwith the claim's terminal outcome regardless of who completed it — the same rule the request-building catch already uses (if (!msg.Claim.IsDispatched) physical.TrySetResult(noCall)). Needs a red test: externally complete the claim as RejectedBeforeDispatch, make the invoker throw without calling the delegate, then assert a second write to the same target is not rejected.Fixed in
8d6b64393(merged8e0399530). Both RunRichWriteAsync catch paths go through FailRichAttempt: a claim that was never dispatched completes the physical task with its pre-dispatch outcome, which releases the slot, target and lease, and replies RejectedBeforeDispatch. Only a claim that was actually dispatched still waits for the driver and replies OutcomeUnknown. The regression test failed on both halves before the fix. DataConnections+DriverInstanceActor 1126/1126, Host GrpcData 210/210.