Skip to content

Garbage collection failure proof #792

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
27 changes: 14 additions & 13 deletions src/aleph/services/storage/garbage_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ def __init__(
async def _delete_from_ipfs(self, file_hash: ItemHash):
ipfs_client = self.storage_service.ipfs_service.ipfs_client
try:
result = await ipfs_client.pin.rm(file_hash)
print(result)

await ipfs_client.pin.rm(file_hash)
except NotPinnedError:
LOGGER.warning("File not pinned: %s", file_hash)
except Exception as err:
LOGGER.error("Failed to unpin file %s: %s", file_hash, str(err))
LOGGER.warning("Failed to unpin file %s: %s", file_hash, str(err))

# Smaller IPFS files are cached in local storage
LOGGER.debug("Deleting %s from local storage", file_hash)
Expand All @@ -55,18 +53,21 @@ async def collect(self, datetime: dt.datetime):
LOGGER.info("Found %d files to delete", len(files_to_delete))

for file_to_delete in files_to_delete:
file_hash = ItemHash(file_to_delete.hash)
LOGGER.info("Deleting %s...", file_hash)
try:
file_hash = ItemHash(file_to_delete.hash)
LOGGER.info("Deleting %s...", file_hash)

delete_file_db(session=session, file_hash=file_hash)
session.commit()
delete_file_db(session=session, file_hash=file_hash)
session.commit()

if file_hash.item_type == ItemType.ipfs:
await self._delete_from_ipfs(file_hash)
elif file_hash.item_type == ItemType.storage:
await self._delete_from_local_storage(file_hash)
if file_hash.item_type == ItemType.ipfs:
await self._delete_from_ipfs(file_hash)
elif file_hash.item_type == ItemType.storage:
await self._delete_from_local_storage(file_hash)

LOGGER.info("Deleted %s", file_hash)
LOGGER.info("Deleted %s", file_hash)
except Exception as err:
LOGGER.error("Failed to delete file %s: %s", file_hash, str(err))


async def garbage_collector_task(
Expand Down
Loading