From 9bf352d00c3017867ca971777ad63d257df7dd91 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Wed, 8 Feb 2023 15:09:13 +0100 Subject: [PATCH] bugfix: do not resize hashindex with wrong num_empty otherwise we would lose the decrement operation on num_empty. --- src/borg/_hashindex.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/borg/_hashindex.c b/src/borg/_hashindex.c index da378f45c..7eb1f5ea0 100644 --- a/src/borg/_hashindex.c +++ b/src/borg/_hashindex.c @@ -749,8 +749,7 @@ hashindex_set(HashIndex *index, const unsigned char *key, const void *value) } idx = start_idx; if(BUCKET_IS_EMPTY(index, idx)){ - index->num_empty--; - if(index->num_empty < index->min_empty) { + if(index->num_empty <= index->min_empty) { /* too many tombstones here / not enough empty buckets, do a same-size rebuild */ if(!hashindex_resize(index, index->num_buckets)) { return 0; @@ -763,6 +762,7 @@ hashindex_set(HashIndex *index, const unsigned char *key, const void *value) assert(BUCKET_IS_EMPTY(index, start_idx)); idx = start_idx; } + index->num_empty--; } else { /* Bucket must be either EMPTY (see above) or DELETED. */ assert(BUCKET_IS_DELETED(index, idx));