Merge pull request #4801 from halseth/router-lifecycle-logs

[logging] add more logging for failed payment shards
This commit is contained in:
Johan T. Halseth 2020-11-24 20:49:08 +01:00 committed by GitHub
commit ef503bf14e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -128,6 +128,8 @@ func (store *networkResultStore) storeResult(paymentID uint64,
store.paymentIDMtx.Lock(paymentID)
defer store.paymentIDMtx.Unlock(paymentID)
log.Debugf("Storing result for paymentID=%v", paymentID)
// Serialize the payment result.
var b bytes.Buffer
if err := serializeNetworkResult(&b, result); err != nil {
@ -175,6 +177,8 @@ func (store *networkResultStore) subscribeResult(paymentID uint64) (
store.paymentIDMtx.Lock(paymentID)
defer store.paymentIDMtx.Unlock(paymentID)
log.Debugf("Subscribing to result for paymentID=%v", paymentID)
var (
result *networkResult
resultChan = make(chan *networkResult, 1)

View File

@ -420,6 +420,9 @@ func (s *Switch) GetPaymentResult(paymentID uint64, paymentHash lntypes.Hash,
return
}
log.Debugf("Received network result %T for paymentID=%v", n.msg,
paymentID)
// Extract the result and pass it to the result channel.
result, err := s.extractResult(
deobfuscator, n, paymentID, paymentHash,

View File

@ -14,6 +14,9 @@ import (
"github.com/lightningnetwork/lnd/routing/route"
)
// errShardHandlerExiting is returned from the shardHandler when it exits.
var errShardHandlerExiting = fmt.Errorf("shard handler exiting")
// paymentLifecycle holds all information about the current state of a payment
// needed to resume if from any point.
type paymentLifecycle struct {
@ -104,7 +107,7 @@ func (p *paymentLifecycle) resumePayment() ([32]byte, *route.Route, error) {
for _, a := range payment.InFlightHTLCs() {
a := a
log.Debugf("Resuming payment shard %v for hash %v",
log.Infof("Resuming payment shard %v for hash %v",
a.AttemptID, p.paymentHash)
shardHandler.collectResultAsync(&a.HTLCAttemptInfo)
@ -308,7 +311,7 @@ func (p *shardHandler) waitForShard() error {
return err
case <-p.quit:
return fmt.Errorf("shard handler quitting")
return errShardHandlerExiting
case <-p.router.quit:
return ErrRouterShuttingDown
@ -326,7 +329,7 @@ func (p *shardHandler) checkShards() error {
}
case <-p.quit:
return fmt.Errorf("shard handler quitting")
return errShardHandlerExiting
case <-p.router.quit:
return ErrRouterShuttingDown
@ -421,7 +424,8 @@ func (p *shardHandler) collectResultAsync(attempt *channeldb.HTLCAttemptInfo) {
result, err := p.collectResult(attempt)
if err != nil {
if err != ErrRouterShuttingDown &&
err != htlcswitch.ErrSwitchExiting {
err != htlcswitch.ErrSwitchExiting &&
err != errShardHandlerExiting {
log.Errorf("Error collecting result for "+
"shard %v for payment %v: %v",
@ -531,7 +535,7 @@ func (p *shardHandler) collectResult(attempt *channeldb.HTLCAttemptInfo) (
return nil, ErrRouterShuttingDown
case <-p.quit:
return nil, fmt.Errorf("shard handler exiting")
return nil, errShardHandlerExiting
}
// In case of a payment failure, fail the attempt with the control
@ -683,7 +687,7 @@ func (p *shardHandler) handleSendError(attempt *channeldb.HTLCAttemptInfo,
return nil
}
log.Debugf("Payment %v failed: final_outcome=%v, raw_err=%v",
log.Infof("Payment %v failed: final_outcome=%v, raw_err=%v",
p.paymentHash, *reason, sendErr)
err := p.router.cfg.Control.Fail(p.paymentHash, *reason)

View File

@ -2006,8 +2006,8 @@ func (r *ChannelRouter) tryApplyChannelUpdate(rt *route.Route,
// processSendError analyzes the error for the payment attempt received from the
// switch and updates mission control and/or channel policies. Depending on the
// error type, this error is either the final outcome of the payment or we need
// to continue with an alternative route. This is indicated by the boolean
// return value.
// to continue with an alternative route. A final outcome is indicated by a
// non-nil return value.
func (r *ChannelRouter) processSendError(paymentID uint64, rt *route.Route,
sendErr error) *channeldb.FailureReason {