fix(grpc-data): #967 a rich write whose invoker fails before dispatch on an externally-rejected claim releases its slot
When the invoker threw without running the dispatch delegate (open breaker / bulkhead) after the claim had already been completed RejectedBeforeDispatch by someone else, Complete(RichRejected) returned false, the path answered OutcomeUnknown and never completed the physical task. The late-write slot, the (driver, reference) target and the ticket's byte lease stayed reserved for the process lifetime, so every later write to that tag was refused as 'Outstanding driver write capacity exhausted'. Both catch paths now go through FailRichAttempt: an undispatched terminal claim can never dispatch (dispatch is a CAS from pending), so the physical task completes with the claim's pre-dispatch outcome and the caller hears RejectedBeforeDispatch. Only a dispatched claim stays Unknown and is left to the driver's own completion.
This commit is contained in:
@@ -1519,10 +1519,7 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
}
|
||||
catch
|
||||
{
|
||||
var outcome = msg.Claim.Complete(RichRejected) ? RichRejected : RichUnknown;
|
||||
if (outcome == RichRejected) physical.TrySetResult(outcome);
|
||||
else msg.Claim.Complete(outcome);
|
||||
return outcome;
|
||||
return FailRichAttempt(msg.Claim, physical);
|
||||
}
|
||||
});
|
||||
try
|
||||
@@ -1534,9 +1531,7 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
}
|
||||
catch
|
||||
{
|
||||
outcome = msg.Claim.Complete(RichRejected) ? RichRejected : RichUnknown;
|
||||
if (outcome == RichRejected) physical.TrySetResult(outcome);
|
||||
else msg.Claim.Complete(outcome);
|
||||
outcome = FailRichAttempt(msg.Claim, physical);
|
||||
}
|
||||
// #964: when the physical write has finished, its late-write slot must be back BEFORE the caller
|
||||
// hears the outcome or the actor frees the tag — both let a next write to the same target reach
|
||||
@@ -1551,6 +1546,29 @@ public sealed class DriverInstanceActor : ReceiveActor, IWithTimers
|
||||
finally { self.Tell(new WriteCompleted(msg.Ticket.Proof.DriverReference, incarnation)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Settles a rich write whose invoker attempt failed or was abandoned. A claim that never dispatched can never
|
||||
/// dispatch any more once terminal (dispatch is a CAS from pending), so no driver call exists or can start:
|
||||
/// the physical task is completed with the claim's pre-dispatch outcome, releasing the late-write slot,
|
||||
/// target and ticket. That holds whether THIS path rejected the claim or someone else (an external
|
||||
/// pre-dispatch deadline) already had — #967: the latter used to leave the physical task pending forever,
|
||||
/// reserving the slot and target for the process lifetime. Only a DISPATCHED claim is left to the driver's
|
||||
/// own completion (it may still be running) and answered Unknown.
|
||||
/// </summary>
|
||||
private static DataWriteOutcome FailRichAttempt(WriteClaim claim, TaskCompletionSource<DataWriteOutcome> physical)
|
||||
{
|
||||
if (claim.Complete(RichRejected) || !claim.IsDispatched)
|
||||
{
|
||||
// CurrentOutcome is null only while another completer is mid-publish; any pre-dispatch completion is a
|
||||
// RejectedBeforeDispatch, so RichRejected is the same state.
|
||||
var outcome = claim.CurrentOutcome ?? RichRejected;
|
||||
physical.TrySetResult(outcome);
|
||||
return outcome;
|
||||
}
|
||||
claim.Complete(RichUnknown);
|
||||
return RichUnknown;
|
||||
}
|
||||
|
||||
private static async Task ObserveRichDriver(Task<IReadOnlyList<DataWriteOutcome>> task,
|
||||
TaskCompletionSource<DataWriteOutcome> physical)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user