← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilkeremrekoc/launchpad:librarian-autocommit-change into launchpad:master

 

İlker Emre Koç has proposed merging ~ilkeremrekoc/launchpad:librarian-autocommit-change into launchpad:master.

Commit message:
Change libraian-gc file deletion to autocommit

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilkeremrekoc/launchpad/+git/launchpad/+merge/491702

In pyscopg2, even "SELECT" queries are counted as transactions by
default. And currently, librarian-gc uses autocommit with the value
False. This results in a need to close each transaction manually, which
were logical while we were using a single large query, but since we
separated the queries into chunks, this results in each query to be
kept open. Thus we change the autocommit value to True so that after
each query we start working on the next query.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilkeremrekoc/launchpad:librarian-autocommit-change into launchpad:master.
diff --git a/lib/lp/services/librarianserver/librariangc.py b/lib/lp/services/librarianserver/librariangc.py
index 5c04c55..57e5d92 100644
--- a/lib/lp/services/librarianserver/librariangc.py
+++ b/lib/lp/services/librarianserver/librariangc.py
@@ -673,8 +673,8 @@ def delete_unwanted_files(con):
     con.rollback()
     orig_autocommit = con.autocommit
     try:
-        # Disable autocommit so that we can use named cursors.
-        con.autocommit = False
+        # Enable autocommit so that each query gets closed automatically.
+        con.autocommit = True
         delete_unwanted_disk_files(con)
         swift_enabled = getFeatureFlag("librarian.swift.enabled") or False
         if swift_enabled: