> ## 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.

# Error 341 UNFINISHED: mutation is not finished because some replicas are inactive

> Why a synchronous ALTER TABLE ... UPDATE or DELETE ends with error 341 UNFINISHED when a replica is not running, and how to wait only for the active replicas with mutations_sync = 3.

The mutation was accepted and keeps running. Only the synchronous wait gave up: `mutations_sync = 2` asks the query to wait for every replica of the table, and one of them is not active. To wait only for the replicas that are running, use `mutations_sync = 3`.

## The error

A statement such as

```sql theme={null}
ALTER TABLE db.events UPDATE status = 'archived' WHERE event_date < '2026-01-01'
SETTINGS mutations_sync = 2;
```

ends with:

```text theme={null}
Code: 341. DB::Exception: Mutation is not finished because some replicas are inactive right now: <replica names>. Mutation will be done asynchronously. (UNFINISHED)
```

The message names replicas of the table that are registered in ClickHouse Keeper but are not active at the moment. On a `ReplicatedMergeTree` table it does not have to name all of them, because the wait stops at the first inactive replica.

## What happened to the mutation

The server creates the mutation first and waits afterwards. When the wait cannot be completed, the mutation is neither cancelled nor rolled back: the active replicas apply it, and an inactive replica applies it when it becomes active again.

Do not submit the statement again because of this error. That would create a second mutation. Check the progress instead:

```sql theme={null}
SELECT mutation_id, command, is_done, parts_to_do, latest_fail_reason
FROM system.mutations
WHERE database = 'db' AND table = 'events'
ORDER BY create_time DESC
LIMIT 5;
```

## Which statements wait for replicas

Three settings control the wait, one for each kind of statement:

| Statement | Setting | Default |
| - | - | - |
| `ALTER TABLE ... UPDATE`, `ALTER TABLE ... DELETE` and other mutations | [`mutations_sync`](https://clickhouse.com/docs/reference/settings/session-settings/mutations#mutations_sync) | `0` |
| Lightweight `DELETE FROM` | [`lightweight_deletes_sync`](https://clickhouse.com/docs/reference/settings/session-settings/lightweight#lightweight_deletes_sync) | `2` (ClickHouse Cloud: `1`) |
| Other `ALTER` queries, `OPTIMIZE`, `TRUNCATE` | [`alter_sync`](https://clickhouse.com/docs/reference/settings/session-settings/alter#alter_sync) | `1` (ClickHouse Cloud: `0`) |

They take the same values:

| Value | Meaning |
| - | - |
| `0` | Do not wait. |
| `1` | Wait for the server that runs the query. |
| `2` | Wait for all replicas. |
| `3` | Wait only for the active replicas. Inactive replicas apply the change when they become active. |

Because `lightweight_deletes_sync` is `2` by default in self-managed ClickHouse, a plain `DELETE FROM` on a replicated table ends with this error whenever a replica is inactive, although you did not change any setting.

With `alter_sync = 2` the query first waits for the inactive replicas for [`replication_wait_for_inactive_replica_timeout`](https://clickhouse.com/docs/reference/settings/session-settings/other#replication_wait_for_inactive_replica_timeout) seconds (120 by default). Then it fails with the same error code and a different message: `Timeout exceeded while waiting for replicas ... to process entry ... Probably some replicas are inactive`.

## Wait only for the active replicas

Set the value `3` for the setting that matches the statement:

```sql theme={null}
ALTER TABLE db.events UPDATE status = 'archived' WHERE event_date < '2026-01-01'
SETTINGS mutations_sync = 3;

DELETE FROM db.events WHERE event_date < '2025-01-01'
SETTINGS lightweight_deletes_sync = 3;

ALTER TABLE db.events ADD COLUMN source String
SETTINGS alter_sync = 3;
```

The query returns when all replicas that are active have applied the change, and it does not fail because of the others. You can also set the value for the session or in a settings profile. If it is enough that the server you are connected to has applied the change, use `1`.

> [!NOTE]
>
> On `ReplicatedMergeTree` tables, the value `3` waits only for the active replicas starting from ClickHouse 26.10. In 26.9 it behaved like `2`, and in earlier versions it did not wait at all.

## Bring back or remove the inactive replica

In self-managed ClickHouse, an inactive replica is a server that is stopped or cannot reach ClickHouse Keeper, a detached table, or a replica that was decommissioned without removing its registration. The `replica_is_active` column of [`system.replicas`](https://clickhouse.com/docs/reference/system-tables/replicas) maps every replica of a table to `1` or `0`:

```sql theme={null}
SELECT database, table, replica_is_active
FROM system.replicas
WHERE database = 'db' AND table = 'events';
```

Start the replica again, or, if it will never come back, remove its registration with [`SYSTEM DROP REPLICA`](https://clickhouse.com/docs/reference/statements/system#drop-replica).

## ClickHouse Cloud

With the ClickHouse Cloud defaults listed above, a statement waits for all replicas only if a query, a session, a settings profile or a client tool sets the value `2`.

Replicas in ClickHouse Cloud are not always running. Services [idle](https://clickhouse.com/docs/products/cloud/features/autoscaling/idling.md), and in a [warehouse](https://clickhouse.com/docs/products/cloud/features/infrastructure/warehouses.md) several services with their own replicas share the same tables and the same ClickHouse Keeper. The warehouses page describes a related case, in which `CREATE`, `RENAME` and `DROP DATABASE` queries can be blocked by idle or stopped services. If the replicas named in the error message are not running at the moment, use the value `3`: the statement waits for the replicas that are running, and the others apply the change when they become active.

## Related pages

* [Synchronicity of `ALTER` queries](https://clickhouse.com/docs/reference/statements/alter/index#synchronicity-of-alter-queries)
* [`system.mutations`](https://clickhouse.com/docs/reference/system-tables/mutations)
