Skip to content

Commit f48e509

Browse files
authored
Merge pull request #9643 from yyforyongyu/fix-startup
lnd: make sure startup flow is not aborted
2 parents 0a2b33a + 1e0ddf3 commit f48e509

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

docs/release-notes/release-notes-0.19.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@
107107
keysend payment would not fail properly and only resolve after restart. Now
108108
keysend payment validation is stricter.
109109

110+
* [Make sure](https://github.com/lightningnetwork/lnd/pull/9643) the startup
111+
process of the node won't be interrupted if a non-fatal error is returned from
112+
the subsystems.
113+
110114
# New Features
111115

112116
* Add support for [archiving channel backup](https://github.com/lightningnetwork/lnd/pull/9232)

server.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,7 @@ func (c cleaner) add(cleanup func() error) cleaner {
21952195
func (c cleaner) run() {
21962196
for i := len(c) - 1; i >= 0; i-- {
21972197
if err := c[i](); err != nil {
2198-
srvrLog.Infof("Cleanup failed: %v", err)
2198+
srvrLog.Errorf("Cleanup failed: %v", err)
21992199
}
22002200
}
22012201
}
@@ -2498,7 +2498,11 @@ func (s *server) Start() error {
24982498
// brontide.NewListener() is called in newServer. This means
24992499
// that we are actually listening and partially accepting
25002500
// inbound connections even before the connMgr starts.
2501+
//
2502+
// TODO(yy): move the log into the connMgr's `Start` method.
2503+
srvrLog.Info("connMgr starting...")
25012504
s.connMgr.Start()
2505+
srvrLog.Debug("connMgr started")
25022506

25032507
// If peers are specified as a config option, we'll add those
25042508
// peers first.
@@ -2540,6 +2544,9 @@ func (s *server) Start() error {
25402544
// Subscribe to NodeAnnouncements that advertise new addresses
25412545
// our persistent peers.
25422546
if err := s.updatePersistentPeerAddrs(); err != nil {
2547+
srvrLog.Errorf("Failed to update persistent peer "+
2548+
"addr: %v", err)
2549+
25432550
startErr = err
25442551
return
25452552
}
@@ -2551,12 +2558,15 @@ func (s *server) Start() error {
25512558
// to ensure we don't reconnect to any nodes we no longer have
25522559
// open channels with.
25532560
if err := s.chanStateDB.PruneLinkNodes(); err != nil {
2561+
srvrLog.Errorf("Failed to prune link nodes: %v", err)
2562+
25542563
startErr = err
25552564
return
25562565
}
2566+
25572567
if err := s.establishPersistentConnections(); err != nil {
2558-
startErr = err
2559-
return
2568+
srvrLog.Errorf("Failed to establish persistent "+
2569+
"connections: %v", err)
25602570
}
25612571

25622572
// setSeedList is a helper function that turns multiple DNS seed
@@ -3535,8 +3545,9 @@ func (s *server) establishPersistentConnections() error {
35353545
// the reconnection port to the default peer port.
35363546
linkNodes, err := s.chanStateDB.LinkNodeDB().FetchAllLinkNodes()
35373547
if err != nil && err != channeldb.ErrLinkNodesNotFound {
3538-
return err
3548+
return fmt.Errorf("failed to fetch all link nodes: %w", err)
35393549
}
3550+
35403551
for _, node := range linkNodes {
35413552
pubStr := string(node.IdentityPub.SerializeCompressed())
35423553
nodeAddrs := &nodeAddresses{
@@ -3551,7 +3562,7 @@ func (s *server) establishPersistentConnections() error {
35513562
// that have been added via NodeAnnouncement messages.
35523563
sourceNode, err := s.graphDB.SourceNode()
35533564
if err != nil {
3554-
return err
3565+
return fmt.Errorf("failed to fetch source node: %w", err)
35553566
}
35563567

35573568
// TODO(roasbeef): instead iterate over link nodes and query graph for
@@ -3637,8 +3648,15 @@ func (s *server) establishPersistentConnections() error {
36373648
nodeAddrsMap[pubStr] = n
36383649
return nil
36393650
})
3640-
if err != nil && !errors.Is(err, graphdb.ErrGraphNoEdgesFound) {
3641-
return err
3651+
if err != nil {
3652+
srvrLog.Errorf("Failed to iterate channels for node %x",
3653+
sourceNode.PubKeyBytes)
3654+
3655+
if !errors.Is(err, graphdb.ErrGraphNoEdgesFound) &&
3656+
!errors.Is(err, graphdb.ErrEdgeNotFound) {
3657+
3658+
return err
3659+
}
36423660
}
36433661

36443662
srvrLog.Debugf("Establishing %v persistent connections on start",

0 commit comments

Comments
 (0)