> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# What distributed consensus implementation does ClickHouse use?

> ClickHouse uses the Raft consensus algorithm, implemented in ClickHouse Keeper on top of a heavily modified fork of the NuRaft library. This page lists every patch in the fork and the bug it fixed.

ClickHouse uses the [Raft](https://raft.github.io/) consensus algorithm. It is implemented in [ClickHouse Keeper](https://clickhouse.com/docs/guides/oss/deployment-and-scaling/keeper/index.md), the coordination service built into the `clickhouse` binary.

The Raft implementation in ClickHouse Keeper is based on the [NuRaft](https://github.com/eBay/NuRaft) library, originally developed at eBay. ClickHouse does not use the original library. It uses [its own fork](https://github.com/ClickHouse/NuRaft), which we had to patch with numerous fixes after exhaustive testing, and which has been modified extensively for ClickHouse.

> [!WARNING]
>
> **The original NuRaft library is not suitable for production use.** Testing it under fault injection and sanitizers, and running it in production, exposed defects that stall replication to a follower, make a server stop accepting Raft connections until it is restarted, terminate the leader process, and allow a committed log entry to be lost. Many of the fixes listed on this page are still absent from the original library. The reliability of ClickHouse Keeper is a property of the fork, not of the original library.

## What is consensus used for in ClickHouse?

Consensus is used for coordination metadata, not for table data. ClickHouse Keeper stores the replication log and the metadata of data parts of `ReplicatedMergeTree` tables, the metadata of `Replicated` databases, the queue of distributed DDL queries, and similar data. Every change to it goes through Raft. The data parts themselves are transferred between replicas directly.

ClickHouse can also work with ZooKeeper, which uses a different algorithm (ZAB), but [ClickHouse Keeper is recommended](https://clickhouse.com/docs/resources/support-center/knowledge-base/general-faqs/why-recommend-clickhouse-keeper-over-zookeeper.md).

## Why does ClickHouse maintain a fork?

The development of ClickHouse Keeper started on the original library at the end of 2020. Five weeks later it switched to a fork to get a fix for a race condition, and it has used the fork since. Problems found by tests or in production had to be fixed in the library, and ClickHouse Keeper needed features that the original library does not have, such as snapshots larger than 2 GiB.

As of 2026-11-30, the `master` branch of the fork contains 124 merged pull requests:

| Kind of change | Pull requests |
| - | - |
| Bug fixes | 54 |
| Defensive checks | 2 |
| Features needed by ClickHouse Keeper | 29 |
| Logging and diagnostics | 9 |
| Build, portability, and tests | 9 |
| Synchronization with the original library | 21 |

The fork differs from the last revision of the original library it was synchronized with by 4422 added and 1018 removed lines in 45 files of library code, and by about 6000 lines of additional tests.

Of the 56 bug fixes and defensive checks, 10 are follow-ups to earlier patches of the fork itself. The other 46 address the code of the original library, and 8 of those also involve our own changes.

The fork is synchronized with the original library regularly, and some patches were contributed back and accepted by the original project. The entries below say which. As of 2026-11-30, about twenty fixes for defects in the original code are still absent from it. Among them are the fixes for a lost committed entry ([#155](https://github.com/ClickHouse/NuRaft/pull/155)), for the leader terminating its own process ([#96](https://github.com/ClickHouse/NuRaft/pull/96)), and for a server that stops accepting Raft connections ([#128](https://github.com/ClickHouse/NuRaft/pull/128)).

Synchronization is itself a source of defects: the fixes #42, #80, #81, #83, and #85 address problems that arrived with a merge of the original library.

## How is the fork tested?

The fork is tested as a part of ClickHouse Keeper:

* **Jepsen tests.** The [Jepsen](https://jepsen.io/) test suite for ClickHouse Keeper checks the linearizability of a compare-and-set register and the consistency of set, counter, queue, and unique identifier workloads. Its faults are killing and pausing nodes, network partitions, and corruption of the latest logs and snapshots. Every night, continuous integration runs the set, counter, queue, and unique identifier workloads while nodes are killed and paused and the network is partitioned. The register workload and the corruption faults are not part of the nightly run.
* **Stress tests.** A three-node cluster serves a production-like mix of requests. The tests run without faults on pull requests and four nights a week. On the other three nights they run with injected network delay, disk delay, CPU starvation, and memory pressure. The metrics are recorded for comparison over time.
* **Integration tests.** About 90 test suites cover multi-node clusters: restarts, reconfiguration, removing and adding servers, snapshot transfer, recovery from a lost quorum, and TLS certificate rotation.
* **Sanitizers.** The integration tests run in builds with AddressSanitizer (ASan), ThreadSanitizer (TSan), MemorySanitizer (MSan), and UndefinedBehaviorSanitizer (UBSan). Sanitizers found the data races and lifetime errors fixed in #54, #55, #103, #106, #108, #119, #128, and #144.
* **Regression tests in the fork.** Many fixes come with a unit test that reproduces the bug on a simulated network. The fork has about 6000 lines of such tests.
* **Production.** ClickHouse Cloud runs ClickHouse Keeper for thousands of services. The bugs fixed in #102, #118, #121, and #129 were found in production.

## List of patches

The list contains every pull request merged into the `master` branch of the fork as of 2026-11-30, with the date of the merge. Function and variable names refer to the source code of the library.

An entry that starts with "Follow-up to" fixes a defect introduced by an earlier patch of the fork. All other fixes address the code of the original library, alone or, where noted, in combination with our changes.

### Log replication and commit

* [#7](https://github.com/ClickHouse/NuRaft/pull/7), 2021-02-24. **Lost wake-up of the commit thread.** `raft_server::commit_in_bg` checked whether there was anything to commit without holding the lock, and then waited on the condition variable without a predicate. A notification that arrived in between was lost, the commit thread slept until the next commit, and a client request could wait until its timeout. Accepted upstream as [eBay/NuRaft#187](https://github.com/eBay/NuRaft/pull/187).
* [#8](https://github.com/ClickHouse/NuRaft/pull/8), 2021-02-24. Follow-up to #7: the new wait predicate did not include `stopping_`, so the commit thread could not be woken up for shutdown when there was nothing to commit.
* [#27](https://github.com/ClickHouse/NuRaft/pull/27), 2021-08-02. **Entries applied at startup were reported as cancelled requests.** When a leader applied entries that were already in its log at startup, `commit_app_log` assumed that a client was about to wait for each of them and registered a result element that nothing consumed. Each of them was later reported as a cancelled client request.
* [#36](https://github.com/ClickHouse/NuRaft/pull/36), 2022-01-21. **Unbounded memory growth on batched requests.** A client request with a batch of N entries has a waiter for the last entry only, but the commit thread registered a result element for each of the other N - 1 entries, and nothing erased them. `commit_ret_elems_` grew until the server lost leadership or ran out of memory. Accepted upstream as [eBay/NuRaft#278](https://github.com/eBay/NuRaft/pull/278).
* [#53](https://github.com/ClickHouse/NuRaft/pull/53), 2023-02-01. **Deadlock on a failed log append.** With `parallel_log_appending_`, a follower waits for its log to become durable while holding `lock_`, and the notification about a failed append needed the same lock, so it never stopped the server. The server is now stopped without taking the lock, on the leader and on the follower.
* [#79](https://github.com/ClickHouse/NuRaft/pull/79), 2024-11-19. **`commit` called before `pre_commit`.** A configuration change advanced the pre-commit index while holding `lock_` only, concurrently with `handle_cli_req`, which appends client entries while holding `cli_lock_` only. The commit thread could call `commit` of the state machine for a client entry before `pre_commit` was called for it. Accepted upstream as [eBay/NuRaft#554](https://github.com/eBay/NuRaft/pull/554).
* [#93](https://github.com/ClickHouse/NuRaft/pull/93), 2026-03-17. **A spurious wake-up returned an empty result.** `cmd_result::get` waited on the condition variable once and without a predicate, so a spurious wake-up made it return before the result was set. The original library fixed the same bug in [eBay/NuRaft#601](https://github.com/eBay/NuRaft/pull/601).
* [#102](https://github.com/ClickHouse/NuRaft/pull/102), 2026-04-16. **Replication stalled after a snapshot transfer.** A stale response that raced with a forced reconnect could leave the leader probing the log of a follower backwards, one entry per round trip, below the index covered by the snapshot that the follower had just installed. In production this lasted about 15 minutes, until log compaction forced another snapshot. A per-peer floor, `next_log_idx_floor_`, now bounds the probing.
* [#106](https://github.com/ClickHouse/NuRaft/pull/106), 2026-05-21. **Data race on `cmd_result::code_`.** `set_result` wrote `code_` outside the lock that protects it in every other method. Found by TSan.
* [#107](https://github.com/ClickHouse/NuRaft/pull/107), 2026-05-19. Follow-up to #101: a follower decided on its own to pipeline responses, which a leader of an older version cannot handle, so a rolling upgrade required a specific order of nodes. The leader now requests pipelining with a flag in the request. The patch also fixes a deadlock by moving the pending responses under a dedicated mutex.
* [#109](https://github.com/ClickHouse/NuRaft/pull/109), 2026-05-21. **Log probing below the snapshot of a follower.** When the next index that the leader kept for a follower was below what the follower had compacted into its snapshot, the hint in the rejection did not move the leader forward, and the leader stepped further back. The follower now reports its snapshot boundary and the leader continues from it.
* [#115](https://github.com/ClickHouse/NuRaft/pull/115), 2026-06-01. Follow-up to #98 and #114: with the limit on uncommitted entries, the leader could reject one pipelined request and accept the next one, so `client_req_stream` skipped entries. The connection is now closed after the first rejected request.
* [#116](https://github.com/ClickHouse/NuRaft/pull/116), 2026-06-01. Follow-up to #101: a follower deferred the response to an `append_entries` request without entries until its log was durable. In ClickHouse Keeper this is a circular wait at startup, and leader election could get stuck. The patch also fixes a lost wake-up between checking the durable index and registering the pending response.
* [#137](https://github.com/ClickHouse/NuRaft/pull/137), 2026-11-04. **Committed entries could be rolled back.** On an `append_entries` request that conflicts with the local log at or below the commit index, the original code lowers both commit indexes and rolls back committed entries. This happens when an invalid leader, for example a node restarted with an empty data directory, sends such a request. The request is now refused, and the application is notified with the new `RejectedCommittedLogRollback` callback.
* [#141](https://github.com/ClickHouse/NuRaft/pull/141), 2026-11-09. Follow-up to #137: after the refusal, the follower still accepted the next request of the same term and restarted its election timer, so the cluster kept the invalid leader. All `append_entries` requests of that term are now refused.
* [#145](https://github.com/ClickHouse/NuRaft/pull/145), 2026-11-24. **Endless resending of a snapshot in stream mode.** In stream mode the next request is built from the last streamed index. When the leader compacted its log past that index, it could only send a snapshot, and nothing reset the position of the stream. The leader sent the same snapshot again on every heartbeat, the follower declined it, and replication to that follower stalled.
* [#155](https://github.com/ClickHouse/NuRaft/pull/155), 2026-11-26. **A committed entry could be lost.** `become_leader` reset every per-peer replication field except `matched_idx_`. A value left from an earlier leadership of the same server let the new leader count a peer as holding entries that the peer did not have, and commit an entry stored on fewer than a majority of servers. A later leader could then overwrite it.

### Snapshots

* [#47](https://github.com/ClickHouse/NuRaft/pull/47), 2022-08-29. **Segmentation fault during the installation of a snapshot.** A follower compacted its log while the background commit thread was reading entries from the same range. `entry_at` returned a null pointer, which was dereferenced. The state machine is now paused during the installation. Accepted upstream as [eBay/NuRaft#373](https://github.com/eBay/NuRaft/pull/373).
* [#77](https://github.com/ClickHouse/NuRaft/pull/77), 2024-10-07. **Snapshots created too early.** `snapshot_and_compact` read the last snapshot before it acquired the flag that marks a snapshot in progress, so the distance check could use a stale value and start a new snapshot right after another thread finished one. Accepted upstream as [eBay/NuRaft#539](https://github.com/eBay/NuRaft/pull/539).
* [#96](https://github.com/ClickHouse/NuRaft/pull/96), 2026-03-19. **The leader terminated its own process.** The per-peer flag `snapshot_sync_is_needed_` could stay set after the peer had caught up with the last snapshot of the leader or passed it. The leader then called `create_sync_snapshot_req`, which found no suitable snapshot and called `system_exit`. Both cases are now recoverable.
* [#118](https://github.com/ClickHouse/NuRaft/pull/118), 2026-06-15. **Livelock of snapshot installation with background snapshot I/O.** While the read of the first snapshot object was queued, the append cycle of the leader could replace or clear the context of the transfer. The acknowledgement from the follower was then dropped, and the transfer restarted from the first object forever. Found in production on a cluster that creates snapshots frequently. One of the two causes was the recovery branch added by #96.
* [#121](https://github.com/ClickHouse/NuRaft/pull/121), 2026-08-10. **A late acknowledgement of a snapshot was dropped.** The leader destroys the context of a transfer when one round trip exceeds the timeout, and the last round trip includes the follower applying the whole snapshot. The successful final response then found no context and was dropped, the leader never learned the position of the follower, and the follower stayed out of the quorum, in production for 17.5 minutes. The acknowledgement now carries the index of the installed snapshot.
* [#144](https://github.com/ClickHouse/NuRaft/pull/144), 2026-11-30. **A snapshot transfer started after shutdown.** A response handled after `shutdown` had released the snapshot contexts could start a new transfer, and nothing released its context. Found by LeakSanitizer.

### Leader election and leadership transfer

* [#70](https://github.com/ClickHouse/NuRaft/pull/70), 2024-02-21. **Process exit after repeated pre-vote rejections.** Removed the code in `handle_prevote_resp` that calls `send_reconnect_request` after a quorum has rejected the pre-vote `pre_vote_rejection_limit_` times. That function terminates the process with `N22_unrecoverable_isolation` when the leader is not known.
* [#85](https://github.com/ClickHouse/NuRaft/pull/85), 2025-04-08. **`busy_connection_limit_` could not be changed.** The field was missing from `raft_server::limits::operator=`, so `set_raft_limits` never changed it. The limit decides when a node gives up after repeated pre-vote failures on busy connections. Accepted upstream as [eBay/NuRaft#587](https://github.com/eBay/NuRaft/pull/587).
* [#91](https://github.com/ClickHouse/NuRaft/pull/91), 2026-03-09. **Segmentation fault when a server became the leader.** A server that hears nothing from the leader after being removed calls `cancel_schedulers`, which shuts down every peer and resets its heartbeat task. If the server later became the leader, `enable_hb_for_peer` scheduled a null task. The peers are now reopened. The original library fixed the same problem later and differently in [eBay/NuRaft#645](https://github.com/eBay/NuRaft/pull/645).
* [#92](https://github.com/ClickHouse/NuRaft/pull/92), 2026-03-18. Follow-up to #91: heartbeats were enabled before the peer was reopened, which does nothing for a peer that is shut down, so the heartbeats to a reopened peer stopped after the first one.
* [#99](https://github.com/ClickHouse/NuRaft/pull/99), 2026-04-08. **`request_leadership` silently did nothing.** The request was sent through the peer object of the leader without checking that its RPC client was usable. With a broken connection nothing was sent, and the function still returned `true`.
* [#100](https://github.com/ClickHouse/NuRaft/pull/100), 2026-04-09. Follow-up to #99: the reconnect ran after the peer was marked as busy, and its result was ignored. The reconnect now runs first, and the function returns `false` if it fails.

### Cluster membership changes

ClickHouse Keeper allows removing a server from a cluster and adding it back while its process keeps running. A new ClickHouse Keeper node takes its initial cluster configuration from its configuration file, so it can already list several servers before it joins a cluster. After a restart, a node restores the latest configuration from its snapshot or log instead. The original library refuses a join request on a server whose configuration already lists several servers, so the fork disables that check (#80). The fixes from #129 to #135 make the join path correct for a server that already was a member.

* [#80](https://github.com/ClickHouse/NuRaft/pull/80), 2024-11-28. Two changes after a synchronization with the original library. A response with a result code and without a context was read as a response with an empty context, which is not the same as no context; accepted upstream as [eBay/NuRaft#555](https://github.com/eBay/NuRaft/pull/555). The check that refuses a join request on a server whose configuration already lists more than one server is disabled, because it prevented adding nodes to a ClickHouse Keeper cluster.
* [#123](https://github.com/ClickHouse/NuRaft/pull/123), 2026-08-13. **A new server never joined with background snapshot I/O.** `sync_log_to_new_srv` chose how to dispatch by the I/O mode, not by what it had prepared. With `use_bg_thread_for_snapshot_io_`, the log synchronization request was created and never sent, and the configuration change was never committed.
* [#129](https://github.com/ClickHouse/NuRaft/pull/129), 2026-09-08. **The commit index was rewound on a rejoin.** Accepting a join request wrote the commit index captured at startup back into the server. A server that was removed and added back without a restart got its commit index rewound below what its state machine had applied, and the leader replayed applied entries, which ClickHouse Keeper rejects with a logical error exception. Found in production.
* [#130](https://github.com/ClickHouse/NuRaft/pull/130), 2026-09-16. **A server that rejoined could not request votes.** The peers kept their busy flags from before the removal, so the server could not send vote requests in a later election. The RPC clients of busy peers are recreated on a join. Replaced by #135.
* [#131](https://github.com/ClickHouse/NuRaft/pull/131), 2026-09-17. **Responses from replaced connections were still processed.** A response from an RPC client that had been replaced, or from a peer removed from the configuration, was logged as stale and still delivered to `raft_server`. A delayed pre-vote response could start an election while the server was catching up. Such responses are now dropped.
* [#132](https://github.com/ClickHouse/NuRaft/pull/132), 2026-09-17. Three fixes of the rejoin sequence. A late callback from a replaced RPC client could release the busy flag of a request sent through the new client, which is a follow-up to #120 and #130. The RPC clients of all peers are recreated on a join, because #130 missed a client with a callback in flight. The peer object of an abandoned join was not shut down, so its pending response updated the progress of a different joining server.
* [#133](https://github.com/ClickHouse/NuRaft/pull/133), 2026-09-18. **A late response of a finished join affected the next join.** After a join completed, its temporary peer object was released without being shut down, and a delayed response was applied to the server added by a later join.
* [#135](https://github.com/ClickHouse/NuRaft/pull/135), 2026-09-21. **State from before the removal survived a rejoin.** Peers that were shut down while the server was removed could not be reconnected, the pending self-removal was not cancelled, and the leave state in `srv_to_leave_`, `config_changing_`, and `uncommitted_config_` was kept. A later election could be blocked, and a later removal could be built from a stale configuration. On a join, every retained peer is now replaced by a new object, which replaces the mechanism of #130 and #132.
* [#136](https://github.com/ClickHouse/NuRaft/pull/136), 2026-11-30. **A newly joined server removed itself after being elected.** If a server that had just joined was elected before it applied the configuration entry that adds it, `become_leader` stopped scanning its log at the first older configuration entry and appended a configuration without itself. The followers then removed it, and it led a cluster that it was not a member of. The early stop came from #37. The patch also fixes `config_changing_` being cleared too early and a catch-up flag that stayed set on a server that became the leader.

### Network transport and RPC

* [#4](https://github.com/ClickHouse/NuRaft/pull/4), 2021-02-01. **Data races on `peer::config_` and on the timer duration.** `peer::config_` was replaced and read without a common lock, and so was `timer_helper::duration_us_`. The timer part is in the original library since [eBay/NuRaft#217](https://github.com/eBay/NuRaft/pull/217).
* [#12](https://github.com/ClickHouse/NuRaft/pull/12), 2021-03-25. **Sending a request modified a shared log entry.** `asio_rpc_client::send` reset the read position of the buffer of a log entry before copying it, and the buffer is shared with other threads. The patch also replaces the two layouts of the buffer header with one.
* [#14](https://github.com/ClickHouse/NuRaft/pull/14), 2021-04-03. Follow-up to #5: the timeout of a forwarded request was dropped on the paths that connect, perform the SSL handshake, or retry before sending.
* [#54](https://github.com/ClickHouse/NuRaft/pull/54), 2023-01-24. **Data race in `asio_rpc_listener`.** `stop` closed the acceptor while a worker thread was using it in `handle_accept`. Found by TSan. Accepted upstream, together with #55, as [eBay/NuRaft#392](https://github.com/eBay/NuRaft/pull/392).
* [#55](https://github.com/ClickHouse/NuRaft/pull/55), 2023-01-25. **Data race on the handler of `asio_rpc_listener`.** `handler_` was written by `listen` and by `shutdown` while worker threads copied it into new sessions. The lock from #54 now protects it too.
* [#75](https://github.com/ClickHouse/NuRaft/pull/75), 2024-08-02. **Worker threads were not joined if the creation of a thread failed.** If the creation of one of the worker threads threw an exception, the constructor of `asio_service_impl` exited without stopping and joining the threads that were already running. Accepted upstream as [eBay/NuRaft#525](https://github.com/eBay/NuRaft/pull/525).
* [#81](https://github.com/ClickHouse/NuRaft/pull/81), 2024-11-29. **Data race on the connection timer.** The timeout timer was armed after `async_connect` had been started, concurrently with the completion handler that cancels it. Accepted upstream as [eBay/NuRaft#556](https://github.com/eBay/NuRaft/pull/556).
* [#83](https://github.com/ClickHouse/NuRaft/pull/83), 2024-12-03. **Custom SSL contexts were ignored with Boost.Asio.** The code for SSL contexts provided by the application is guarded by the `ASIO_VERSION` macro, which Boost.Asio does not define. In a build with Boost.Asio the code was compiled out, and the providers were silently ignored.
* [#103](https://github.com/ClickHouse/NuRaft/pull/103), 2026-05-06. **Rewrite of the send and receive paths of the RPC client.** In streaming mode, one timer was armed by the send path and cancelled by the receive path concurrently, two races could call the completion callback of a request twice, the client could get stuck after a recoverable error such as a CRC mismatch, and `ctx_read` ignored a read error and parsed the buffer. Found by running #101 under TSan. Sending and receiving now have separate timers and busy flags, and any error abandons the connection.
* [#108](https://github.com/ClickHouse/NuRaft/pull/108), 2026-05-20. **Reference cycle between the RPC client and its pending requests.** The response handler held a pointer to the RPC client that owned the handler, so the requests that were still queued at shutdown were never released. LeakSanitizer reported it after #103. The patch also fixes the SSL handshake handler, which captured a raw `this` pointer.
* [#119](https://github.com/ClickHouse/NuRaft/pull/119), 2026-06-14. **Data race on `peer::config_`.** Six places read `config_` without the mutex added by #4, concurrently with the commit of a configuration change. Found by TSan.
* [#128](https://github.com/ClickHouse/NuRaft/pull/128), 2026-09-08. **Four bugs found in one test run.** An exception from `remote_endpoint` on a connection that was reset right after `accept` left `handle_accept` before the acceptor was armed again, so the server never accepted another Raft connection and stayed a candidate until it was restarted. Nothing bounded the TCP connect and the SSL handshake of requests without a timeout, which are all Raft requests except forwarded client requests: a peer that never completed the handshake kept the request in flight forever, and the leader stopped replicating to it. The destructor of the RPC client read the options of the service after they had been destroyed, which was found by MSan. The timer handlers captured a raw `this` pointer and could run on a destroyed client.

### Startup and shutdown

* [#9](https://github.com/ClickHouse/NuRaft/pull/9), 2021-03-03. Follow-up to #6: the callback was raised only if the state machine started at index 0 or right before the start of the log, and not if it was restored from a snapshot at an index inside the log.
* [#32](https://github.com/ClickHouse/NuRaft/pull/32), 2021-12-15. Follow-up to #30: a duplicated argument of the startup log message shifted all the arguments after it, so an integer was formatted as `%s`, which is undefined behavior.
* [#42](https://github.com/ClickHouse/NuRaft/pull/42), 2022-07-28. **Uninitialized `parallel_log_appending_`.** The new field of `raft_params` had no initializer, so the mode was indeterminate unless the application set it. Accepted upstream as [eBay/NuRaft#366](https://github.com/eBay/NuRaft/pull/366).
* [#49](https://github.com/ClickHouse/NuRaft/pull/49), 2022-09-02. **Shutdown waited for all pending commits.** The commit loop did not check `stopping_`, so a shutdown during the commit of a long log, for example at startup, waited for the whole log. The patch also removes the limit of 1 GiB on the size of a request: a larger request was treated as corrupted and the connection was closed, and a large snapshot exceeds it.
* [#52](https://github.com/ClickHouse/NuRaft/pull/52), 2022-12-02. Defensive check: a notification about a completed log append that arrives after the shutdown has started is ignored.
* [#86](https://github.com/ClickHouse/NuRaft/pull/86), 2025-07-07. **Requests were processed after the shutdown had started.** `process_req` checked `stopping_` only before it acquired `lock_`. A request that waited for the lock during `shutdown` was still processed after it. The flag is now checked again under the lock.

### Features added for ClickHouse Keeper

Replication and backpressure:

* [#69](https://github.com/ClickHouse/NuRaft/pull/69), 2024-02-20. `log_store::is_conf`, so that the search for configuration entries at startup and in `become_leader` does not load every log entry.
* [#88](https://github.com/ClickHouse/NuRaft/pull/88), 2025-11-17. `max_append_size_bytes_`, a limit on the size of one `append_entries` request in bytes.
* [#98](https://github.com/ClickHouse/NuRaft/pull/98), 2026-05-06. `client_req_stream`, pipelined forwarding of client requests from a follower to the leader over one connection, with the guarantee that the entries are committed in order and without gaps.
* [#101](https://github.com/ClickHouse/NuRaft/pull/101), 2026-05-06. Asynchronous log appending on a follower: the follower does not block on every `append_entries` request until the log is durable, and responds when it is.
* [#110](https://github.com/ClickHouse/NuRaft/pull/110), 2026-05-22. `client_req_stream` passes requests to a leader on the same node directly, without the network.
* [#113](https://github.com/ClickHouse/NuRaft/pull/113), 2026-05-29. A limit on backward probing: after several rejected probes, the leader sends one log entry per request instead of a full batch.
* [#114](https://github.com/ClickHouse/NuRaft/pull/114), 2026-05-29. `max_uncommitted_log_entries_`, with which the leader rejects client requests while too many entries are not committed.
* [#120](https://github.com/ClickHouse/NuRaft/pull/120), 2026-08-10. A peer identifier in `log_entries_ext` and the new `entry_at_ext`, for the per-peer read-ahead of the log in ClickHouse Keeper. The busy flag of a peer is now released after its position is updated, so that a concurrent request does not send the same range of the log twice.
* [#126](https://github.com/ClickHouse/NuRaft/pull/126), 2026-09-10. Backpressure for a slow member: the leader can hold back the commit index for the slowest reachable member, so that the member catches up. The patch also fixes two defects of the original code: `limits::operator=` did not copy two fields, and a response to a custom notification could move the next index of a peer backwards.
* [#127](https://github.com/ClickHouse/NuRaft/pull/127), 2026-09-10. `log_entry::user_data` and the log entry in `ext_op_params`, so that ClickHouse Keeper passes deserialized entries to the state machine.

Callbacks and integration:

* [#6](https://github.com/ClickHouse/NuRaft/pull/6), 2021-02-19. The `InitialBatchCommited` callback, raised when the entries that were in the log at startup are committed.
* [#16](https://github.com/ClickHouse/NuRaft/pull/16), 2021-04-07. `start_server`, to construct a server first and start it later. Accepted upstream as [eBay/NuRaft#195](https://github.com/eBay/NuRaft/pull/195).
* [#19](https://github.com/ClickHouse/NuRaft/pull/19), 2021-04-16. `cmd_result::has_result`.
* [#40](https://github.com/ClickHouse/NuRaft/pull/40), 2022-06-17. The `PreAppendLog` callback, raised on the leader before a log entry is stored. It is used for the calculation of digests.
* [#43](https://github.com/ClickHouse/NuRaft/pull/43), 2022-08-03. The `AppendLogFailed` callback, raised when the log store throws an exception, so that the application can undo what it prepared.
* [#44](https://github.com/ClickHouse/NuRaft/pull/44), 2022-08-04. `commit_in_bg` is virtual, so that ClickHouse Keeper can wrap the commit thread.
* [#61](https://github.com/ClickHouse/NuRaft/pull/61), 2023-06-10. The `PreAppendLogFollower` callback, raised on a follower before a log entry is stored.
* [#73](https://github.com/ClickHouse/NuRaft/pull/73), 2024-04-02. The threads of the library can run in the thread pool of ClickHouse.

Leadership and configuration:

* [#5](https://github.com/ClickHouse/NuRaft/pull/5), 2021-02-08. A timeout for the requests that a follower forwards to the leader. The original library had none. Accepted upstream, together with #14, as [eBay/NuRaft#191](https://github.com/eBay/NuRaft/pull/191).
* [#37](https://github.com/ClickHouse/NuRaft/pull/37), 2022-04-25. A configuration set by the application takes priority over older uncommitted configuration entries when a server becomes the leader. It is used for the recovery of a cluster that lost its quorum.
* [#46](https://github.com/ClickHouse/NuRaft/pull/46), 2022-09-15. The `leader_status_request` message, which the leader answers with its term and commit index.
* [#89](https://github.com/ClickHouse/NuRaft/pull/89), 2026-03-10. Any node can ask the leader to transfer leadership to any node, and `set_priority_v2` forwards a priority change to the leader instead of broadcasting it.

Networking and limits:

* [#10](https://github.com/ClickHouse/NuRaft/pull/10), 2021-03-10. The listener accepts IPv6 connections. The original library listens on IPv4 only.
* [#17](https://github.com/ClickHouse/NuRaft/pull/17), 2021-04-12. Options to use the default certificate authorities and to omit the root certificate file. No longer in effect since #72.
* [#23](https://github.com/ClickHouse/NuRaft/pull/23), 2021-06-17. 64-bit buffer sizes. The original library throws an exception for a buffer of 2 GiB or more, and a ClickHouse Keeper snapshot can be larger.
* [#28](https://github.com/ClickHouse/NuRaft/pull/28), 2021-10-22. The `SO_REUSEADDR` option on the listener socket.
* [#35](https://github.com/ClickHouse/NuRaft/pull/35), 2022-01-07. A switch between IPv4 and IPv6. Since #10 the listener always opened an IPv6 socket, and ClickHouse Keeper did not start on a host with IPv6 disabled.
* [#45](https://github.com/ClickHouse/NuRaft/pull/45), 2022-08-17. Several listeners, each bound to a given address.
* [#56](https://github.com/ClickHouse/NuRaft/pull/56), 2023-04-12. SSL contexts provided by the application for the client and server sides. Accepted upstream as [eBay/NuRaft#412](https://github.com/eBay/NuRaft/pull/412).

### Logging and diagnostics

* [#11](https://github.com/ClickHouse/NuRaft/pull/11), 2021-03-25. The message about a rollback of the commit index of the state machine is logged as an error and says that it may indicate data loss. Accepted upstream as [eBay/NuRaft#186](https://github.com/eBay/NuRaft/pull/186).
* [#29](https://github.com/ClickHouse/NuRaft/pull/29), 2021-12-14. The message about a failure to create a listener contains the port.
* [#30](https://github.com/ClickHouse/NuRaft/pull/30), 2021-12-14. Clearer messages at the start of a server.
* [#38](https://github.com/ClickHouse/NuRaft/pull/38), 2022-04-28. The message about a CRC mismatch contains the header of the request and the address of the peer.
* [#39](https://github.com/ClickHouse/NuRaft/pull/39), 2022-04-28. The same message contains the header in hexadecimal form.
* [#48](https://github.com/ClickHouse/NuRaft/pull/48), 2023-04-11. The message about a failed installation of a snapshot contains the text of the exception.
* [#66](https://github.com/ClickHouse/NuRaft/pull/66), 2024-01-05. A new, most verbose log level for the messages logged on every request.
* [#125](https://github.com/ClickHouse/NuRaft/pull/125), 2026-08-27. Ten messages logged on every request are moved from the debug level to the trace level.
* [#140](https://github.com/ClickHouse/NuRaft/pull/140), 2026-11-06. Log messages do not contain pointers. Heap addresses in the log defeat address space layout randomization for anyone who can read the log.

### Build, portability, and tests

* [#20](https://github.com/ClickHouse/NuRaft/pull/20), 2021-04-28. Build on illumos.
* [#26](https://github.com/ClickHouse/NuRaft/pull/26), 2021-07-29. A public header included a private one, `event_awaiter.h`, so an application could not compile it. The header is moved to the public directory.
* [#34](https://github.com/ClickHouse/NuRaft/pull/34), 2021-12-23. Build with Boost 1.78 without an SSL library.
* [#68](https://github.com/ClickHouse/NuRaft/pull/68), 2024-01-11. Removed the `regex` include and the dead code that used `std::regex`.
* [#74](https://github.com/ClickHouse/NuRaft/pull/74), 2024-04-04. Renamed the thread type introduced by #73.
* [#94](https://github.com/ClickHouse/NuRaft/pull/94), 2026-03-18. Removed the `asio` submodule.
* [#97](https://github.com/ClickHouse/NuRaft/pull/97), 2026-03-19. A test for the recovery from a missing snapshot added by #96.
* [#124](https://github.com/ClickHouse/NuRaft/pull/124), 2026-08-17. The test added by #123 fails on a timeout instead of ignoring it.
* [#142](https://github.com/ClickHouse/NuRaft/pull/142), 2026-11-09. The coverage build works with `lcov` 2.4.

### Synchronization with the original library

* [#2](https://github.com/ClickHouse/NuRaft/pull/2), 2021-01-31. A branch of the maintainer of the original library that adds the address of the RPC client to log messages.
* [#3](https://github.com/ClickHouse/NuRaft/pull/3), 2021-02-01. Merge of the original library, including its fix for clearing the busy flag of a peer without a lock.
* [#13](https://github.com/ClickHouse/NuRaft/pull/13), 2021-04-03. Merge of the original library, including the upstream versions of #7, #8, and #11.
* [#18](https://github.com/ClickHouse/NuRaft/pull/18), 2021-04-16. Merge of the original library, including the upstream versions of #5, #14, and #16.
* [#21](https://github.com/ClickHouse/NuRaft/pull/21), 2021-05-12. Merge of the original library.
* [#22](https://github.com/ClickHouse/NuRaft/pull/22), 2021-05-30. Merge of the original library.
* [#25](https://github.com/ClickHouse/NuRaft/pull/25), 2021-07-28. Merge of the original library, including background snapshot I/O and the API to pause the state machine.
* [#33](https://github.com/ClickHouse/NuRaft/pull/33), 2021-12-15. Merge of the original library.
* [#41](https://github.com/ClickHouse/NuRaft/pull/41), 2022-07-26. Merge of the original library, including parallel log appending.
* [#51](https://github.com/ClickHouse/NuRaft/pull/51), 2022-10-17. Merge of the original library, including the upstream versions of #42 and #47.
* [#58](https://github.com/ClickHouse/NuRaft/pull/58), 2023-04-11. Merge of the original library, including the upstream version of #54 and #55.
* [#59](https://github.com/ClickHouse/NuRaft/pull/59), 2023-04-12. Merge of the original library, the continuation of #58.
* [#63](https://github.com/ClickHouse/NuRaft/pull/63), 2023-06-29. The upstream change [eBay/NuRaft#432](https://github.com/eBay/NuRaft/pull/432): `set_priority` returns its status.
* [#65](https://github.com/ClickHouse/NuRaft/pull/65), 2023-09-13. The upstream change [eBay/NuRaft#470](https://github.com/eBay/NuRaft/pull/470): the `ServerJoinFailed` callback.
* [#72](https://github.com/ClickHouse/NuRaft/pull/72), 2024-04-02. Merge of the original library.
* [#76](https://github.com/ClickHouse/NuRaft/pull/76), 2024-10-04. Merge of the original library, including the upstream version of #75.
* [#84](https://github.com/ClickHouse/NuRaft/pull/84), 2025-02-18. Merge of the original library, including stream mode and the upstream versions of #77, #79, and #81.
* [#87](https://github.com/ClickHouse/NuRaft/pull/87), 2025-07-07. Merge of the original library, including the upstream version of #85.
* [#117](https://github.com/ClickHouse/NuRaft/pull/117), 2026-06-08. Merge of the original library. The same pull request contains three changes of our own: a snapshot that is already covered by the commit index is not applied, the user context of a snapshot is not released while the background thread reads from it, and `snapshot_io_mgr` can be shut down explicitly.
* [#150](https://github.com/ClickHouse/NuRaft/pull/150), 2026-11-26. The upstream fix [eBay/NuRaft#668](https://github.com/eBay/NuRaft/pull/668): after the whole log was compacted into a snapshot, the vote request handler compared the log of a candidate with term 0, so a candidate with a stale log could get the vote.
* [#168](https://github.com/ClickHouse/NuRaft/pull/168), 2026-11-27. The upstream fix [eBay/NuRaft#670](https://github.com/eBay/NuRaft/pull/670): in the blocking mode, the result of a client request was read again after the lock was released, so a request that timed out could be reported as successful with an empty value. ClickHouse Keeper does not use this mode.

Four more commits were pushed in 2021 without a pull request: a continuous integration workflow, a formatting change from the original library, the switch to C++17, and a build fix.
