Relational Database ServiceRelational Database Service

Compute
Elastic Cloud Server
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
Domain Name Service
VPC Endpoint
Cloud Connect
Enterprise Switch
Security & Compliance
Anti-DDoS
Web Application Firewall
Host Security Service
Data Encryption Workshop
Database Security Service
Advanced Anti-DDoS
Data Security Center
Container Guard Service
Situation Awareness
Managed Threat Detection
Compass
Cloud Certificate Manager
Anti-DDoS Service
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GaussDB NoSQL
GaussDB(for MySQL)
Distributed Database Middleware
GaussDB(for openGauss)
Developer Services
ServiceStage
Distributed Cache Service
Simple Message Notification
Application Performance Management
Application Operations Management
Blockchain
API Gateway
Cloud Performance Test Service
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
DevCloud
ProjectMan
CodeHub
CloudRelease
CloudPipeline
CloudBuild
CloudDeploy
Cloud Communications
Message & SMS
Cloud Ecosystem
Marketplace
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP License Service
Support Plans
Customer Operation Capabilities
Partner Support Plans
Professional Services
enterprise-collaboration
Meeting
IoT
IoT
Intelligent EdgeFabric
DeveloperTools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Updated at: Apr 02, 2022 GMT+08:00

Failover Slot for Logical Subscriptions

Scenarios

RDS for PostgreSQL synchronizes information about logical replication slots specified as failover slots from the primary DB instance to the standby DB instance to ensure logical subscriptions remain connected after a primary/standby switchover.

Information about logical replication slots will not be transferred to the new primary DB instance during a primary/standby switchover. If there is a primary/standby switchover, the logical subscriptions are disconnected, and you will need to manually create new slots. Failover slots make it possible to synchronize all logical slots from the primary DB instance to the standby DB instance, preventing logical subscriptions from being disconnected after a primary/standby switchover.

Precautions

  • This function is supported only for PostgreSQL 12 and later versions.
  • This function supports only logical subscriptions. It does not support physical subscriptions.
  • This function introduces new log types. Therefore, restoring data from backup files to a new DB instance will fail when this function is enabled.

How to Use

Run the following SQL statement on the publishing client to create a failover slot:

SELECT * FROM pg_create_logical_replication_slot('slot1', 'pgoutput', false, true);

Parameters in the command are described as follows:

  • slot1 is the name of the logical slot.
  • pgoutput is the plugin name.
  • The third parameter specifies if the slot is a temporary slot.
  • The fourth parameter specifies if the slot is a failover slot.

If you want to create a failover slot, set the third parameter to false and the fourth parameter to true. If the fourth parameter is not specified, a non-failover slot is created.

Example of a Complete Logical Subscription

  • Create a table on the publishing client.

    create table t1(c1 int primary key, c2 int);

  • Create a publication on the publishing client.

    create publication pub1 for table t1;

  • Create a failover slot on the publishing client.

    SELECT * FROM pg_create_logical_replication_slot('slot1', 'pgoutput', false, true);

  • Insert data into the table on the publishing client.

    insert into t1 values(1,1);

    insert into t1 values(2,2);

  • Create a table on the subscription client.

    create table t1(c1 int primary key, c2 int);

  • Create a subscription on the subscription client and specify the name of the failover slot.

    create subscription sub1 connection 'host=127.0.0.1 dbname=postgres user=postgres port=5438' publication pub1 with(create_slot=false,slot_name=slot1);

  • Query data on the subscription client and check whether the data is subscribed to.

    Select * from t1;

  • Perform a primary/standby switchover.

    Insert data into the table on the publishing client and view the data on the subscription client. The logical subscription is not disconnected.

Did you find this page helpful?

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel