~sircmpwn/lists.sr.ht#168: 
Saving webhook delivery status results in traceback

In my testing on my install of lists (0.45.20) it seems when trying to save the webhook delivery results the task fails a couple of times before finally saving. Almost seems like the delivery write hasn't been committed before the update is being triggered.

Nov 16 21:16:48 code python3[920279]: [2020-11-16 21:16:48,764: INFO/MainProcess] Received task: srht.webhook.celery.async_request[8b6f8a0e-cbcd-4809-8301
-e9412f85d365]
Nov 16 21:16:48 code python3[920393]: [2020-11-16 21:16:48,763: ERROR/ForkPoolWorker-2] Task srht.webhook.celery.async_request[1b9d3c66-f997-41ad-804a-e3e
05e26a3de] raised unexpected: InternalError('(psycopg2.errors.InFailedSqlTransaction) current transaction is aborted, commands ignored until end of transa
ction block\n')
Nov 16 21:16:48 code python3[920393]: Traceback (most recent call last):
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
Nov 16 21:16:48 code python3[920393]:     self.dialect.do_execute(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 593, in do_execute
Nov 16 21:16:48 code python3[920393]:     cursor.execute(statement, parameters)
Nov 16 21:16:48 code python3[920393]: psycopg2.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction bl
ock
Nov 16 21:16:48 code python3[920393]: The above exception was the direct cause of the following exception:
Nov 16 21:16:48 code python3[920393]: Traceback (most recent call last):
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/celery/app/trace.py", line 412, in trace_task
Nov 16 21:16:48 code python3[920393]:     R = retval = fun(*args, **kwargs)
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/celery/app/trace.py", line 704, in __protected_call__
Nov 16 21:16:48 code python3[920393]:     return self.run(*args, **kwargs)
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/srht/webhook/celery.py", line 36, in async_request
Nov 16 21:16:48 code python3[920393]:     db.session.execute(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/orm/scoping.py", line 163, in do
Nov 16 21:16:48 code python3[920393]:     return getattr(self.registry(), name)(*args, **kwargs)
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/orm/session.py", line 1291, in execute
Nov 16 21:16:48 code python3[920393]:     return self._connection_for_bind(bind, close_with_result=True).execute(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1011, in execute
Nov 16 21:16:48 code python3[920393]:     return meth(self, multiparams, params)
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
Nov 16 21:16:48 code python3[920393]:     return connection._execute_clauseelement(self, multiparams, params)
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1124, in _execute_clauseelement
Nov 16 21:16:48 code python3[920393]:     ret = self._execute_context(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1316, in _execute_context
Nov 16 21:16:48 code python3[920393]:     self._handle_dbapi_exception(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
Nov 16 21:16:48 code python3[920393]:     util.raise_(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/util/compat.py", line 182, in raise_
Nov 16 21:16:48 code python3[920393]:     raise exception
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1276, in _execute_context
Nov 16 21:16:48 code python3[920393]:     self.dialect.do_execute(
Nov 16 21:16:48 code python3[920393]:   File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 593, in do_execute
Nov 16 21:16:48 code python3[920393]:     cursor.execute(statement, parameters)
Nov 16 21:16:48 code python3[920393]: sqlalchemy.exc.InternalError: (psycopg2.errors.InFailedSqlTransaction) current transaction is aborted, commands ign$
red until end of transaction block
Nov 16 21:16:48 code python3[920393]: [SQL:
Nov 16 21:16:48 code python3[920393]:                 UPDATE list_webhook_delivery
Nov 16 21:16:48 code python3[920393]:                 SET response = %(response)s,
Nov 16 21:16:48 code python3[920393]:                     response_status = %(status)s,
Nov 16 21:16:48 code python3[920393]:                     response_headers = %(headers)s
Nov 16 21:16:48 code python3[920393]:                 WHERE id = %(delivery_id)s
Nov 16 21:16:48 code python3[920393]:                 ]
Nov 16 21:16:48 code python3[920393]: [parameters: {'response': 'Thanks!', 'status': 200, 'headers': 'Server: nginx\nDate: Mon, 16 Nov 2020 21:16:48 GMT\$
Content-Type: text/html; charset=utf-8\nContent-Length: 7\nConnection: keep-alive\nKeep-Alive: ti ... (243 characters truncated) ...  sync-xhr none; micr$
phone none; camera none; magnetometer none; gyroscope none; speaker none; vibrate none; fullscreen self; payment none; usb none;', 'delivery_id': 36}]
Nov 16 21:16:48 code python3[920393]: (Background on this error at: http://sqlalche.me/e/13/2j85)
Nov 16 21:16:48 code python3[920951]: [2020-11-16 21:16:48,791: INFO/ForkPoolWorker-2] Task srht.webhook.celery.async_request[ae01ebd5-7a58-47fd-9c01-69c$
9432d10d] succeeded in 0.03890800476074219s: <Response [200]>
Status
REPORTED
Submitter
~petersanchez
Assigned to
No-one
Submitted
10 months ago
Updated
10 months ago
Labels
No labels applied.

~petersanchez 10 months ago

Can see the traceback a little easier in the paste:

https://paste.sr.ht/~petersanchez/5f7256fa8137b477647003433f84a986b3c4c9f7

Register here or Log in to comment, or comment via email.