Handling of database errors
Right now database errors are not properly handled. For example error induced by failing some of the constrains is shown below. In this case, it is our application that just tried to do something wrong and we can fix it on the side of the application. but, in principle, user could induce additional constraints that we are not aware of. So, we should handle it better.
Right now, after that error, application cannot communicate with the database anymore. On every new transaction it will try to repeat the same failed one.
[SQL: UPDATE gel_lane SET lane=%(lane)s WHERE gel_lane.id = %(gel_lane_id)s]
[parameters: {'lane': '1', 'gel_lane_id': 5}]
(Background on this error at: https://sqlalche.me/e/14/gkpj) (Background on this error at: https://sqlalche.me/e/14/7s2a)
qt.qpa.wayland: Creating a fake screen in order for Qt not to crash
qt.qpa.wayland: Creating a fake screen in order for Qt not to crash
Traceback (most recent call last):
File "/home/markov/code/gel/iocbio/gel/gui/widgets/tables/gels_table.py", line 101, in load_on_context_change
gels = self.repository.fetch_all()
File "/home/markov/code/gel/iocbio/gel/repository/gel_repository.py", line 33, in fetch_all
return self.db.execute(stmt).scalars().all()
File "/home/markov/code/gel/iocbio/gel/db/database_client.py", line 64, in execute
return self.session.execute(statement)
File "/home/markov/code/gel/.venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1695, in execute
conn = self._connection_for_bind(bind)
File "/home/markov/code/gel/.venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1536, in _connection_for_bind
return self._transaction._connection_for_bind(
File "/home/markov/code/gel/.venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 721, in _connection_for_bind
self._assert_active()
File "/home/markov/code/gel/.venv/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 601, in _assert_active
raise sa_exc.PendingRollbackError(
sqlalchemy.exc.PendingRollbackError: This Session's transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "uc_gel_lane_unique"
DETAIL: Key (lane, gel_id)=(1, 1) already exists.