Re: Logical replication CPU-bound with TRUNCATE/DROP/CREATE many tables

Keisuke Kuroda <keisuke.kuroda.3862@gmail.com>

From: Keisuke Kuroda <keisuke.kuroda.3862@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-10-01T02:51:54Z
Lists: pgsql-hackers
Hi Dilip, Amit,

Thank you for the patch!

I test the patch on the master HEAD(9796f455) and it works fine.
* make installcheck-world: passed
* walsender process continues to use 100% of the CPU 1core when
TRUNCATE 1000 partition: 1s or less
** before patch : 230s

There is "ReorderBufferAddInvalidation" in reorderbuffer.h, but I
don't think it's needed.

src/include/replication/reorderbuffer.h
+void ReorderBufferAddInvalidation(ReorderBuffer *, TransactionId,
XLogRecPtr lsn,
+                 int nmsgs, SharedInvalidationMessage *msgs);

If possible, I'd like to improve it even before PG13,
 but I recognize that it's difficult because it uses a PG14 or later
mechanism...

Best Regards,
-- 
Keisuke Kuroda
NTT Software Innovation Center
keisuke.kuroda.3862@gmail.com



Commits

  1. Execute invalidation messages for each XLOG_XACT_INVALIDATIONS message

  2. WAL Log invalidations at command end with wal_level=logical.