channeldb: explicitly catch error in pruneGraphNodes

With the new postgres concurrency control, an error may come from a
bucket function that's actually a postgres error. In this case, we need
to return early so we can retry the txn. Otherwise, we'll be working
with an aborted tx, and never actually return the error so we don't auto
retry.
This commit is contained in:
Olaoluwa Osuntokun 2023-09-19 18:14:12 -07:00 committed by Andras Banki-Horvath
parent 329fcc6498
commit 120d6dd297
No known key found for this signature in database
GPG key ID: 80E5375C094198D8

View file

@ -1508,9 +1508,15 @@ func (c *ChannelGraph) pruneGraphNodes(nodes kvdb.RwBucket,
// If we reach this point, then there are no longer any edges
// that connect this node, so we can delete it.
if err := c.deleteLightningNode(nodes, nodePubKey[:]); err != nil {
log.Warnf("Unable to prune node %x from the "+
"graph: %v", nodePubKey, err)
continue
if errors.Is(err, ErrGraphNodeNotFound) ||
errors.Is(err, ErrGraphNodesNotFound) {
log.Warnf("Unable to prune node %x from the "+
"graph: %v", nodePubKey, err)
continue
}
return err
}
log.Infof("Pruned unconnected node %x from channel graph",