All Products
Search
Document Center

PolarDB:Subscription management

Last Updated:Mar 28, 2026

Logical replication slots retain write-ahead logging (WAL) files until a subscriber reads them. When a slot goes inactive, WAL files accumulate indefinitely. If the disk fills up, the cluster locks and data writes fail, disrupting your business.

To prevent this, monitor your replication slots regularly and drop any that are no longer in use.

Prerequisites

Before you begin, make sure:

  • For a centralized cluster (Enterprise Edition or Standard Edition): set the wal_level parameter to logical from the PolarDB console. The cluster restarts after the change — plan accordingly.

  • For a distributed cluster: wal_level is set to logical by default. No action required.

View logical replication slots

If no logical replication slots exist in your cluster, create the relevant resources first. To enable the logical replication slot view in the PolarDB console, contact us.
  1. Log on to the PolarDB console. In the left-side navigation pane, select Clusters, choose the region of your cluster, and click the cluster ID to go to the Basic Information page.

  2. In the left-side navigation pane, choose Settings and Management > Subscription Management. On the WAL File Management tab, view the logical replication slots for the cluster. The following table describes each field.

    FieldDescription
    Slot NameThe name of the logical replication slot.
    Slot TypeThe type of the logical replication slot. Only logical is supported.
    Use Plug-inThe output plugin used by the slot. PolarDB for PostgreSQL supports decoderbufs, decoder_raw, wal2json, and pgoutput.
    Temporary SlotWhether the slot is temporary. A temporary slot exists only for the current session and is deleted automatically when the session ends. true = temporary; false = persistent.
    Database NameThe database where the slot resides.
    Accumulated WAL FilesThe amount of WAL data retained by this slot. Unit: MB.
    Logical Subscription LatencyThe replication lag between the publisher and subscriber for this slot. Unit: seconds.
    Whether ActiveThe current status of the slot: ACTIVE (a subscriber is connected) or INACTIVE (no subscriber is connected).
  3. (Optional) If the Whether Active field shows INACTIVE, WAL files are accumulating. Resolve this as soon as possible using one of the following methods:

    • Activate the slot to change its status to ACTIVE.

    • Drop the slot if it is no longer needed:

      SELECT pg_drop_replication_slot('slot_name');

(Optional) Create a logical replication slot

Use the following steps to set up logical replication between two databases in the same cluster.

  1. In the publisher database, create a publication for the table you want to replicate.

    CREATE PUBLICATION <publication_name> FOR TABLE <table_name>;

    Example:

    CREATE PUBLICATION pub1 FOR TABLE public.t1;

    To list existing publications, run:

    SELECT * FROM pg_publication;
  2. In the publisher database, use the privileged account to create a logical replication slot.

    SELECT pg_create_logical_replication_slot('<slot_name>', 'pgoutput');
  3. In the subscriber database, create a table with the same schema and name as the publisher table.

  4. In the subscriber database, create the subscription. Reference the slot you created in step 2 and set create_slot=false to reuse it.

    CREATE SUBSCRIPTION my_subscription
    CONNECTION 'channel_name=localhost dbname=<publisher_database> user=<privileged_account> password=<password>'
    PUBLICATION pub1 WITH (create_slot=false, slot_name=<slot_name>);
    Important

    When the publisher and subscriber are in the same cluster, you must add WITH (create_slot=false) to instruct the subscriber not to create a new replication slot and instead use the existing one.