Skip to content

Commit a1c9952

Browse files
committed
Add a default timepout for the lock files used when download data.
This is to prevent a deadlock if the code can't get the lock file. Example: ERROR 2024/11/14 03:55:11 PM - lifetime has expired, breaking ERROR 2024/11/14 03:55:11 PM - lockfile exists but isn't safe to break: /hps/nobackup/rdf/metagenomics/service-team/production/automated_jobs/ERP1432/ERP143252/download.lock If this happens the process hangs there indefinitely. With the timeout the code will fail and exit with a Timeout error at least
1 parent 31e11c2 commit a1c9952

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fetchtool/abstract_fetch.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ def write_project_download_file(self, project_accession, new_rows):
343343
self.create_empty_file(download_file)
344344

345345
lock_file = download_file + ".lock"
346-
# Lock for 1 minute
347-
with Lock(lock_file, lifetime=60):
346+
# Lock for 1 minute, timeout after 10 minutes to avoid deadlocking the code if it can get the lock
347+
with Lock(lock_file, lifetime=60, default_timeout=60 * 10):
348348
existing_rows = set(self.read_download_data(project_accession))
349349
existing_rows = existing_rows.union(set(new_download_rows))
350350
with open(download_file, "w+") as f:
@@ -412,7 +412,8 @@ def write_project_description_file(self, project_accession, new_rows):
412412

413413
lock_file = project_file + ".lock"
414414
# We lock the file for 2 minutes, should be enough
415-
with Lock(lock_file, lifetime=120):
415+
# The timeout will prevent a deadlock, if within 10 minutes it can't get the lock it will timeout and exit
416+
with Lock(lock_file, lifetime=120, default_timeout=60 * 10):
416417
# Fallback in case empty file exists
417418
try:
418419
project_runs = self.read_project_description_file(project_accession)

0 commit comments

Comments
 (0)