Errors with a second database attached (MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))")

739 views
Skip to first unread message

Christian Varas

unread,
May 24, 2022, 12:49:45 PM5/24/22
to py4web
Hi, I have an app with 2 databases connected (mysql), the problem is, when the application is not used in some hours or days, the functions that show the second database (using a grid) run in connection error against the mysql server (pymysql.err.OperationalError: (2006, "MySQL server has gone away (ConnectionResetError(104, 'Connection reset by peer'))"). 
The rest of the functions that use the main database work properly. The issue is only for the second db and it happened after hours of no use.
Trying to spot the issue on google, I found a similar error when using sqlalchemy, and the fix is setting an option to "true", i now is totally different but maybe there is a pydal option that i need to set.
Ex:  
SQLALCHEMY_ENGINE_OPTIONS = {
        "pool_pre_ping": True,
        "pool_recycle": 300,
    }



This is my settings:

DB_URI = "mysql://easyxxxt:xxxx@localhost/db_one"
DB_POOL_SIZE = 1
DB_MIGRATE = True
DB_FAKE_MIGRATE = False  # maybe?

DB_URI2 = "mysql://easyxxxt:xxxx@localhost/db_two"
DB_POOL_SIZE2 = 1
DB_MIGRATE2 = True
DB_FAKE_MIGRATE2 = False  # maybe?


Cheers.
Chris.

Jim Steil

unread,
May 26, 2022, 5:07:51 PM5/26/22
to py4web
I run my main app with 3 db connections.  MySQL, SQLServer and IBM i (AS/400) DB2.

MySQL is the 'primary' database but I have never had a problem with either of the other 2 databases not being available.

I also have another app that has 2 different MySQL database.  The primary db has all the auth parts and the main data lives in the second db.  I've never had issues with either one not being available.

Any more info you can share?

I'm assuming you're connecting both db's in common.py.  Does that seem right?

-Jim

Christian Varas

unread,
May 29, 2022, 12:51:10 PM5/29/22
to Jim Steil, py4web
Thanks Jim, I already had this implementation before and never see a problem, maybe is something related to my mysql server.

I will try to dig more.


Cheers.
Chris.

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/d476d8df-c8c8-4595-a68f-e005c578b00an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages