From 1c8f2db4d2ec6ca67fc1bbc7c84d37aa40f40856 Mon Sep 17 00:00:00 2001 From: Madison Swain-Bowden Date: Tue, 21 Dec 2021 13:00:10 -0800 Subject: [PATCH] Use gc.collect instead --- ingestion_server/ingestion_server/ingest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ingestion_server/ingestion_server/ingest.py b/ingestion_server/ingestion_server/ingest.py index 217379ecc..d6584debd 100644 --- a/ingestion_server/ingestion_server/ingest.py +++ b/ingestion_server/ingestion_server/ingest.py @@ -16,6 +16,7 @@ """ import datetime +import gc import logging as log import psycopg2 @@ -319,9 +320,9 @@ def reload_upstream(table, progress=None, finish_time=None, approach="advanced") f"_Next: re-applying indices & constraints_" ) - # The server sometimes hangs on or before this next step. Adding this debug - # message here because apparently that unblocks it? May have to do with GC. - log.debug("Getting downstream cursor again") + # The server sometimes hangs on or before this next step. This is a pre-emptive + # garbage collection to try and assist with that. + gc.collect() downstream_db = database_connect() with downstream_db.cursor() as downstream_cur: # Step 5: Recreate indices from the original table