pglogical
pglogical copied to clipboard
TRUNCATE not replicated when executed with session_replication_role='replica'
pglogical 2.1.1, postgresql 10.5
We have setup replication on table trunc_test
between two databases. It works well except for TRUNCATE.
It does not replicate to target database when executed in 'replica' role:
set session_replication_role = 'replica';
truncate trunc_test;
set session_replication_role = 'origin';
This is replicates just fine
truncate trunc_test;
INSERTs, UPDATEs and DELETEs are replicated both in 'replica' and 'origin' roles.
So far we have worked around this by creating a trigger in the source datbase which executes DELETE from trunc_test
before the TRUNCATE trunc_test
is executed.
But in a long term we need pglogical to be consistent in handling TRUNCATE.
That's expected in PG10, we use trigger for replication of truncates. Long term it's solved in PG11.
How do you know this is expected? Can't find any information about this...
Triggers are not executed with session_replication_role = 'replica'
that's documented in postgres manual. We have to use trigger on PG10 and older for supporting TRUNCATE
replication, because logical decoding of TRUNCATE
was added in PG11 (well, pglogical 2 uses trigger even on PG11 currently, which is why I am keeping this open).
OK, so to fix the issue we must migrate to PG11 and use pglogical 3, which is not freely available now. Am I right? Will you open source pglogical 3 any time soon?
@PJMODOS Do you have any update here? Pglogical 3 still not released. Any chance you backport it to the 2.x branch?