Skip to content

Improve garbage collection session handling #793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/aleph/services/storage/garbage_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ async def collect(self, datetime: dt.datetime):
files_to_delete = list(get_unpinned_files(session))
LOGGER.info("Found %d files to delete", len(files_to_delete))

for file_to_delete in files_to_delete:
for file_to_delete in files_to_delete:
with self.session_factory() as session:
try:
file_hash = ItemHash(file_to_delete.hash)
LOGGER.info("Deleting %s...", file_hash)
Expand All @@ -68,6 +69,7 @@ async def collect(self, datetime: dt.datetime):
LOGGER.info("Deleted %s", file_hash)
except Exception as err:
LOGGER.error("Failed to delete file %s: %s", file_hash, str(err))
session.rollback()


async def garbage_collector_task(
Expand Down
Loading