2ndQuadrant / pglogical

Logical Replication extension for PostgreSQL 17, 16, 15, 14, 13, 12, 11, 10, 9.6, 9.5, 9.4 (Postgres), providing much faster replication than Slony, Bucardo or Londiste, as well as cross-version upgrades.
http://2ndquadrant.com/en/resources/pglogical/
Other
1.01k stars 153 forks source link

segmentation fault on pglogical 2.4.1 with replication from non-partitioned to partitioned #367

Open jcasanov opened 2 years ago

jcasanov commented 2 years ago

I have a 9.6 database which is being upgraded to 13. We are using pglogical 2.4.1 as part of the process of migration.

pglogical here is important to decrease down time but we were trying to use the opportunity to partition some tables. Sadly, pglogical makes the database crash everytime we try it.

= Configuration on both servers (pg_hba.conf accept both normal and replication connections for the whole subnet in both servers):

listen_addresses = '*'
logging_collector = 'on'
shared_preload_libraries = 'pglogical'
wal_level = 'logical'

= executed on origin (to prepare the test):

psql -c "create database pgbench" 
/usr/pgsql-9.6/bin/pgbench -i pgbench 
psql -d pgbench <<EOF 
create extension pglogical; 
select pglogical.create_node('origin', 'host=10.0.204.102 dbname=pgbench'); 
select pglogical.replication_set_add_table('default', 'pgbench_accounts'::regclass); 
EOF

= executed on destiny (note that we drop original pgbench_accounts and change it by a partitioned table):

psql -c "create database pgbench"
/usr/pgsql-13/bin/pg_dump --schema-only -t pgbench_* -h 10.0.204.102 pgbench | psql pgbench
psql -d pgbench <<EOF 
create extension pglogical;
select pglogical.create_node('destination', 'host=10.0.204.111 dbname=pgbench');

DROP TABLE pgbench_accounts;
CREATE TABLE public.pgbench_accounts (
    aid integer NOT NULL PRIMARY KEY,
    bid bigint,
    abalance bigint,
    filler character(84)
)
PARTITION BY RANGE (aid);

CREATE TABLE public.pgbench_accounts_1 PARTITION OF public.pgbench_accounts FOR VALUES FROM (1) TO (50001);
CREATE TABLE public.pgbench_accounts_2 PARTITION OF public.pgbench_accounts FOR VALUES FROM (50001) TO (100001);

select pglogical.create_subscription('sub_1', 'host=10.0.204.102 dbname=pgbench', '{default}', false, true);
EOF

Then give it some activity on origin, and wait for the crash (segmentation fault) on the logs

/usr/pgsql-9.6/bin/pgbench -c2 -j 2 -T 1300 -d pgbench

LOG:  background worker "pglogical apply 174506:2411690873" (PID 3828) was terminated by signal 11: Segmentation fault
LOG:  terminating any other active server processes

Attached the backtrace gdb.txt

Anything else I can do to help?

PS: if the origin is in v13 it doesn't crash but gives this ERROR message

LOG:  starting apply for subscription sub_1
ERROR:  insufficient data left in message
CONTEXT:  apply UPDATE in commit before 0/232CCC0, xid 504 committed at 2022-01-31 22:23:22.875938-05 (action #2) from node replorigin 1
Yuxin0610 commented 2 years ago

My understanding is that pglogical don't support non-partitioned table to to partitioned table.

petere commented 2 years ago

My understanding is that pglogical don't support non-partitioned table to to partitioned table.

That is correct.

sethideepak commented 11 months ago

Please adjusted the configuration on the provider node, setting the parameter synchronize_data to false in order to skip schema structure validation:

SELECT pglogical.replication_set_add_all_tables('default', 'pgbench_accounts'::regclass, synchronize_data := false); This was working for me. Please test it and let me know if you face any issue.