Repository navigation
Conversation
Layer names passed to getroutes are checked when the command arrives, but they are only looked up again in apply_layers() once a child is free (up to askrene-max-threads at once). If the layer was removed in between, find_layer() returns NULL and we hit the assert that the only remaining possibility is auto.sourcefree, killing the plugin and lightningd with it. This is easy to hit with the common pattern of creating a temporary layer, calling getroutes, and removing the layer when the call returns or times out on the client side: while askrene is busy, the request is still queued when the cleanup runs. Fail that request with an error instead. Changelog-Fixed: askrene: `getroutes` no longer crashes lightningd if one of its layers is removed while the request is waiting to run. Signed-off-by: Adam Soltys <asoltys@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
getrouteschecks its layer names when the command arrives, butapply_layers()only looks them up again once a child is free. If a layer is removed in between,find_layer()returns NULL and we fall through to:The plugin is not restartable mid-call, so lightningd exits with it.
We hit this in production about 16 times in 3 hours during heavy xpay load. A fee-quoting path creates a temporary layer, calls
getroutes, and removes the layer in afinallywhen the call returns or the client-side RPC timeout fires. With allaskrene-max-threadschildren busy, the request was still in the waiters queue when the cleanup removed its layer, and the next dequeue took the node down.This makes
apply_layers()report the missing layer, sodo_getroutes()fails just that request withJSONRPC2_INVALID_PARAMS("Layer X was removed before routing began"). The early return happens beforegossmap_apply_localmods(), and the partially built localmods and layers are allocated offcmd, so there's nothing to unwind.The new test
test_layer_removed_while_waitingsetsaskrene-max-threadsto 0 so the request is guaranteed to queue, removes the layer, then sets it back to 1 and runs another request to wake the queue. Without the fix it reproduces the assert above; with it, it passes. The fulltests/test_askrene.pypasses locally (38 tests).Checklist
tools/lightning-downgrade(no persistent changes)🤖 Generated with Claude Code