[Yandex Cloud documentation](../../index.md) > [Yandex MPP Analytics for PostgreSQL](../index.md) > [Step-by-step guides](index.md) > Clusters > Maintenance

# Yandex MPP Analytics for PostgreSQL cluster maintenance

You can manage [maintenance](../concepts/maintenance.md) of a Yandex MPP Analytics for PostgreSQL cluster.

## Getting a list of maintenance jobs {#list-maintenance}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
  1. Click the cluster name and open the ![image](../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Optionally, select a maintenance status above the maintenance list.

{% endlist %}

## Getting cluster maintenance logs {#maintenance-logs}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
  1. Click the cluster name and open the ![image](../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Select the maintenance. The maintenance page will open.
  1. Click **Task logs**.

{% endlist %}

## Postponing scheduled maintenance {#postpone-planned-maintenance}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
  1. Click the cluster name and open the ![image](../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Click ![image](../../_assets/console-icons/ellipsis.svg) next to the maintenance with the **Planned** status and select ![image](../../_assets/console-icons/arrow-uturn-cw-right.svg) **Postpone**.
  1. Select the reschedule type for the planned maintenance:
    
      * **Next window**: Reschedule to the next maintenance window.
      * **Choose date (UTC)**: Reschedule to a specific date and time interval (UTC).

        For this option, select the date and UTC time interval.

        Maintenance can be postponed for a maximum of two weeks from the original scheduled date.
  
  1. Click **Reschedule**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To postpone scheduled maintenance:
    
  1. View the description of the CLI command for rescheduling maintenance:
    
      ```bash
      yc managed-greenplum cluster reschedule-maintenance --help
      ```
  
  1. Reschedule the maintenance:
    
      ```bash
      yc managed-greenplum cluster reschedule-maintenance <cluster_name_or_ID> \
        --reschedule-type <reschedule_type>
      ```
    
      Where `reschedule_type` is reschedule type:
    
      * `next-available-window`: Next available maintenance window.
      * `specific-time`: Specific date and time, UTC.
        
        For this value, also use the `--delayed-until` parameter to provide a timestamp in one of these formats:
    
        * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt).
        * HH:MM:SS.
        * Relative time to postpone maintenance for.
    
        > Here are some examples: `2006-01-02T15:04:05Z`, `15:04:05`, `2h`, `3h30m ago`.

        Maintenance can be postponed for a maximum of two weeks from the original scheduled date.
    
      You can get the cluster name and ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

- REST API {#api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:
      
      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```
  
  1. Call the [Cluster.RescheduleMaintenance](../api-ref/Cluster/rescheduleMaintenance.md) method, e.g., via the following [cURL](https://curl.se/) request:
  
      ```bash
      curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>:rescheduleMaintenance' \
        --data '{
                 "rescheduleType": "<reschedule_type>"
               }'
      ```

      Where `reschedule_type` is reschedule type:
    
      * `NEXT_AVAILABLE_WINDOW`: Next available maintenance window.
      * `SPECIFIC_TIME`: Specific date and time, UTC.
        
        For this value, also use the `delayedUntil` parameter to provide a timestamp in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. Here is an example:

        > `2006-01-02T15:04:05Z`
    
        Maintenance can be postponed for a maximum of two weeks from the original scheduled date.
    
      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/Cluster/rescheduleMaintenance.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

  1. Call the [ClusterService.RescheduleMaintenance](../api-ref/grpc/Cluster/rescheduleMaintenance.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
  
      ```bash
      grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
             "cluster_id": "<cluster_ID>",
             "reschedule_type": "<reschedule_type>"
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.greenplum.v1.ClusterService.RescheduleMaintenance
      ```

      Where `reschedule_type` is reschedule type:
    
      * `NEXT_AVAILABLE_WINDOW`: Next available maintenance window.
      * `SPECIFIC_TIME`: Specific date and time, UTC.
        
        For this value, also use the `delayed_until` parameter to provide a timestamp in [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. Here is an example:

        > `2006-01-02T15:04:05Z`

        Maintenance can be postponed for a maximum of two weeks from the original scheduled date.
    
      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/grpc/Cluster/rescheduleMaintenance.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Starting scheduled maintenance immediately {#exec-planned-maintenance}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
  1. Click the cluster name and open the ![image](../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. In the maintenance row, click ![image](../../_assets/console-icons/ellipsis.svg) and select ![image](../../_assets/console-icons/triangle-right.svg) **Carry out now**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To start scheduled maintenance immediately, do the following:
    
  1. View the description of the CLI command for rescheduling maintenance:
    
      ```bash
      yc managed-greenplum cluster reschedule-maintenance --help
      ```
  
  1. Start scheduled maintenance immediately:
    
      ```bash
      yc managed-greenplum cluster reschedule-maintenance <cluster_name_or_ID> \
        --reschedule-type immediate
      ```
    
      You can get the cluster name and ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

- REST API {#api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:
      
      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```
  
  1. Call the [Cluster.RescheduleMaintenance](../api-ref/Cluster/rescheduleMaintenance.md) method, e.g., via the following [cURL](https://curl.se/) request:
  
      ```bash
      curl \
        --request POST \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>:rescheduleMaintenance' \
        --data '{
                 "rescheduleType": "IMMEDIATE"
               }'
      ```
    
      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/Cluster/rescheduleMaintenance.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

  1. Call the [ClusterService.RescheduleMaintenance](../api-ref/grpc/Cluster/rescheduleMaintenance.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
  
      ```bash
      grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
             "cluster_id": "<cluster_ID>",
             "reschedule_type": "IMMEDIATE"
           }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.greenplum.v1.ClusterService.RescheduleMaintenance
      ```
    
      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/grpc/Cluster/rescheduleMaintenance.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}

## Configuring a maintenance window {#set-maintenance-window}

{% list tabs group=instructions %}

- Management console {#console}

  1. Open the [folder dashboard](https://console.yandex.cloud).
  1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
  1. Click the cluster name and open the ![image](../../_assets/console-icons/bars-play.svg) **Maintenance** tab.
  1. Click ![image](../../_assets/console-icons/calendar.svg) **Configure the maintenance window** in the top-right corner of the page.
  1. Select a maintenance window:
    
      * **At any time**: Maintenance takes place at any time.
      * **By schedule**: Maintenance is scheduled for the selected day of the week and UTC time interval.

        For this type of maintenance, define the start of the maintenance window: select the day of the week and UTC time interval.

  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  To set a maintenance window:
    
  1. See the description of the CLI command for updating cluster settings:
    
      ```bash
      yc managed-greenplum cluster update --help
      ```
  
  1. Set up a maintenance window:
    
      ```bash
      yc managed-greenplum cluster update <cluster_name_or_ID> \
        --maintenance-window type=<maintenance_type>,`
                            `day=<day_of_week>,`
                            `hour=<hour>
      ```
    
      Where `type` is the maintenance type:

      * `anytime`: Any time (default).
      * `weekly`: On a schedule. For this value, also specify the following:
          * `day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
          * `hour`: Sequence number of UTC hour interval, from `1` to `24`.
      
            > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.
    
      You can get the cluster name and ID with the [list of clusters in the folder](cluster-list.md#list-clusters).


- Terraform {#tf}

  1. Open the current Terraform configuration file with the infrastructure plan.

      To learn how to create this file, see [Creating a cluster](cluster-create.md).

      For the complete list of configurable Yandex MPP Analytics for PostgreSQL cluster fields, see [this Terraform provider guide](../../terraform/resources/mdb_greenplum_cluster.md).

  1. To set up a [maintenance window](../concepts/maintenance.md#maintenance-window), add the `maintenance_window` section to the cluster description:
  
      ```hcl
      resource "yandex_mdb_greenplum_cluster" "<local_cluster_name>" {
        ...
        maintenance_window {
          type = "<maintenance_type>"
        }
        ...
      }
      ```

      Where `type` is the maintenance type:

      * `ANYTIME`: Any time (default).
      * `WEEKLY`: On a schedule. For this value, also specify the following:
        
        * `day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
        * `hour`: Hour of day (UTC), from `1` to `24`.

  1. Make sure the settings are correct.

      1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.
      1. Run this command:
      
         ```bash
         terraform validate
         ```
      
         Terraform will show any errors found in your configuration files.

  1. Confirm updating the resources.

      1. Run this command to view the planned changes:
      
         ```bash
         terraform plan
         ```
      
         If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.
      
      1. If everything looks correct, apply the changes:
         1. Run this command:
      
            ```bash
            terraform apply
            ```
      
         1. Confirm updating the resources.
         1. Wait for the operation to complete.

      {% note warning %}
      
      The Terraform provider limits the amount of time for all Yandex MPP Analytics for PostgreSQL cluster operations to complete to 120 minutes.
      
      Operations exceeding the set timeout are interrupted.
      
      {% cut "How do I change these limits?" %}
      
      Add the `timeouts` block to the cluster description, for example:
      
      ```hcl
      resource "yandex_mdb_greenplum_cluster" "<cluster name>" {
        ...
        timeouts {
          create = "1h30m" # 1 hour 30 minutes
          update = "2h"    # 2 hours
          delete = "30m"   # 30 minutes
        }
      }
      ```
      
      {% endcut %}
      
      {% endnote %}


- REST API {#api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:
      
      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```
  
  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:
  
      ```bash
      curl \
        --request PATCH \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-greenplum/v1/clusters/<cluster_ID>' \
        --data '{
                 "updateMask": "maintenanceWindow",
                 "maintenanceWindow": {
                   "weeklyMaintenanceWindow": {
                     "day": "<day_of_week>",
                     "hour": "<hour>"
                   }
                 }
               }'
      ```
    
      Where:

      * `updateMask`: Comma-separated string of settings to update.

        In this example, only the `maintenanceWindow` setting is provided.

        {% note warning %}

        When you update a cluster, all parameters of the object you are modifying will be reset to their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the `updateMask` parameter.

        {% endnote %}

      * `maintenanceWindow`: [Maintenance window](../concepts/maintenance.md#maintenance-window) settings. Provide one of these parameters:

        * `anytime`: Allows performing maintenance at any time; default option.
          
          This parameter is provided as an empty object: `"anytime": {}`.
        
        * `weeklyMaintenanceWindow`: Maintenance takes place once a week at the specified time:

          * `day`: Day of week in `DDD` format, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
          * `hour`: Time of day (UTC), from `1` to `24`.

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}
  
  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

      ```bash
      export IAM_TOKEN="<IAM_token>"
      ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.

  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:
  
      ```bash
      grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/greenplum/v1/cluster_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
             "cluster_id": "<cluster_ID>",
             "update_mask": {
               "paths": [
                 "maintenance_window"
               ]
             },
             "maintenance_window": {
               "weekly_maintenance_window": {
                 "day": "<day_of_week>",
                 "hour": "<hour>"
               }
             }
           }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.greenplum.v1.ClusterService.Update
      ```
    
      Where:

      * `update_mask`: List of settings to update as an array of strings (`paths[]`).

        {% cut "Format for listing settings" %}

        ```yaml
        "update_mask": {
          "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
          ]
        }
        ```

        {% endcut %}

        In this example, only the `maintenance_window` setting is provided.

        {% note warning %}

        When you update a cluster, all parameters of the object you are modifying will be reset to their defaults unless explicitly provided in the request. To avoid this, list the settings you want to change in the `update_mask` parameter.

        {% endnote %}

      * `maintenance_window`: [Maintenance window](../concepts/maintenance.md#maintenance-window) settings. Provide one of these parameters:

        * `anytime`: Allows performing maintenance at any time; default option.
          
          This parameter is provided as an empty object: `"anytime": {}`.

        * `weekly_maintenance_window`: Maintenance takes place once a week at the specified time:

          * `day`: Day of week in `DDD` format, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
          * `hour`: Time of day (UTC), from `1` to `24`.

      You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).
  
  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

{% endlist %}