Skip to content

Report log store time in the slow append_entries warning - #149

Open
yackushevas wants to merge 2 commits into
ClickHouse:masterfrom
yackushevas:append-warn-log-store-time
Open

yackushevas wants to merge 2 commits into
ClickHouse:masterfrom
yackushevas:append-warn-log-store-time

Conversation

@yackushevas

Copy link
Copy Markdown

handle_append_entries times the whole handler with one timer, so the warning cannot tell whether the time went to the log store or to the rest of the handler (locks, state machine callbacks, a busy raft thread).

Add a second accumulator for the log store write path: store_log_entry on both the overwrite and the append path, end_of_append_batch, and the wait for durability with parallel_log_appending_. It is reported right after the total:

appending entries from peer 2 took long time (593 ms), log_store 593 ms
req type: 3, req term: 1, req l idx: 64 (1), req c idx: 64, my term: 1, my role: 1

The new text comes after took long time (N ms) and adds no parentheses, so parsers matching took long time \((\d+) ms\) keep returning the total.

In our ClickHouse Keeper production cluster these warnings (118 in 6 hours on 4 of 6 nodes, 500–1534 ms) gave no way to tell fsync stalls from lock waits or raft-thread starvation.

Verified with a ClickHouse build on this branch: in a 3-node keeper cluster with heart_beat_interval_ms=100, a follower with min_time_between_fsyncs_ms=600 (every changelog flush is delayed) logged the line above and two more like it, with log_store 0–1 ms below the total; the other nodes logged none.

The warning on slow append_entries handling has a single timer covering
the whole handler, so there is no way to tell whether the time went to
the log store (storing entries and waiting for their durability) or
elsewhere (locks, state machine callbacks).

Accumulate the time spent on log store operations into a separate
counter and report it as "log_store <N> ms" right after the existing
total, so that existing parsers of "took long time (N ms)" keep
working.
Drop the comment that only restates the names, put the initializer
list on leading commas and the destructor body on one line, like the
other local guard structs in this file.
@yackushevas
yackushevas marked this pull request as ready for review November 23, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant