Merge #967: an invoker failing before dispatch on an externally-rejected claim releases the late-write slot/target and answers RejectedBeforeDispatch
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