routing: fail in-flight attempts cleanly on terminal payment failure

In case of a multi shard payment with more than one in-flight shards,
one shard quitting with a terminal failure will stop the payment
lifecycle and close the `shardHandler`'s `quit` channel. In the
`collectResult` function we're waiting for the `Switch` to
asynchronously return a result for each shard. This may have been
interrupted by the aformentioned `quit` channel's closing skipping
attempt failure (or success) notification towards the control tower
and therefore skipping proper settle/fail info fill in the channel db.
Since payments have a composite state of a global failure reason and
settle/fail info for all attempts, any attempt with an unfilled
settle/fail info keeps a payment in-flight even if the payment itself
isn't in-flight anymore.
This commit is contained in:
Andras Banki-Horvath
2022-03-21 20:37:43 +01:00
parent 8047f2388e
commit 3d5f33a0cf
2 changed files with 32 additions and 18 deletions

View File

@ -597,9 +597,6 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
case <-p.router.quit:
return nil, ErrRouterShuttingDown
case <-p.quit:
return nil, errShardHandlerExiting
}
// In case of a payment failure, fail the attempt with the control