zapfdk / tui-mensa-bot

GNU General Public License v2.0
1 stars 0 forks source link

SQL verschluckt sich und muss regelmäßig zurückgerollt werden, sqlalchemy.exc.InvalidRequestError #1

Open zapfdk opened 6 years ago

zapfdk commented 6 years ago

Letztes Logfile:

@400000005ab8af92007fb55c 2018-03-26 10:30:00,006 - JobQueue - ERROR - An uncaught error was raised while executing job daily_menu
@400000005ab8af92007fc114 Traceback (most recent call last):
@400000005ab8af92007fc4fc   File "/home/steke/.local/lib/python3.4/site-packages/telegram/ext/jobqueue.py", line 245, in tick
@400000005ab8af92007fc8e4     job.run(self.bot)
@400000005ab8af92007fcccc   File "/home/steke/.local/lib/python3.4/site-packages/telegram/ext/jobqueue.py", line 372, in run
@400000005ab8af92007fd0b4     self.callback(bot, self)
@400000005ab8af9200809fbc   File "/home/steke/workspace/mensa_bot_new/run.py", line 212, in daily_menu
@400000005ab8af920080a78c     user = get_user_by_chat_id(chat_id)
@400000005ab8af920080a78c   File "/home/steke/workspace/mensa_bot_new/src/db_handling.py", line 100, in get_user_by_chat_id
@400000005ab8af920080af5c     user = sess.query(User).filter_by(chat_id=chat_id).first()
@400000005ab8af920080b344   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2789, in first
@400000005ab8af920080c6cc     ret = list(self[0:1])
@400000005ab8af920080cab4   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2581, in __getitem__
@400000005ab8af920080ce9c     return list(res)
@400000005ab8af920080d284   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2889, in __iter__
@400000005ab8af920080f5ac     return self._execute_and_instances(context)
@400000005ab8af920080f994   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2910, in _execute_and_instances
@400000005ab8af920080fd7c     close_with_result=True)
@400000005ab8af9200810164   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2919, in _get_bind_args
@400000005ab8af92008114ec     **kw
@400000005ab8af92008114ec   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/query.py", line 2901, in _connection_from_session
@400000005ab8af9200811cbc     conn = self.session.connection(**kw)
@400000005ab8af92008120a4   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1035, in connection
@400000005ab8af9200813044     execution_options=execution_options)
@400000005ab8af920081342c   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 1040, in _connection_for_bind
@400000005ab8af9200813814     engine, execution_options)
@400000005ab8af9200813bfc   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 388, in _connection_for_bind
@400000005ab8af9200814b9c     self._assert_active()
@400000005ab8af9200814f84   File "/home/steke/.local/lib/python3.4/site-packages/sqlalchemy/orm/session.py", line 276, in _assert_active
@400000005ab8af9200816ec4     % self._rollback_exception
@400000005ab8af92008172ac sqlalchemy.exc.InvalidRequestError: This Session's transaction has been rolled back due to a previous exception during flush. To begina new transaction with this Session, first issue Session.rollback(). Original exception was: (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back [SQL: 'INSERT INTO user (chat_id, subscription_time, subbed_mensas) VALUES (%(chat_id)s, %(subscription_time)s, %(subbed_mensas)s)']
[parameters: [{'chat_id': 209422801, 'subbed_mensas': None}]]

Logfile in dem der Fehler wohl verursacht wird: @400000005ab84ad506894954.s.log

thb42 commented 6 years ago

Die Exception InvalidRequestError tritt auf, aber du fängst diese in db_handling.py nicht.

zapfdk commented 6 years ago

@thb42 Danke dafür! Sollte mit https://github.com/zapfdk/tui-mensa-bot/commit/bce2c67d87d3e55aaef74da092121e4817704cee gefixed sein.

zapfdk commented 6 years ago

Besteht immer noch...

zapfdk commented 6 years ago

Added pool_pre_ping=True option to engine creation. Sollte das Problem hoffentlich beheben, indem es vor jedem session commit die Verbindung anpingt.