db: logging option for cursor

In some cases we expect query to fail (LOCK NOWAIT) but it still
clutters the logs. Option for not logging cursor-level errors.

Fixes: https://pagure.io/koji/issue/2837
This commit is contained in:
Tomas Kopecek 2021-12-07 13:32:35 +01:00
parent bc04708990
commit e7db7d8b53
3 changed files with 10 additions and 6 deletions

View file

@ -356,7 +356,7 @@ def handle_db_msgs(urls, CONFIG):
# we're running in postCommit, so we need to handle new transaction
c.execute('BEGIN')
try:
c.execute('LOCK TABLE proton_queue IN ACCESS EXCLUSIVE MODE NOWAIT')
c.execute('LOCK TABLE proton_queue IN ACCESS EXCLUSIVE MODE NOWAIT', log=False)
except psycopg2.OperationalError:
LOG.debug('skipping db queue due to lock')
return