mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
chancloser: unregister channel before db modification
This fixes a race during channel closing, where the last channel state update was still not finished when we set the channel close bit in the database. This lead to a flake during integration tests, where the last state update would not finish, and the channel wasn't closes successfully. We fix it by first unregistering the channel, making sure it is removed fully from the link before doing the db modification.
This commit is contained in:
parent
1467cd4dd3
commit
03a0706593
@ -223,6 +223,10 @@ func (c *channelCloser) initChanShutdown() (*lnwire.Shutdown, error) {
|
||||
"close: %v", c.chanPoint, err)
|
||||
}
|
||||
|
||||
// Before returning the shutdown message, we'll unregister the channel
|
||||
// to ensure that it isn't seen as usable within the system.
|
||||
c.cfg.unregisterChannel(c.cid)
|
||||
|
||||
// Before continuing, mark the channel as cooperatively closed with a
|
||||
// nil txn. Even though we haven't negotiated the final txn, this
|
||||
// guarantees that our listchannels rpc will be externally consistent,
|
||||
@ -233,12 +237,6 @@ func (c *channelCloser) initChanShutdown() (*lnwire.Shutdown, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Before returning the shutdown message, we'll unregister the channel
|
||||
// to ensure that it isn't seen as usable within the system.
|
||||
//
|
||||
// TODO(roasbeef): fail if err?
|
||||
c.cfg.unregisterChannel(c.cid)
|
||||
|
||||
peerLog.Infof("ChannelPoint(%v): sending shutdown message", c.chanPoint)
|
||||
|
||||
return shutdown, nil
|
||||
|
Loading…
Reference in New Issue
Block a user