From 120d6dd297fb1f27a6ee7dd21e6f5960d4940245 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 19 Sep 2023 18:14:12 -0700 Subject: [PATCH] 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. --- channeldb/graph.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/channeldb/graph.go b/channeldb/graph.go index 2c000f3e7..99ccdaf0b 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -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",