Fix (and test) threaded payment retries 2023-02-no-racey-retries
authorMatt Corallo <git@bluematt.me>
Fri, 3 Feb 2023 23:05:58 +0000 (23:05 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 16 Feb 2023 21:35:25 +0000 (21:35 +0000)
commitd98632973451c1e0c75d5d5c89fa6eca9d6cbaa1
tree0e925ce71416679342909c2cb85f1ca0aa85f2d5
parent1dc96cbde2bb24e8d92cc7a54947592ac495fedc
Fix (and test) threaded payment retries

The new in-`ChannelManager` retries logic does retries as two
separate steps, under two separate locks - first it calculates
the amount that needs to be retried, then it actually sends it.
Because the first step doesn't udpate the amount, a second thread
may come along and calculate the same amount and end up retrying
duplicatively.

Because we generally shouldn't ever be processing retries at the
same time, the fix is trivial - simply take a lock at the top of
the retry loop and hold it until we're done.
lightning/src/ln/channelmanager.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/outbound_payment.rs
lightning/src/ln/payment_tests.rs