Skip to content

Commit 5f0ed60

Browse files
pks-tgitster
authored andcommitted
reftable/stack: update stats on failed full compaction
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8030100 commit 5f0ed60

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

reftable/stack.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,13 +1205,6 @@ static int stack_compact_range(struct reftable_stack *st,
12051205
return err;
12061206
}
12071207

1208-
int reftable_stack_compact_all(struct reftable_stack *st,
1209-
struct reftable_log_expiry_config *config)
1210-
{
1211-
return stack_compact_range(st, 0, st->merged->stack_len ?
1212-
st->merged->stack_len - 1 : 0, config);
1213-
}
1214-
12151208
static int stack_compact_range_stats(struct reftable_stack *st,
12161209
size_t first, size_t last,
12171210
struct reftable_log_expiry_config *config)
@@ -1222,6 +1215,13 @@ static int stack_compact_range_stats(struct reftable_stack *st,
12221215
return err;
12231216
}
12241217

1218+
int reftable_stack_compact_all(struct reftable_stack *st,
1219+
struct reftable_log_expiry_config *config)
1220+
{
1221+
size_t last = st->merged->stack_len ? st->merged->stack_len - 1 : 0;
1222+
return stack_compact_range_stats(st, 0, last, config);
1223+
}
1224+
12251225
static int segment_size(struct segment *s)
12261226
{
12271227
return s->end - s->start;

reftable/stack_test.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,8 +1005,7 @@ static void test_reftable_stack_compaction_with_locked_tables(void)
10051005
*/
10061006
err = reftable_stack_compact_all(st, NULL);
10071007
EXPECT(err == REFTABLE_LOCK_ERROR);
1008-
/* TODO: this is wrong, we should get notified about the failure. */
1009-
EXPECT(st->stats.failures == 0);
1008+
EXPECT(st->stats.failures == 1);
10101009
EXPECT(st->merged->stack_len == 3);
10111010

10121011
reftable_stack_destroy(st);

0 commit comments

Comments
 (0)