The first select on a DB will start an implicit transaction and hold it open until it is either explicitly rolled back or committed, or automatically rolled back when the connection closes. This is not a recommended best practice as it can result in long-lived transactions, database locks, and table bloat if auto vacuum isn't able to remove objects.
ebookconverter creates long-lived DB connections at module load time, for example: Candidates.py:
ob = GutenbergDatabase.Objectbase(False)
Even though the module is only doing selects, it creates a transaction that is held open the entire time the process is running.
ebookconverter only does explicit transactions in BlueskyWriter.py, FacebookWriter.py, and MastodonWriter.py but even those aren't done correctly because the initial select starts the transaction on the connection that is ultimately rolled back.
One solution is to update libgutenberg.GutenbergDatabase.Database (raw DBAPI connection) and Objectbase (sqlalchemy connection) to allow those constructors to pass in the appropriate autocommit setting and then having ebookconverter use them. Then the explicit transactions in the above files can be removed as well.
References:
The first
selecton a DB will start an implicit transaction and hold it open until it is either explicitly rolled back or committed, or automatically rolled back when the connection closes. This is not a recommended best practice as it can result in long-lived transactions, database locks, and table bloat if auto vacuum isn't able to remove objects.ebookconverter creates long-lived DB connections at module load time, for example:
Candidates.py:Even though the module is only doing
selects, it creates a transaction that is held open the entire time the process is running.ebookconverter only does explicit transactions in
BlueskyWriter.py,FacebookWriter.py, andMastodonWriter.pybut even those aren't done correctly because the initial select starts the transaction on the connection that is ultimately rolled back.One solution is to update libgutenberg.GutenbergDatabase.Database (raw DBAPI connection) and Objectbase (sqlalchemy connection) to allow those constructors to pass in the appropriate autocommit setting and then having ebookconverter use them. Then the explicit transactions in the above files can be removed as well.
References: