Skip to content

Commit

Permalink
Actually, always rollback the datanommer session
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Jun 7, 2024
1 parent ef7358b commit 6f8b609
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fedbadges/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ def __call__(self, message: Message):
self._process_message(message)
except SQLAlchemyError:
log.exception("Could not process message %s on %s", message.id, message.topic)
# If we don't rollback, following queryies will fail.
# If we don't rollback, following queryies will fail: https://sqlalche.me/e/20/8s2b
self.tahrir.session.rollback()
finally:
# Always finish the datanommer transaction with a rollback, it's read-only.
datanommer.models.session.rollback()
# Also rollback the connection to avoid https://sqlalche.me/e/20/8s2b
self.tahrir.session.connection().rollback()
datanommer.models.session.connection().rollback()

def _process_message(self, message: Message):
# First thing, we receive the message, but we put ourselves to sleep to
Expand Down

0 comments on commit 6f8b609

Please sign in to comment.