[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for ClickHouse®](../index.md) > [Concepts](index.md) > Maintenance

# Maintenance in Managed Service for ClickHouse®

Maintenance in Managed Service for ClickHouse® includes:

* Automatic installation of DBMS updates and patches for hosts (including for stopped clusters).
* Scheduled [automatic storage expansion](storage.md#auto-rescale).
* Other maintenance activities.

A major DBMS version update is not part of maintenance. For more information about upgrading between major versions, see [ClickHouse® version upgrade](../operations/cluster-version-update.md).

## Maintenance window {#maintenance-window}

You can set the maintenance window when [creating a cluster](../operations/cluster-create.md) or [updating its settings](../operations/cluster-maintenance.md#set-maintenance-window):

* The **At any time** option (default) allows performing maintenance at any time.
* The **By schedule** option allows you to select the day of the week and UTC time when the maintenance will be performed. For example, you can choose a time when the cluster is least loaded.

{% note info %}

To view maintenance task information, you need the `managed-clickhouse.maintenanceTask.viewer` [role](../security.md#managed-clickhouse-maintenanceTask-viewer) or higher.

To manage maintenance tasks, you need the `managed-clickhouse.maintenanceTask.editor` [role](../security.md#managed-clickhouse-maintenanceTask-editor) or higher.

{% endnote %}

## Maintenance workflow {#maintenance-order}

The maintenance workflow for Managed Service for ClickHouse® clusters depends on the number of [shards](sharding.md) and hosts in them:

* In single-host clusters, maintenance is performed on a single ClickHouse® host. This means, if you restart such a cluster during maintenance, it will become unavailable.
* If a cluster consists of multiple ClickHouse® hosts in a single shard, [replica hosts](replication.md) undergo maintenance one by one. Such hosts are queued randomly. If you restart a host during maintenance, it will become unavailable for this time period. If you access a cluster using the [FQDN of the ClickHouse® host](network.md#hostname), the cluster may become unavailable. To make your application continuously available, access the cluster using a [special FQDN](../operations/connect/fqdn.md#auto) always pointing to the available host.
* If a cluster consists of multiple shards, maintenance is performed shard by shard in ascending order by shard number. Maintenance is first performed on the hosts of one shard, then four shards, and further on, in batches of 16 shards. Host maintenance is the same as in single-shard clusters. If you access a cluster shard using the FQDN of the ClickHouse® host, the shard may become unavailable. To make your application continuously available, access the shard using a [special FQDN](../operations/connect/fqdn.md#auto), always pointing to the available host in the shard.

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._