Updated on 2025-05-29 GMT+08:00

DR Query Functions for Dual-Database Instances

gs_get_local_barrier_status()

Description: If two-city 3DC DR is enabled, logs of the primary database instance and standby database instance for DR are synchronized. The progress of the primary database instance's archived logs and the standby database instance's log replay is determined by flushing barrier logs to the primary database instance and replaying them on the standby database instance. gs_get_local_barrier_status is used to query the current log replay status of each node of the standby database instance for DR.

Return type: text

barrier_id: latest barrier ID of a node of the standby database instance for DR.

barrier_lsn: LSN of the latest barrier ID returned by a node in the standby database instance for DR.

archive_lsn: location of archived logs obtained by a node in the standby database instance for DR. This parameter does not take effect currently.

flush_lsn: location of logs that have been flushed to disk on a node in the standby database instance for DR.

gs_hadr_in_recovery()

Description: Checks whether the current node is in barrier-based log restoration if two-city 3DC DR is enabled. If the current node is in barrier-based log restoration, true is returned. The standby database instance for DR can be promoted to the production database instance through the switchover process only after the log restoration is complete (the SYSADMIN permission is required).

Return type: Boolean

Note: This function is used only when a planned switchover is performed in the standby database instance for DR.

gs_streaming_dr_get_switchover_barrier()

Description: Checks whether the DN instance of the standby database instance for DR has received the switchover barrier logs and replayed the logs in two-city 3DC DR solutions based on streaming replication. If it has, true is returned. In the standby database instance for DR, the procedure for promoting the standby database instance for DR to the production database instance in the switchover process can be started only after the switchover barrier logs of all DN instances are replayed (the SYSADMIN permission is required).

Return type: Boolean

Note: This function is used only when a planned switchover is performed in the standby database instance in streaming DR solutions.

gs_streaming_dr_service_truncation_check()

Description: Checks whether the DN instance of the primary database instance has sent the switchover barrier logs in two-city 3DC DR solutions based on streaming replication. If it has, true is returned. The procedure for demoting the production database instance to the standby database instance for DR in the switchover process can be started only after the logs are sent (the SYSADMIN permission is required).

Return type: Boolean

Note: This function is used only when a planned switchover is performed in the standby database instance for DR.

gs_hadr_local_rto_and_rpo_stat()

Description: Displays the log flow control information about the primary and standby database instances in the streaming DR scenario. (This view can be used only on the primary DN of the primary database instance. Statistics cannot be obtained from the standby DN or the standby database instance.)

The return value type is record. The types and meanings of the columns are as described in Table 1.

Table 1 gs_hadr_local_rto_and_rpo_stat parameters

Parameter

Type

Description

hadr_sender_node_name

text

Node name, including the primary database instance and the main standby node of the standby database instance.

hadr_receiver_node_name

text

Name of the main standby node of the standby database instance.

source_ip

text

IP address of the primary DN of the primary database instance.

source_port

int

Communication port of the primary DN of the primary database instance.

dest_ip

text

IP address of the main standby DN of the standby database instance.

dest_port

int

Communication port of the main standby DN of the standby database instance.

current_rto

int

Flow control information, that is, log RTO time of the current primary and standby database instances (unit: second).

target_rto

int

Flow control information, that is, the RTO time between the target primary and standby database instances (unit: second).

current_rpo

int

Flow control information, that is, log RPO time of the current primary and standby database instances (unit: second).

target_rpo

int

Flow control information, that is, the RPO time between the target primary and standby database instances (unit: second).

rto_sleep_time

int

RTO flow control information, that is, the expected sleep time (unit: μs) required by walsender on the host to reach the specified RTO.

rpo_sleep_time

int

RPO flow control information, that is, the expected sleep time (unit: μs) required by xlogInsert on the host to reach the specified RPO.

gs_hadr_remote_rto_and_rpo_stat()

Description: Displays the log flow control information of the primary database instance and standby database instance for DR of other non-local data shards in streaming DR mode. This function is not supported in the current version.

gs_hadr_create_recovery_pause_barrier()

Description: In production mode, the primary database instance generates a barrier that enables the standby database instance for DR to pause during replay. This is only effective after production mode is enabled.

gs_is_wal_truncate_complete()

Description: Queries whether the online log truncation of the current standby database instance for DR is complete after a production failure. If the online log truncation is complete, true is returned.

Return type: Boolean

gs_change_dorado_state(device_name cstring, dorado_state cstring, term int)

Description: Initializes user permissions to change the status of the Dorado shared volume channel.

Return type: Boolean

Category

Parameter

Type

Shared Volume Channel Name

Input parameter

device_name

text

Name of the shared volume channel.

Input parameter

dorado_state

text

Status of the shared volume.

Input parameter

term

int

The term value of the current database instance.

gs_get_dorado_state()

Description: Queries the health and running status of the Dorado shared volume channel.

Return type: record

Category

Parameter

Type

Description

Output parameter

device_name

text

Name of the shared volume channel.

Output parameter

dorado_health

text

Health status of the shared volume.

Output parameter

dorado_state

text

Running status of the shared volume.