From d124cf076185298052b4ad6da80e88ceedbb687b Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 8 Nov 2019 00:10:28 +0100 Subject: [PATCH 1/2] check: improve error output for matching index size, see #4829 if the rebuilt index size matched the on-disk index size AND there was a difference in e.g. 1 key, the old code only output the key/value for one index, but not what is present in the other index. we already had better code in the branch for different index sizes, so just use that for both cases. additionally we tell when the index size matches (new) because we also tell if there is a mismatch. --- src/borg/repository.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/borg/repository.py b/src/borg/repository.py index b306cdfb6..585259d0f 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -1022,24 +1022,21 @@ def report_error(msg): report_error('Index object count mismatch.') logger.error('committed index: %d objects', len(current_index)) logger.error('rebuilt index: %d objects', len(self.index)) - - line_format = '%-64s %-16s %-16s' - not_found = '' - logger.warning(line_format, 'ID', 'rebuilt index', 'committed index') - for key, value in self.index.iteritems(): - current_value = current_index.get(key, not_found) - if current_value != value: - logger.warning(line_format, bin_to_hex(key), value, current_value) - for key, current_value in current_index.iteritems(): - if key in self.index: - continue - value = self.index.get(key, not_found) - if current_value != value: - logger.warning(line_format, bin_to_hex(key), value, current_value) - elif current_index: - for key, value in self.index.iteritems(): - if current_index.get(key, (-1, -1)) != value: - report_error('Index mismatch for key {}. {} != {}'.format(key, value, current_index.get(key, (-1, -1)))) + else: + logger.info('Index object count match.') + line_format = '%-64s %-16s %-16s' + not_found = '' + logger.warning(line_format, 'ID', 'rebuilt index', 'committed index') + for key, value in self.index.iteritems(): + current_value = current_index.get(key, not_found) + if current_value != value: + logger.warning(line_format, bin_to_hex(key), value, current_value) + for key, current_value in current_index.iteritems(): + if key in self.index: + continue + value = self.index.get(key, not_found) + if current_value != value: + logger.warning(line_format, bin_to_hex(key), value, current_value) if repair: self.write_index() self.rollback() From dd7c08ae91e5add054263873886cd040e3e4d757 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 8 Nov 2019 00:15:36 +0100 Subject: [PATCH 2/2] do not emit warning headline, there might be no mismatches to report instead, use a slightly different format for the warnings themselves. --- src/borg/repository.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/borg/repository.py b/src/borg/repository.py index 585259d0f..e64fb78f2 100644 --- a/src/borg/repository.py +++ b/src/borg/repository.py @@ -1024,9 +1024,8 @@ def report_error(msg): logger.error('rebuilt index: %d objects', len(self.index)) else: logger.info('Index object count match.') - line_format = '%-64s %-16s %-16s' + line_format = 'ID: %-64s rebuilt index: %-16s committed index: %-16s' not_found = '' - logger.warning(line_format, 'ID', 'rebuilt index', 'committed index') for key, value in self.index.iteritems(): current_value = current_index.get(key, not_found) if current_value != value: