From 4cd9bc8a6be3ed165a95b6fe0ae6eb7c480d71c8 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 30 Sep 2023 23:32:03 +0200 Subject: [PATCH] check: do not consider orphan chunks a problem if we use AdHocCache or NewCache, we do not have precise refcounting. thus, we do not delete repo objects as their refcount does not go to zero. check --repair will just remove the orphans. --- src/borg/archive.py | 4 ++-- src/borg/testsuite/archiver/check_cmd.py | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/borg/archive.py b/src/borg/archive.py index 8da51b22d..13cac5fc5 100644 --- a/src/borg/archive.py +++ b/src/borg/archive.py @@ -2331,10 +2331,10 @@ class ArchiveChecker: unused = {id_ for id_, entry in self.chunks.iteritems() if entry.refcount == 0} orphaned = unused - self.possibly_superseded if orphaned: - logger.error(f"{len(orphaned)} orphaned objects found!") + logger.info(f"{len(orphaned)} orphaned (unused) objects found.") for chunk_id in orphaned: logger.debug(f"chunk {bin_to_hex(chunk_id)} is orphaned.") - self.error_found = True + # To support working with AdHocCache or NewCache, we do not set self.error_found = True. if self.repair and unused: logger.info( "Deleting %d orphaned and %d superseded objects..." % (len(orphaned), len(self.possibly_superseded)) diff --git a/src/borg/testsuite/archiver/check_cmd.py b/src/borg/testsuite/archiver/check_cmd.py index cf4c6baf2..16b768073 100644 --- a/src/borg/testsuite/archiver/check_cmd.py +++ b/src/borg/testsuite/archiver/check_cmd.py @@ -338,10 +338,11 @@ def test_extra_chunks(archivers, request): with Repository(archiver.repository_location, exclusive=True) as repository: repository.put(b"01234567890123456789012345678901", b"xxxx") repository.commit(compact=False) - cmd(archiver, "check", exit_code=1) - cmd(archiver, "check", exit_code=1) + output = cmd(archiver, "check", "-v", exit_code=0) # orphans are not considered warnings anymore + assert "1 orphaned (unused) objects found." in output cmd(archiver, "check", "--repair", exit_code=0) - cmd(archiver, "check", exit_code=0) + output = cmd(archiver, "check", "-v", exit_code=0) + assert "orphaned (unused) objects found." not in output cmd(archiver, "extract", "archive1", "--dry-run", exit_code=0)