]> git.ipfire.org Git - thirdparty/git.git/commitdiff
reftable/stack: update stats on failed full compaction
authorPatrick Steinhardt <ps@pks.im>
Thu, 8 Aug 2024 14:06:34 +0000 (16:06 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Aug 2024 17:14:42 +0000 (10:14 -0700)
When auto-compaction fails due to a locking error, we update the
statistics to indicate this failure. We're not doing the same when
performing a full compaction.

Fix this inconsistency by using `stack_compact_range_stats()`, which
handles the stat update for us.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/stack.c
reftable/stack_test.c

index ba8234b4865b714f3daebc0d0333b18244de6ae1..e5959d2c765afe88fd88826bc1f03ff204806c24 100644 (file)
@@ -1205,13 +1205,6 @@ done:
        return err;
 }
 
-int reftable_stack_compact_all(struct reftable_stack *st,
-                              struct reftable_log_expiry_config *config)
-{
-       return stack_compact_range(st, 0, st->merged->stack_len ?
-                       st->merged->stack_len - 1 : 0, config);
-}
-
 static int stack_compact_range_stats(struct reftable_stack *st,
                                     size_t first, size_t last,
                                     struct reftable_log_expiry_config *config)
@@ -1222,6 +1215,13 @@ static int stack_compact_range_stats(struct reftable_stack *st,
        return err;
 }
 
+int reftable_stack_compact_all(struct reftable_stack *st,
+                              struct reftable_log_expiry_config *config)
+{
+       size_t last = st->merged->stack_len ? st->merged->stack_len - 1 : 0;
+       return stack_compact_range_stats(st, 0, last, config);
+}
+
 static int segment_size(struct segment *s)
 {
        return s->end - s->start;
index 1d109933d335f88566f413ccf0909f0291aa4c5e..3ed8e44924f1075a011bbd6d18eba7dc29bbb26e 100644 (file)
@@ -1005,8 +1005,7 @@ static void test_reftable_stack_compaction_with_locked_tables(void)
         */
        err = reftable_stack_compact_all(st, NULL);
        EXPECT(err == REFTABLE_LOCK_ERROR);
-       /* TODO: this is wrong, we should get notified about the failure. */
-       EXPECT(st->stats.failures == 0);
+       EXPECT(st->stats.failures == 1);
        EXPECT(st->merged->stack_len == 3);
 
        reftable_stack_destroy(st);