Truncate in synchronous logical replication failed

From: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Truncate in synchronous logical replication failed
Date: 2021-04-07 06:56:15
Message-ID: OS0PR01MB6113C2499C7DC70EE55ADB82FB759@OS0PR01MB6113.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I met a problem in synchronous logical replication. The client hangs when TRUNCATE TABLE at publisher.

Example of the procedure:
------publisher------
create table test (a int primary key);
create publication pub for table test;

------subscriber------
create table test (a int primary key);
create subscription sub connection 'dbname=postgres' publication pub;

Then, set synchronous_standby_names = 'sub’ on publisher, and reload publisher.

------publisher------
truncate test;

Then the client of publisher will wait for a long time. A moment later, the publisher and subscriber will report following errors.
Subscriber log
2021-04-07 12:13:07.700 CST [3542235] logical replication worker ERROR: terminating logical replication worker due to timeout
2021-04-07 12:13:07.722 CST [3542217] postmaster LOG: background worker "logical replication worker" (PID 3542235) exited with exit code 1
2021-04-07 12:13:07.723 CST [3542357] logical replication worker LOG: logical replication apply worker for subscription "sub" has started
2021-04-07 12:13:07.745 CST [3542357] logical replication worker ERROR: could not start WAL streaming: ERROR: replication slot "sub" is active for PID 3542236
Publisher log
2021-04-07 12:13:07.745 CST [3542358] walsender ERROR: replication slot "sub" is active for PID 3542236
2021-04-07 12:13:07.745 CST [3542358] walsender STATEMENT: START_REPLICATION SLOT "sub" LOGICAL 0/169ECE8 (proto_version '2', publication_names '"pub"')

I checked the PG-DOC, found it says that “Replication of TRUNCATE commands is supported”[1], so maybe TRUNCATE is not supported in synchronous logical replication?

If my understanding is right, maybe PG-DOC can be modified like this. Any thought?
Replication of TRUNCATE commands is supported
->
Replication of TRUNCATE commands is supported in asynchronous mode

[1]https://www.postgresql.org/docs/devel/logical-replication-restrictions.html

Regards,
Tang

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2021-04-07 07:08:23 Re: [Patch] ALTER SYSTEM READ ONLY
Previous Message osumi.takamichi@fujitsu.com 2021-04-07 06:43:19 RE: Disable WAL logging to speed up data loading