From: Ammar Faizi <[email protected]>
To: GNU/Weeb Mailing List <[email protected]>
Cc: Ammar Faizi <[email protected]>,
Muhammad Rizki <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH v2 0/2] Automatic recovery from a MySQL restart
Date: Sun, 30 Oct 2022 12:49:28 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
Hi,
This series adds a mechanism for the daemon to recover from a MySQL
restart event. Currently, the daemon is totally unusable when the MySQL
server is restarted. It's spinning in a loop with the following error:
mysql.connector.errors.OperationalError: 2013 (HY000): Lost connection to MySQL server during query
When it happens, the only way to fix the situation is: restart the
daemon manually, which is obviously not productive. Create a mechanism
in the class DB to allow the caller to reconnect.
Handle MySQL error in the main daemon loop path. Do reconnect to the
database if such an error happens. This way, the daemon can
automatically recover from the MySQL server restart without having the
user restart the daemon.
There are two patches in this series:
- Patch 1 is a preparation patch to create a recover mechanism.
- Patch 2 is to implement the recover mechanism in the main daemon
loop path.
## Changelog
v1 -> v2:
- Use conn.ping(reconnect=True) instead of creating a new MySQL
connection object (comment from Muhammad Rizki).
Signed-off-by: Ammar Faizi <[email protected]>
---
Ammar Faizi (2):
daemon: telegram: db: Allow the caller to reconnect
daemon: telegram: Handle MySQL error
daemon/telegram/database/core.py | 5 +++++
daemon/telegram/mailer/listener.py | 31 ++++++++++++++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
base-commit: 6e94cf607287e5bc209e9c14c8156c7ad49455e3
--
Ammar Faizi
next reply other threads:[~2022-10-30 5:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-30 5:49 Ammar Faizi [this message]
2022-10-30 5:49 ` [PATCH v2 1/2] daemon: telegram: db: Allow the caller to reconnect Ammar Faizi
2022-10-30 5:49 ` [PATCH v2 2/2] daemon: telegram: Handle MySQL error Ammar Faizi
2022-10-30 9:49 ` Muhammad Rizki
2022-10-30 12:45 ` Ammar Faizi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox