fix: database connection auto-healing and controller fail-fast monitoring#448
Open
TrezorHannes wants to merge 1 commit into
Open
fix: database connection auto-healing and controller fail-fast monitoring#448TrezorHannes wants to merge 1 commit into
TrezorHannes wants to merge 1 commit into
Conversation
…ring - Implement Django connection auto-healing in background workers (jobs.py, rebalancer.py, p2p.py, htlc_stream.py) to prevent unrecoverable zombie loops on DB drop. - Implement process monitoring in controller.py to terminate the process group and exit if any worker process dies, allowing systemd restart.
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.
Hey @cryptosharks131
Here's the fix for the daemon zombie loop/controller hanging issues.
I've been running this patch locally, and it completely resolved all the random controller/daemon hangs I used to see. Before this, I had to manually restart the lndg controller systemd service every 2-3 weeks due to connections dropping/processes getting stuck. Since running this patch, it's been running perfectly with zero issues.
Summary of Changes:
controller.pyto monitor the main tasks (jobs,rebalancer,htlc_stream,p2p) in a loop. If any of these helper processes dies or crashes, the controller terminates the remaining processes and exits with status1. This allows standard systemd service managers to cleanly restart the entire group.connections.close_all()calls to exception blocks injobs.py,rebalancer.py,p2p.py, andhtlc_stream.py. When a database connection is dropped or gets stuck, Django will now automatically close the bad connections and reopen clean ones on the next retry loop, preventing the processes from getting stuck in an infinite database connection error loop.