From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [182.253.183.140]) by gnuweeb.org (Postfix) with ESMTPSA id 2419780BE8; Thu, 27 Oct 2022 15:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666883311; bh=8Q3MkcPOV8ERXBa3YhXQQWF2NDaBHmjPOkcsAiiw2y0=; h=From:To:Cc:Subject:Date:From; b=juJzxbeH+Q+wyLqZmqgovXn4R0ZX11xq9yQJ13JdPsaMs6hHD9H9RRjH+62iWyLPt sinB7A97kUG17FhygXYl/L00bx0ZAk1bHT8gFkiYBqGvx+e3qwi18GbhV4V2h49yMl PvuROowZjyuT62zCrWXt5f22qjQe1krr34YWo+XjL+nu5u3HeUeRKMBwEJ/9zAmWSb JDlBE2NqTxJxUAW1FLXhJXQ1QhfkZOOAxBgusVbdBvomjFHfU4uAcEceLBZtl7FvDg tNRnu9eJ/IP2PciKvVGjx3iOPaHjvSF4KtKGWxjkgepqbX6qwYQ0K6hgVjDBr5DYZu 8su8YuZDnhSdw== From: Ammar Faizi To: GNU/Weeb Mailing List Cc: Ammar Faizi , Muhammad Rizki , Alviro Iskandar Setiawan Subject: [PATCH v1 0/2] Automatic recovery from a MySQL restart Date: Thu, 27 Oct 2022 22:08:21 +0700 Message-Id: <20221027150823.601914-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. This way, the caller can automatically reconnect without having the user restart the daemon. 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. This series is just a hot fix, 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. Signed-off-by: Ammar Faizi --- Ammar Faizi (2): daemon: telegram: db: Allow the caller to reconnect daemon: telegram: Handle MySQL error daemon/telegram/database/core.py | 31 +++++++++++++++++++++++++----- daemon/telegram/mailer/listener.py | 29 ++++++++++++++++++++++++---- daemon/telegram/packages/client.py | 8 ++++---- daemon/tg.py | 4 ++-- 4 files changed, 57 insertions(+), 15 deletions(-) base-commit: 6e94cf607287e5bc209e9c14c8156c7ad49455e3 -- Ammar Faizi