-
Notifications
You must be signed in to change notification settings - Fork 2
fix: ensure node state persisted before shutdown #743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fix/node-stopping-bg-payments
Are you sure you want to change the base?
Changes from all commits
562f44f
27123f1
20e246a
964a9f0
240d16c
1dd4f51
46724e1
36fe6d5
d90e8c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -277,6 +277,14 @@ class LightningRepo @Inject constructor( | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| val result = lifecycleMutex.withLock { | ||||||||||||||||||||||||
| initialLifecycleState = _lightningState.value.nodeLifecycleState | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Recovery: if stuck at Stopping (e.g., previous shutdown interrupted), reset to Stopped | ||||||||||||||||||||||||
| if (initialLifecycleState == NodeLifecycleState.Stopping) { | ||||||||||||||||||||||||
| Logger.warn("Found stuck Stopping state, resetting to Stopped", context = TAG) | ||||||||||||||||||||||||
| _lightningState.update { it.copy(nodeLifecycleState = NodeLifecycleState.Stopped) } | ||||||||||||||||||||||||
| initialLifecycleState = NodeLifecycleState.Stopped | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (initialLifecycleState.isRunningOrStarting()) { | ||||||||||||||||||||||||
| Logger.info("LDK node start skipped, lifecycle state: $initialLifecycleState", context = TAG) | ||||||||||||||||||||||||
| return@withLock Result.success(Unit) | ||||||||||||||||||||||||
|
|
@@ -396,6 +404,12 @@ class LightningRepo @Inject constructor( | |||||||||||||||||||||||
| lightningService.stop() | ||||||||||||||||||||||||
| _lightningState.update { LightningState(nodeLifecycleState = NodeLifecycleState.Stopped) } | ||||||||||||||||||||||||
| }.onFailure { | ||||||||||||||||||||||||
| // On cancellation (e.g., timeout), ensure state is recoverable | ||||||||||||||||||||||||
| if (it is CancellationException) { | ||||||||||||||||||||||||
| Logger.warn("Node stop cancelled, forcing Stopped state for recovery", context = TAG) | ||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Setting state to When a timeout-induced Consequences:
Possible solutions:
|
||||||||||||||||||||||||
| _lightningState.update { LightningState(nodeLifecycleState = NodeLifecycleState.Stopped) } | ||||||||||||||||||||||||
| return@withLock Result.failure(it) | ||||||||||||||||||||||||
|
Comment on lines
+407
to
+411
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue: Catching This code catches The same file demonstrates the correct pattern in multiple places:
Impact: While this happens to work for the primary
If any of these call sites' coroutines are cancelled while Suggested fix: Rethrow the
Suggested change
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| Logger.error("Node stop error", it, context = TAG) | ||||||||||||||||||||||||
| // On failure, check actual node state and update accordingly | ||||||||||||||||||||||||
| // If node is still running, revert to Running state to allow retry | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.