pglogical
pglogical copied to clipboard
Endless pglogical.queue growth
pglogical 2.3.4 postgresql 11.4 debian 9
pglogical.queue table growth endless in multisubscribe mode when trying to add new table to the replication set
To reproduce need to deploy 3 pglogical nodes.
pglogical.create_node(
node_name := node1,
dsn := 'host=/tmp/postgresql_node1 dbname=my_database'
);
pglogical.create_node(
node_name := node2,
dsn := 'host=/tmp/postgresql_node2 dbname=my_database'
);
pglogical.create_node(
node_name := node3,
dsn := 'host=/tmp/postgresql_node3 dbname=my_database'
);
Create replication set on every node:
select * from pglogical.create_replication_set(
set_name := 'test',
replicate_insert := true, replicate_update := true,
replicate_delete := true, replicate_truncate := true);
and add some table to the replication set ( in real use case there is some row_filter to separate keys beetwen nodes ):
select * from pglogical.replication_set_add_table(
set_name := 'test', relation := 'test_replication',
synchronize_data := true,
columns := null,
row_filter := null);
Test table may be:
create table test_replication(
test_value bigint primary key
);
So, then create subscription to each other, example for node1
select * from pglogical.create_subscription(
subscription_name := 'node2',
replication_sets := array['test'],
synchronize_data := true,
provider_dsn := 'host=/tmp/postgresql_node2 dbname=my_database user=root');
select * from pglogical.create_subscription(
subscription_name := 'node3',
replication_sets := array['test'],
synchronize_data := true,
provider_dsn := 'host=/tmp/postgresql_node3 dbname=my_database user=root');
So add another table to the 'test' replication set on each node after configuring subscriptions:
create table test_replication2(
test_value bigint primary key
);
select * from pglogical.replication_set_add_table(
set_name := 'test', relation := 'test_replication2',
synchronize_data := true,
columns := null,
row_filter := null);
Open 3 consoles and run: watch -n1 -c "/opt/itcs/bin/psql -h /tmp/postgresql_node1/ -d my_database -c 'select count() from pglogical.queue;' " watch -n1 -c "/opt/itcs/bin/psql -h /tmp/postgresql_node1/ -d my_database -c 'select count() from pglogical.queue;' " watch -n1 -c "/opt/itcs/bin/psql -h /tmp/postgresql_node1/ -d my_database -c 'select count(*) from pglogical.queue;' "
pglogical.queue will growth endless
my_database=> select count(*) from pglogical.queue;
count
-------
3735
(1 row)
my_database=> select count(*) from pglogical.queue;
count
-------
13576
(1 row)
Possible fix described in commit for my pglogical fork https://github.com/DenisRazinkin/pglogical/pull/1/commits/77bad006fa20d6f660689fbb4f66fa6583facf3f