Fix rebalance/monitor races: probe kill, oscillation, double-pay#521
Draft
markettes wants to merge 8 commits into
Draft
Fix rebalance/monitor races: probe kill, oscillation, double-pay#521markettes wants to merge 8 commits into
markettes wants to merge 8 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three related races between RebalanceService.ExecuteAsync, queued RebalanceJob retries, and MonitorRebalancesJob.
expected state during the probe. The monitor was flipping such rows to Failed, killing in-progress probes. Fixed by only flipping Failed on null when Status == InFlight;
Pending/Probing are left to local execution. Stale rows past the reconciliation window are still reaped.
hash and writing the prior failure back on top — producing NoRoute → Pending → NoRoute → Probing → … plus a spurious RebalanceCompleted/Failure audit event between every two attempts.
Fixed by returning without writing when the row is Pending/Probing regardless of LND's response; the retry path owns those states.
despite a local Failed. The retry would call AddInvoice (new hash) and send again, paying fees twice. Each retry creates a fresh invoice, so Lightning's own invoice-uniqueness rule
doesn't catch it. Fixed with a pre-flight TrackPaymentV2 at the top of ExecuteAsync: on Succeeded, adopt the outcome and return without sending.