AUSTransaction raising an exception when trying to handle some exceptions
Opened this issue · 0 comments
For example:
OperationalError: (1053, 'Server shutdown in progress')
File "sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "MySQLdb/connections.py", line 226, in query
_mysql.connection.query(self, query)
OperationalError: (MySQLdb._exceptions.OperationalError) (1053, 'Server shutdown in progress')
[SQL: SELECT releases.name, releases.product, releases.data_version
FROM releases
WHERE releases.name = %s
LIMIT %s]
[parameters: ('Firefox-60.9.0esr-build1', 1)]
(Background on this error at: http://sqlalche.me/e/e3q8)
File "auslib/db.py", line 230, in execute
return self.conn.execute(statement)
File "sqlalchemy/engine/base.py", line 988, in execute
return meth(self, multiparams, params)
File "sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
distilled_params,
File "sqlalchemy/engine/base.py", line 1248, in _execute_context
e, statement, parameters, cursor, context
File "sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "sqlalchemy/util/compat.py", line 398, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "sqlalchemy/util/compat.py", line 152, in reraise
raise value.with_traceback(tb)
File "sqlalchemy/engine/base.py", line 1244, in _execute_context
cursor, statement, parameters, context
File "sqlalchemy/engine/default.py", line 552, in do_execute
cursor.execute(statement, parameters)
File "MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "MySQLdb/connections.py", line 226, in query
_mysql.connection.query(self, query)
OperationalError: (2006, 'MySQL server has gone away')
File "sqlalchemy/engine/base.py", line 739, in _rollback_impl
self.engine.dialect.do_rollback(self.connection)
File "sqlalchemy/dialects/mysql/base.py", line 2251, in do_rollback
dbapi_connection.rollback()
OperationalError: (MySQLdb._exceptions.OperationalError) (2006, 'MySQL server has gone away')
(Background on this error at: http://sqlalche.me/e/e3q8)
File "auslib/web/public/client.py", line 132, in wrapper
return f(*args, transaction=transaction, **kwargs)
File "auslib/web/public/client.py", line 151, in get_update_blob
release, update_type = AUS.evaluateRules(query, transaction=transaction)
File "auslib/AUS.py", line 120, in evaluateRules
release = dbo.releases.getReleases(name=rule["mapping"], limit=1, transaction=transaction)[0]
File "auslib/db.py", line 1835, in getReleases
rows = self.select(columns=[self.name, self.product, self.data_version], where=where, limit=limit, transaction=transaction)
File "auslib/db.py", line 391, in select
result = transaction.execute(query).fetchall()
File "auslib/db.py", line 237, in execute
self.rollback()
File "auslib/db.py", line 248, in rollback
self.trans.rollback()
File "sqlalchemy/engine/base.py", line 1705, in rollback
self._do_rollback()
File "sqlalchemy/engine/base.py", line 1743, in _do_rollback
self.connection._rollback_impl()
File "sqlalchemy/engine/base.py", line 741, in _rollback_impl
self._handle_dbapi_exception(e, None, None, None, None)
File "sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
util.raise_from_cause(sqlalchemy_exception, exc_info)
File "sqlalchemy/util/compat.py", line 398, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "sqlalchemy/util/compat.py", line 152, in reraise
raise value.with_traceback(tb)
File "sqlalchemy/engine/base.py", line 739, in _rollback_impl
self.engine.dialect.do_rollback(self.connection)
File "sqlalchemy/dialects/mysql/base.py", line 2251, in do_rollback
dbapi_connection.rollback()
TypeError: init() missing 2 required positional arguments: 'params' and 'orig'
File "flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "flask/app.py", line 1935, in dispatch_request
return self.view_functionsrule.endpoint
File "connexion/decorators/decorator.py", line 73, in wrapper
response = function(request)
File "connexion/decorators/uri_parsing.py", line 117, in wrapper
response = function(request)
File "connexion/decorators/validation.py", line 336, in wrapper
return function(request)
File "connexion/decorators/produces.py", line 38, in wrapper
response = function(request)
File "connexion/decorators/response.py", line 104, in wrapper
response = function(request)
File "connexion/decorators/decorator.py", line 44, in wrapper
response = function(request)
File "connexion/decorators/parameter.py", line 207, in wrapper
return function(**kwargs)
File "auslib/web/public/client.py", line 132, in wrapper
return f(*args, transaction=transaction, **kwargs)
File "auslib/db.py", line 209, in exit
e = exc_type(exc_value)
It looks like something changed in the constructor for some SQLAlchemy exceptions, and we're calling them incorrectly now.
Instead of just trying to fix this, I think it's worth considering whether or not we can get rid of AUSTransaction instead. I don't remember the justification for creating it in the first place, nor do I see much value in it. After pursuing some history it looks like it was added in https://bugzilla.mozilla.org/show_bug.cgi?id=678163#c13, and I may have thought it would help avoid data races?
(Imported from https://bugzilla.mozilla.org/show_bug.cgi?id=1578476)