lnd.xprv/discovery
Matheus Degiovani 44f83731bc discovery: Correctly lock premature annoucements
This reworks the locking behavior of the Gossiper so that a race
condition on channel updates and block notifications doesn't cause any
loss of messages.

This fixes an issue that manifested mostly as flakes on itests during
WaitForNetworkChannelOpen calls.

The previous behavior allowed ChannelUpdates to be missed if they
happened concurrently to block notifications. The
processNetworkAnnoucement call would check for the current block height,
then lock the gossiper and add the msg to the prematureAnnoucements
list. New blocks would trigger an update to the current block height
then a lock and check of the aforementioned list.

However, specially during itests it could happen that the missing lock
before checking the height could case a race condition if the following
sequence of events happened:

- A new ChannelUpdate message was received and started processing on a
  separate goroutine
- The isPremature() call was made and verified that the ChannelUpdate
  was in fact premature
- The goroutine was scheduled out
- A new block started processing in the gossiper. It updated the block
  height, asked and was granted the lock for the gossiper and verified
  there was zero premature announcements. The lock was released.
- The goroutine processing the ChannelUpdate asked for the gossiper lock
  and was granted it. It added the ChannelUpdate in the
  prematureAnnoucements list. This can never be processed now.

The way to fix this behavior is to ensure that both isPremature checks
done inside processNetworkAnnoucement and best block updates are made
inside the same critical section (i.e. while holding the same lock) so
that they can't both check and update the prematureAnnoucements list
concurrently.
2020-06-05 15:58:33 -03:00
..
bootstrapper.go discovery: error string lint fixes 2019-09-25 18:42:38 +00:00
chan_series.go discovery/chan_series: use netann.ChannelUpdateFromEdge helper 2020-03-17 16:24:25 -07:00
gossiper_test.go Ensure chain notifier is started before accessed. 2020-04-30 12:54:33 +03:00
gossiper.go discovery: Correctly lock premature annoucements 2020-06-05 15:58:33 -03:00
log.go multi: init subsystem loggers via build pkg 2018-10-05 13:04:45 +09:00
message_store_test.go discovery: covert to use new kvdb abstraction 2020-03-18 19:35:07 -07:00
message_store.go multi: rename ReadTx to RTx 2020-05-26 18:20:37 -07:00
mock_test.go multi: remove returned error from WipeChannel 2020-04-02 17:39:29 -07:00
reliable_sender_test.go multi: move WaitPredicate, WaitNoError, WaitInvariant to lntest/wait 2019-09-19 12:46:29 -07:00
reliable_sender.go discovery,fundingmanager: avoid serialization in NotifyWhenOnline 2019-06-04 16:36:21 -03:00
sync_manager_test.go discovery: interpret block range from ReplyChannelRange messages 2020-01-06 14:03:13 -08:00
sync_manager.go multi: remove dead code 2019-09-10 17:21:59 +02:00
syncer_test.go discovery: check ChainHash in QueryChannelRange messages 2020-01-17 11:51:09 -08:00
syncer.go discovery: check ChainHash in QueryChannelRange messages 2020-01-17 11:51:09 -08:00