#1762 koji-sweep-db VACUUM inside a transaction
Closed: Fixed by tkopecek. Opened by jforaker.

Receiving the following error in 1.19.0:

[root@koji ~]# /usr/sbin/koji-sweep-db
No handlers could be found for logger "koji.db"
Traceback (most recent call last):
  File "/usr/sbin/koji-sweep-db", line 87, in <module>
    clean_sessions(cursor, options.vacuum)
  File "/usr/sbin/koji-sweep-db", line 19, in clean_sessions
    cursor.execute("VACUUM ANALYZE sessions")
  File "/usr/lib/python2.7/site-packages/koji/db.py", line 136, in execute
    ret = self.cursor.execute(operation, parameters)
psycopg2.InternalError: VACUUM cannot run inside a transaction block

It's possible that I'm turning this up due to using older versions of psycopg2/postgresql, but documentation seems to indicate that modern versions of PostgreSQL still don't support VACUUM in transactions, and psycopg2 still leaves transactions open when idle.
Turning on autocommit does work around the issue.


Metadata Update from @tkopecek:
- Custom field Size adjusted to None
- Issue set to the milestone: 1.20
- Issue tagged with: bug

PR #1771

Commit 1a4fae67 fixes this issue

Metadata Update from @jcupova:
- Issue tagged with: testing-done

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/koji/koji/issues/1762

Please continue any further discussion there.

Metadata