ReplicatedMergeTree table in self-managed ClickHouse doesn’t repeat the inserts and merges of the past. It downloads (fetches) the existing data parts from another replica. By default the fetches are not limited in bandwidth and up to 16 of them run in parallel, which can saturate the network or the disks of the replicas involved. To throttle the recovery, limit the fetch speed on the recovering replica, the send speed on the source replicas, or the number of parallel fetches.
What a recovering replica does
When a replica is created empty or restored after data loss (see Recovery after failures), it puts oneGET_PART entry for every part of a source replica into its replication queue. Check the queue on the recovering server:
GET_PART. A small number of MERGE_PARTS or MUTATE_PART entries can appear as well.
Settings that throttle the fetches
The server settings go to the top level of the server configuration, for example into a file in
config.d. This example limits the fetches of the server to 50 MiB per second and to four at a time:
background_fetches_pool_size can’t be lowered while the server runs. Put the limits in place before you start the server that is going to recover, or restart it.
The table-level settings can be given in the SETTINGS clause of CREATE TABLE, changed with ALTER TABLE, or set for all tables in the merge_tree section of the server configuration:
Pause the fetches without a restart
To stop the fetches for a while, for example during peak hours, useSYSTEM STOP FETCHES on the recovering replica, for one table or for all tables. The queue entries are kept and are executed after SYSTEM START FETCHES:
Monitor the recovery
The fetches that are running now are listed insystem.replicated_fetches:
postpone_reason column of system.replication_queue, for example: