Search code examples
postgresqlreplication

Pglogical replication sets not working as expected


I am trying to setup up pglogical replication. I have a table which has around 4 rows in the provider server.

=========
employee_id |     visitor_email     | vistor_id |        date         |             message          
-------------+-----------------------+-----------+---------------------+--------------------------
       1 | [email protected]      |         1 | 2016-08-24 00:00:00 | This is the first test.
       2 | [email protected] |         2 | 2016-08-24 00:00:00 | This is the second test.
       3 | [email protected] |         3 | 2016-08-24 00:00:00 | This is the third test.
       4 | [email protected] |         4 | 2016-08-24 00:00:00 | This is the fourth test.
  ===============================

After creating the above mentioned table. I have created a replication set in the provider . Then I configured the subscriber node and the subscription. Ideally, I should see the 4 rows from the provider table in my subscriber, but I am only seeing the table structure in subscriber, not the data. If I add a new row in the provider table as follows

INSERT INTO employees (employee_id, visitor_email, date, message) VALUES (5, '[email protected]', current_date, 'This is the fifth test.'); 

Now, I am able to see the last added row in my subscriber table. All the other 4 rows which were added in the beginning are still missing. What am I doing wrong here?

Does it mean that only the data which was created after the creation of replication_sets will be considered? How to add the whole content of a table to a replication set.?

Any help would be much appreciated.?

Regards, Muhammed Roshan


Solution

  • You can issue the resynchronise_table command to pull everything across. All subsequent inserts will be ok as you've found.

    Use this function to do so:

    pglogical.alter_subscription_resynchronize_table(subscription_name name, relation regclass)
    

    Also you could have passed "synchronize_data" during your initial sync:

    For more information see 2.3 in the following document:

    https://2ndquadrant.com/en/resources/pglogical/pglogical-docs/