Skip to content

Commit fd5d00a

Browse files
committed
raft/c: warn on struck truncation.
The timeout is generously long to detect only legitmately stuck truncations.
1 parent 43a1893 commit fd5d00a

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/v/raft/consensus.cc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "reflection/adl.h"
3737
#include "rpc/types.h"
3838
#include "ssx/future-util.h"
39+
#include "ssx/watchdog.h"
3940
#include "storage/api.h"
4041
#include "storage/kvstore.h"
4142
#include "storage/ntp_config.h"
@@ -2655,10 +2656,21 @@ ss::future<> consensus::write_snapshot(write_snapshot_cfg cfg) {
26552656
co_return;
26562657
}
26572658

2658-
// Release the lock when truncating the log because it can take some
2659-
// time while we wait for readers to be evicted.
2660-
co_await _log->truncate_prefix(
2661-
storage::truncate_prefix_config(model::next_offset(last_included_index)));
2659+
{
2660+
auto truncation_offset = model::next_offset(last_included_index);
2661+
ssx::watchdog wd15min(15min, [this, truncation_offset] {
2662+
vlog(
2663+
_ctxlog.warn,
2664+
"Truncation at offset {} is taking more than 15min, log offsets: "
2665+
"{}",
2666+
truncation_offset,
2667+
_log->offsets());
2668+
});
2669+
// Release the lock when truncating the log because it can take some
2670+
// time while we wait for readers to be evicted.
2671+
co_await _log->truncate_prefix(
2672+
storage::truncate_prefix_config(truncation_offset));
2673+
}
26622674

26632675
/*
26642676
* We do not need to keep an oplock when updating the flushed offset here as

0 commit comments

Comments
 (0)