Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Managed Service for PostgreSQL
  • Getting started
    • All tutorials
      • Getting information on existing clusters
      • Creating a cluster
      • Updating cluster settings
      • Stopping and starting a cluster
      • Managing PostgreSQL hosts
      • Migrating hosts to a different availability zone
      • Managing replication slots
      • Managing backups
      • Managing backup policies
      • Managing disk space
      • Maintenance
      • Updating the PostgreSQL version
      • Deleting a cluster
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Set up alerts in Yandex Monitoring
  • Manually get the cluster out of the read-only mode
  • Changing the disk type and increasing the storage size
  • Setting up automatic increase of storage size
  1. Step-by-step tutorials
  2. Clusters
  3. Managing disk space

Managing disk space

Written by
Yandex Cloud
Updated at May 13, 2025
  • Set up alerts in Yandex Monitoring
  • Manually get the cluster out of the read-only mode
  • Changing the disk type and increasing the storage size
  • Setting up automatic increase of storage size

When the storage is more than 97% full, the host automatically switches to read-only mode.
To avoid issues with writing to the database, use one of the following methods:

  • Set up alerts in Yandex Monitoring to monitor storage utilization.

  • Manually get the cluster out of the read-only mode and free up the storage space by deleting some data.

  • Increase the storage size to automatically disable the read-only mode. You can also change the disk type.

  • Set up automatic storage size increase.

Set up alerts in Yandex MonitoringSet up alerts in Yandex Monitoring

  1. Navigate to the folder dashboard and select Monitoring.

  2. Select Managed Service for PostgreSQL.

  3. Create a notification channel.

  4. Create an alert with the following properties:

    1. Metrics: Set the following metric parameters:

      • Cloud

      • Folder

      • Managed Service for PostgreSQL service

      • Managed Service for PostgreSQL cluster ID

        You can get the cluster ID with the list of clusters in the folder.

      • disk.free_bytes label

    2. Alert condition: Set the Less than or equals condition for free disk space utilization percentage to trigger the alert:

      • Aggregation function: Minimum (minimum metric value for the period).
      • Warning: 90 (90% of the storage size).
      • Alarm: 95 (95% of the storage size).
      • Evaluation window: Preferred metric update period.
    3. Add the previously created notification channel.

Manually get the cluster out of the read-only modeManually get the cluster out of the read-only mode

Alert

Do not allow free disk space to drop to zero during the following actions. Otherwise, since the fail-safe mechanism is disabled, PostgreSQL will crash and the cluster will stop operating.

To disable the read-only mode:

  1. Connect to the database in any appropriate way.

  2. Open a transaction and run the following command inside it:

    SET LOCAL transaction_read_only TO off;
    
  3. As part of the same transaction, delete the data you do not need using the DROP or TRUNCATE operators. Do not use the DELETE operator, as it marks rows as deleted but does not physically delete them from the database.

  4. Commit the transaction and restart all connections to the database.

For example, if your database contains a table called ExcessDataTable1 that you no longer need, delete it using the following transaction:

BEGIN;
SET LOCAL transaction_read_only TO off;
DROP TABLE ExcessDataTable1;
COMMIT;

Changing the disk type and increasing the storage sizeChanging the disk type and increasing the storage size

Note

Some PostgreSQL settings depend on the storage size.

Make sure the cloud has enough quota to increase the storage size. Open the cloud's Quotas page and check the HDD storage capacity and SSD storage capacity lines under Managed Databases to make sure there is available quota for storage space.

Warning

  • You cannot decrease the storage size.
  • While resizing the storage, cluster hosts will be unavailable.
Management console
CLI
Terraform
REST API
gRPC API

To change the disk type and increase the storage size for a cluster:

  1. Navigate to the folder dashboard and select Managed Service for PostgreSQL.

  2. Select a cluster and click Edit in the top panel.

  3. Under Size of storage:

    • Select the disk type.
    • Specify the required disk size.
  4. Click Save changes.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To change the disk type and increase the storage size for a cluster:

  1. View the description of the CLI command to update the cluster:

    yc managed-postgresql cluster update --help
    
  2. Specify the disk type and required storage size in the cluster update command (at least as large as disk_size in the cluster properties):

    yc managed-postgresql cluster update <cluster_name_or_ID> \
        --disk-type <disk_type> \
        --disk-size <storage_size_in_GB>
    

To change the disk type and increase the storage size for a cluster:

  1. Open the current Terraform configuration file that defines your infrastructure.

    For more information about creating this file, see Creating clusters.

    For a complete list of available Managed Service for PostgreSQL cluster configuration fields, see the Terraform provider documentation.

  2. In the Managed Service for PostgreSQL cluster description, change the disk_type_id and disk_size attributes in the config.resources block:

    resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
      ...
      config {
        resources {
          disk_type_id = "<disk_type>"
          disk_size    = <storage_size_in_GB>
          ...
        }
      }
    }
    
  3. 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.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      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.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    Time limits

    A Terraform provider sets the timeout for Managed Service for PostgreSQL cluster operations:

    • Creating a cluster, including restoring from a backup: 30 minutes.
    • Editing a cluster: 60 minutes.
    • Deleting a cluster: 15 minutes.

    Operations exceeding the set timeout are interrupted.

    How do I change these limits?

    Add the timeouts block to the cluster description, for example:

    resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
      ...
      timeouts {
        create = "1h30m" # 1 hour 30 minutes
        update = "2h"    # 2 hours
        delete = "30m"   # 30 minutes
      }
    }
    
  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Update method and send the following request, e.g., via cURL:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

    curl \
      --request PATCH \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --header "Content-Type: application/json" \
      --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>' \
      --data '{
                "updateMask": "configSpec.resources.diskTypeId,configSpec.resources.diskSize",
                "configSpec": {
                  "resources": {
                    "diskTypeId": "<disk_type>",
                    "diskSize": "<storage_size_in_bytes>"
                  }
                }
              }'
    

    Where:

    • updateMask: List of parameters to update as a single string, separated by commas.

    • configSpec.resources: Storage parameters:

      • diskTypeId: Disk type.
      • diskSize: New storage size in bytes.

    You can request the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the ClusterService.Update call and send the following request, e.g., via gRPCurl:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the update_mask parameter as an array of paths[] strings.

    Format for listing settings
    "update_mask": {
        "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
        ]
    }
    
    grpcurl \
      -format json \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>",
            "update_mask": {
              "paths": [
                "config_spec.resources.disk_type_id",
                "config_spec.resources.disk_size"
              ]
            },
            "config_spec": {
              "resources": {
                "disk_type_id": "<disk_type>",
                "disk_size": "<storage_size_in_bytes>"
              }
            }
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.ClusterService.Update
    

    Where:

    • update_mask: List of parameters to update as an array of paths[] strings.

    • config_spec.resources: Storage parameters:

      • disk_type_id: Disk type.
      • disk_size: New storage size in bytes.

    You can request the cluster ID with the list of clusters in the folder.

  4. View the server response to make sure the request was successful.

Setting up automatic increase of storage sizeSetting up automatic increase of storage size

Note

Some PostgreSQL settings depend on the storage size.

Make sure the cloud has enough quota to increase the storage size. Open the cloud's Quotas page and check the HDD storage capacity and SSD storage capacity lines under Managed Databases to make sure there is available quota for storage space.

Warning

  • You cannot decrease the storage size.
  • While resizing the storage, cluster hosts will be unavailable.
Management console
CLI
REST API
gRPC API
  1. Navigate to the folder dashboard and select Managed Service for PostgreSQL.

  2. Select the cluster and click Edit in the top panel.

  3. Under Automatic increase of storage size:

    1. In the Increase size field, set the storage utilization percentage to trigger storage increase. You can configure the increase to take place:

      • During the next maintenance window.
      • Right away.

      You can enable both rules, but the threshold for immediate increase should be higher than that for increase during the maintenance window.

    2. In the Maximum storage size field, specify the maximum storage size that can be set when increasing the storage size automatically.

  4. Click Save changes.

If you do not have the Yandex Cloud (CLI) command line interface yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To set up automatic increase of storage size:

  1. View the description of the CLI command to update the cluster:

    yc managed-postgresql cluster update --help
    
  2. Set the maximum storage size and conditions for its increase in the update cluster command.

    Make sure the maximum storage size is greater than the disk_size value in the cluster properties. The percentage for immediate increase should be higher than that for increase during the next maintenance window.

    yc managed-postgresql cluster update <cluster_ID_or_name> \
        --disk-size-autoscaling disk-size-limit=<maximum_storage_size_in_bytes>,`
                               `planned-usage-threshold=<scheduled_increase_percentage>,`
                               `emergency-usage-threshold=<immediate_increase_percentage>
    

    If you have set up the storage size to increase within the maintenance window, set up a schedule for the maintenance window.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Use the Cluster.Update method and send the following request, e.g., via cURL:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

    curl \
      --request PATCH \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --header "Content-Type: application/json" \
      --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>' \
      --data '{
                "updateMask": "configSpec.diskSizeAutoscaling,maintenanceWindow",
                "configSpec": {
                  "diskSizeAutoscaling": {
                    "plannedUsageThreshold": "<scheduled_increase_percentage>",
                    "emergencyUsageThreshold": "<immediate_increase_percentage>",
                    "diskSizeLimit": "<maximum_storage_size_in_bytes>"
                  }
                },
                "maintenanceWindow": {
                  "weeklyMaintenanceWindow": {
                    "day": "<day_of_week>",
                    "hour": "<hour>"
                  }
                }
              }'
    

    Where:

    • updateMask: List of parameters to update as a single string, separated by commas.

      In this case, provide only configSpec.diskSizeAutoscaling and maintenanceWindow.

    • configSpec.diskSizeAutoscaling: Automatic storage size increase settings:

      • plannedUsageThreshold: Storage utilization percentage to trigger a storage increase during the next maintenance window.

        Use a percentage value between 0 and 100. The default value is 0 (automatic increase is disabled).

        If you have set this parameter, configure the maintenance window schedule in the maintenanceWindow parameter.

      • emergencyUsageThreshold: Storage utilization percentage to trigger an immediate storage increase.

        Use a percentage value between 0 and 100. The default value is 0 (automatic increase is disabled). This parameter value must be greater than or equal to plannedUsageThreshold.

      • diskSizeLimit: Maximum storage size, in bytes, that can be set when utilization reaches one of the specified percentages.

    • maintenanceWindow: Maintenance window schedule. It is required only if the plannedUsageThreshold parameter is set. Contains the following parameters:

      • day: Day of week, in DDD format, for scheduled maintenance.
      • hour: Hour, in HH format, for scheduled maintenance. The possible values range from 1 to 24.

    You can request the cluster ID with the list of clusters in the folder.

  3. View the server response to make sure the request was successful.

  1. Get an IAM token for API authentication and put it into the environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Use the ClusterService.Update call and send the following request, e.g., via gRPCurl:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the update_mask parameter as an array of paths[] strings.

    Format for listing settings
    "update_mask": {
        "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
        ]
    }
    
    grpcurl \
      -format json \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "cluster_id": "<cluster_ID>",
            "update_mask": {
              "paths": [
                "config_spec.disk_size_autoscaling",
                "maintenance_window"
              ]
            },
            "config_spec": {
              "disk_size_autoscaling": {
                "planned_usage_threshold": "<scheduled_increase_percentage>",
                "emergency_usage_threshold": "<immediate_increase_percentage>",
                "disk_size_limit": "<maximum_storage_size_in_bytes>"
              }
            },
            "maintenance_window": {
              "weekly_maintenance_window": {
                "day": "<day_of_week>",
                "hour": "<hour>"
              }
            }
          }' \
      mdb.api.cloud.yandex.net:443 \
      yandex.cloud.mdb.postgresql.v1.ClusterService.Update
    

    Where:

    • update_mask: List of parameters to update as an array of paths[] strings.

      In this case, provide only config_spec.disk_size_autoscaling and maintenance_window.

    • config_spec.disk_size_autoscaling: Automatic storage size increase settings:

      • planned_usage_threshold: Storage utilization percentage to trigger a storage increase during the next maintenance window.

        Use a percentage value between 0 and 100. The default value is 0 (automatic increase is disabled).

        If you have set this parameter, configure the maintenance window schedule in the maintenance_window parameter.

      • emergency_usage_threshold: Storage utilization percentage to trigger an immediate storage increase.

        Use a percentage value between 0 and 100. The default value is 0 (automatic increase is disabled). This parameter value must be greater than or equal to planned_usage_threshold.

      • disk_size_limit: Maximum storage size, in bytes, that can be set when utilization reaches one of the specified percentages.

    • maintenance_window: Maintenance window schedule. It is required only if the planned_usage_threshold parameter is set. Contains the following parameters:

      • day: Day of week, in DDD format, for scheduled maintenance.
      • hour: Hour, in HH format, for scheduled maintenance. The possible values range from 1 to 24.

    You can request the cluster ID with the list of clusters in the folder.

  4. View the server response to make sure the request was successful.

If the specified threshold is reached, the storage size increases differently depending on disk type:

  • For network HDDs and SSDs, by the higher of the two values: 20 GB or 20% of the current disk size.

  • For non-replicated SSDs and ultra high-speed network SSDs with three replicas, by 93 GB.

  • For local SSDs:

    • In an Intel Broadwell or Intel Cascade Lake cluster, by 100 GB.
    • Intel Ice Lake cluster, by 368 GB.

If the threshold is reached again, the storage size will be automatically increased until it reaches the specified maximum. After that, you can specify a new maximum storage size manually.

Was the article helpful?

Previous
Managing backup policies
Next
Maintenance
Yandex project
© 2025 Yandex.Cloud LLC