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 mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by gnuweeb.org (Postfix) with ESMTPSA id 8F49981405 for ; Mon, 31 Oct 2022 16:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667233553; bh=AzItFffskwRji2Z6ShEHFJFgiWqu9Jg3jDqW9GCc3+E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=qvhuY9TI6/ftg0y3cmA/JNd5ZKN74Iy7DkdszVYE7nTTynZR0rf6QxPbz7Dr2b6qn UCW3XOwpd51Z8A4AMxH+r1hp9uTiwepDroj//WwELX5hdAINwX51t4FpP0wLtiNBSH bkyVxCFdAOuPQfc+ppWkzq7kllWLImfPBsSKI4sjvjQ+glyzmsxDSo7ZsDkcslkxjl riGYqjJBAHuBIO1SxlxcK4gi/gocoFnZZEsX/cEB/IwPH4uVBAaSa8AkslK9J/B6Kb FnGcIaThdDvsVQg9dQK8DL4Jfhbo2V5pgnoPTg/M882V5IyaRPr1bXrNIsn7Gj8vLV EJPq8S57tG0rw== Received: by mail-lj1-f172.google.com with SMTP id j14so17328781ljh.12 for ; Mon, 31 Oct 2022 09:25:53 -0700 (PDT) X-Gm-Message-State: ACrzQf3wFm69udCXE0cdE08etpoetXGEDli9Gdlcd7ojyDByFD1F5ty6 lxq+yFq8ZieA5xGArWbA+M27ZXSCpARC8pq5T/g= X-Google-Smtp-Source: AMsMyM5/Gk3URnDEYnkOAht8mKe1LaEDUdOWp4YN7WZyX+i0oL9sbtJHzFCCknotyX5n82eGbGi7iiLfE01xQ+dFUeo= X-Received: by 2002:a2e:a239:0:b0:277:1d99:ab0c with SMTP id i25-20020a2ea239000000b002771d99ab0cmr6098958ljm.111.1667233551724; Mon, 31 Oct 2022 09:25:51 -0700 (PDT) MIME-Version: 1.0 References: <20221031161256.199149-1-ammarfaizi2@gnuweeb.org> <20221031161256.199149-2-ammarfaizi2@gnuweeb.org> In-Reply-To: <20221031161256.199149-2-ammarfaizi2@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Mon, 31 Oct 2022 23:25:40 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RESEND v3 1/2] daemon: telegram: db: Allow the caller to reconnect To: Ammar Faizi Cc: "GNU/Weeb Mailing List" , Muhammad Rizki Content-Type: text/plain; charset="UTF-8" List-Id: On Mon, Oct 31, 2022 at 11:13 PM Ammar Faizi wrote: > 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. > > v2: > - Use conn.ping(reconnect=True) instead of creating a new MySQL > connection object (comment from Muhammad Rizki). > > Signed-off-by: Ammar Faizi Reviewed-by: Alviro Iskandar Setiawan