Here is the error. It happens exactly after (>=) 5 mins have elapsed since my last db statement executed. If I execute anything before that, say 4 min 30 sec, it runs fine.
2020-12-09 05:50:21,818: Exception on /api/registration/verify [POST]
Traceback (most recent call last):
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1205, in _execute_context
context = constructor(dialect, self, conn, *args)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 806, in _init_compiled
self.cursor = self.create_cursor()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 1162, in create_cursor
return self._dbapi_connection.cursor()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 1000, in cursor
return self.connection.cursor(*args, **kwargs)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 541, in cursor
raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.
**NO MATCH**
The above exception was the direct cause of the following exception:
**NO MATCH**
Traceback (most recent call last):
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask_restplus/api.py", line 313, in wrapper
resp = resource(*args, **kwargs)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask/views.py", line 89, in view
return self.dispatch_request(*args, **kwargs)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
resp = meth(*args, **kwargs)
File "/home/sbsatter/lenden-api/app/main/controller/registration_controller.py", line 106, in post
return verify_email(request.json)
File "/home/sbsatter/lenden-api/app/main/service/registration_service.py", line 196, in verify_email
user_reg = get_user_registration(public_id)
File "/home/sbsatter/lenden-api/app/main/service/user_service.py", line 45, in get_user_registration
return UserRegistration.query.filter_by(public_id=public_id).first_or_404()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 430, in first_or_404
rv = self.first()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3397, in first
ret = list(self[0:1])
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3171, in __getitem__
return list(res)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3503, in __iter__
return self._execute_and_instances(context)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3528, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1014, in execute
return meth(self, multiparams, params)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1127, in _execute_clauseelement
ret = self._execute_context(
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1207, in _execute_context
self._handle_dbapi_exception(
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
util.raise_(
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1205, in _execute_context
context = constructor(dialect, self, conn, *args)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 806, in _init_compiled
self.cursor = self.create_cursor()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 1162, in create_cursor
return self._dbapi_connection.cursor()
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 1000, in cursor
return self.connection.cursor(*args, **kwargs)
File "/home/sbsatter/lenden-api/venv/lib/python3.8/site-packages/mysql/connector/connection_cext.py", line 541, in cursor
raise errors.OperationalError("MySQL Connection not available.")
sqlalchemy.exc.OperationalError: (mysql.connector.errors.OperationalError) MySQL Connection not available.