tencent cloud

TencentDB for PostgreSQL

ModifyDBInstanceHAConfig

Download
Focus Mode
Font Size
Last updated: 2026-05-21 10:43:45

1. API Description

Domain name for API request: postgres.intl.tencentcloudapi.com.

This API is used to modify instance HA configuration info. Among them, HA configuration info includes:.

  • This API is used to configure conditions for allowing a secondary node to switch over to a primary node.
  • .
  • This API is used to configure conditions for using synchronous replication or async replication in semi-sync instances.
  • .

    A maximum of 20 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: ModifyDBInstanceHAConfig.
    Version Yes String Common Params. The value used for this API: 2017-03-12.
    Region Yes String Common Params. For more information, please see the list of regions supported by the product.
    DBInstanceId Yes String Instance ID. obtain through the api DescribeDBInstances.
    SyncMode Yes String Primary-Standby sync mode.
  • Semi-Sync: semi-sync
  • .
  • Async: asynchronous
  • .
    MaxStandbyLatency Yes Integer Maximum delayed data volume for high-availability standby server. switchover to primary node is allowed when backup node latency is less than or equal to this value and standby lag time is less than or equal to MaxStandbyLag.
  • Unit: byte.
  • .
  • Value range: [1073741824, 322122547200]
  • .
    MaxStandbyLag Yes Integer Maximum delay time for high-availability standby servers. a backup node can switchover to the primary node when its latency is less than or equal to this value and its data volume is less than or equal to MaxStandbyLatency.
  • Unit: s.
  • .
  • Value range: [5, 10]
  • .
    MaxSyncStandbyLatency No Integer Maximum data sync lag for standby server. If data lag of the standby node and the delay ime are both less than or equals to the values of MaxSyncStandbyLatency and MaxSyncStandbyLag, the standby server adopts semi-sync replication; if not, it adopts async replication.
    This value is only valid for the instance with SyncMode set to Semi-sync.
    When the semi-sync replication mode of the instance is not allowed to downgrade to async replication, MaxSyncStandbyLatency and MaxSyncStandbyLag are not required.
    When the semi-sync instance is allowed to downgrade to async replication, MaxSyncStandbyLatency is required and MaxSyncStandbyLag must be left empty for PostgreSQL 9; MaxSyncStandbyLatency and MaxSyncStandbyLag` are required for PostgreSQL 10 and later.
    MaxSyncStandbyLag No Integer Maximum delay for sync standby server. If the delay time for standby server and the data lag are both less than or equals to the value of MaxSyncStandbyLag and MaxSyncStandbyLatency respectively, the standby server adopts sync replication mode; if not, it adopts async replication.
    This value is only valid for the instance with SyncMode set to Semi-sync.
    When the semi-sync replication mode of the instance is not allowed to downgrade to async replication, MaxSyncStandbyLatency and MaxSyncStandbyLag are not required.
    When the semi-sync instance is allowed to downgrade to async replication, MaxSyncStandbyLatency is required and MaxSyncStandbyLag must be left empty for PostgreSQL 9; MaxSyncStandbyLatency and MaxSyncStandbyLag` are required for PostgreSQL 10 and later.

    3. Output Parameters

    Parameter Name Type Description
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Changing to Async

    This example shows you how to use Primary-standby sync mode asynchronously and set the maximum delay for switching allowed.

    Input Example

    POST / HTTP/1.1
    Host: postgres.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifyDBInstanceHAConfig
    <Common request parameters>
    
    {
        "DBInstanceId": "postgres-32d4mmv9",
        "SyncMode": "Async",
        "MaxStandbyLatency": 10737418240,
        "MaxStandbyLag": 10
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "c4676122-1694-4d0f-8b03-a33b4e1bd850"
        }
    }
    

    Example2 Changing to Semi-Sync with Permission to Fall Back to Asynchronous Replication

    This example shows you how to use the Primary-standby sync mode with semi-sync, set the maximum delay for switching allowed, and allow fallback to asynchronous replication.

    Input Example

    POST / HTTP/1.1
    Host: postgres.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifyDBInstanceHAConfig
    <Common request parameters>
    
    {
        "DBInstanceId": "postgres-32d4mmv9",
        "SyncMode": "Semi-sync",
        "MaxStandbyLatency": 10737418240,
        "MaxStandbyLag": 10,
        "MaxSyncStandbyLatency": 1073741824,
        "MaxSyncStandbyLag": 5
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "34c1d54c-ea3e-4594-8a5d-1b739123949d"
        }
    }
    

    Example3 Changing to Semi-Sync with Forbidden Fall Back to Asynchronous Replication

    This example shows you how to use the Primary-standby sync mode with semi-sync, set the maximum delay for switching allowed, and forbid fallback to asynchronous replication.

    Input Example

    POST / HTTP/1.1
    Host: postgres.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifyDBInstanceHAConfig
    <Common request parameters>
    
    {
        "DBInstanceId": "postgres-32d4mmv9",
        "SyncMode": "Semi-sync",
        "MaxStandbyLatency": 10737418240,
        "MaxStandbyLag": 10
    }
    

    Output Example

    {
        "Response": {
            "RequestId": "9b923bd9-6a3b-482a-945d-ea2e6f2a9f17"
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation.DatabaseAccessError Failed to access database management service. Please try again later. If the problem persists, please contact customer service.
    FailedOperation.FailedOperationError Operation failed. Please try again later.
    InvalidParameter.ParameterCheckError Failed to check the parameter.
    InvalidParameter.ParametersNotSet You can't left all parameters empty.You need to set at least one of the parameters.
    InvalidParameterValue.InvalidParameterValueError Incorrect parameter value
    InvalidParameterValue.ParameterOutOfRange Invalid parameter
    OperationDenied.CamDeniedError This operation cannot be performed.
    OperationDenied.InstanceStatusLimitError This operation cannot be performed on an instance in this status.
    ResourceNotFound.InstanceNotFoundError The instance does not exist.

    Help and Support

    Was this page helpful?

    Help us improve! Rate your documentation experience in 5 mins.

    Feedback