diff --git a/ezidapp/management/commands/proc-expunge.py b/ezidapp/management/commands/proc-expunge.py index 8776bdad..1d25c225 100755 --- a/ezidapp/management/commands/proc-expunge.py +++ b/ezidapp/management/commands/proc-expunge.py @@ -192,6 +192,7 @@ def get_id_range_by_time(self, time_range: Q): last_id = last_record.id except Exception as ex: log.error(f"Database error while retrieving first and last record from Identifier: {ex}") + # add retry logic here return first_id, last_id @@ -229,7 +230,10 @@ def seconds_to_date(self, seconds_since_epoch: int) -> str: def sleep_and_prepare_next_batch(self): sleep_time = django.conf.settings.DAEMONS_LONG_SLEEP + django.db.connections["default"].close() + log.info(f'Closing DB connections before entering sleep mode.') log.info(f"Sleep {sleep_time} sec before running next batch.") + self.sleep(sleep_time) self.min_age_ts = self.max_age_ts self.max_age_ts = int(time.time()) - django.conf.settings.DAEMONS_EXPUNGE_MAX_AGE_SEC