Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I use pglogical to distribute data, but there are more table structures in subscriptions. #455

Open
Jerry-Freelancer opened this issue Jan 15, 2024 · 0 comments

Comments

@Jerry-Freelancer
Copy link

My publisher has four tables and two replication sets, Repset1 (T1, T2) and Repset2 (T3, T4).

select pglogical.create_replication_set('repset1');
select pglogical.create_replication_set('repset2');

select pglogical.replication_set_add_table('repset1','t1');
select pglogical.replication_set_add_table('repset1','t2');

select pglogical.replication_set_add_table('repset2','t3');
select pglogical.replication_set_add_table('repset2','t4');
pgdb=# select * from tables;
 relid | nspname | relname | set_name
-------+---------+---------+----------
 32005 | public  | t1      | repset1
 32010 | public  | t2      | repset1
 32020 | public  | t4      | repset2
 32015 | public  | t3      | repset2
(4 rows)

The command at the subscriber is

SELECT pglogical.create_subscription(
    subscription_name := 'subscription1',
    synchronize_structure := true,
    provider_dsn := 'host=192.168.5.171 port=5432 user=pguser password=123456 dbname=pgdb',
    replication_sets := array['repset1']
);

The subscriber correctly synchronized the table structure and data of T1 and T2, but did synchronize the table structure of T3 and T4.

pgdb01=# \d
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+--------
 public | t1   | table | pguser
 public | t2   | table | pguser
 public | t3   | table | pguser
 public | t4   | table | pguser
(4 rows)

pgdb01=# select * from t1;
 id | name
----+------
  1 | a
  2 | b
  3 | c
(3 rows)

pgdb01=# select * from t2;
 id | name
----+------
 11 | aa
 22 | bb
 33 | cc
(3 rows)

pgdb01=# select * from t3;
 id | name
----+------
(0 rows)

pgdb01=# select * from t4;
 id | name
----+------

If I set synchronize_structure to false and manually create the table structure, it is correct, and only the table structure and data of T1 and T2 will be synchronized, but this seems to increase the workload and does not conform to the corresponding relationship between the publication set and the table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant