pglogical
pglogical copied to clipboard
Bidirectional Replication Behavior - forward_origins
My Goal: Bidirectional Replication, where all changes are synced
My Setup (Broken):
## DB -- A
SELECT pglogical.create_subscription(
subscription_name := 'legacy_sub',
provider_dsn := 'REMOVED',
replication_sets := ARRAY['default'],
synchronize_data := true,
forward_origins := '{}' );
## DB -- B
SELECT pglogical.create_subscription(
subscription_name := 'authdb_sub',
provider_dsn := 'REMOVED',
replication_sets := ARRAY['default'],
synchronize_data := false,
forward_origins := '{}' );
Observed Behavior: For some reason changes to some rows only flow in 1 direction.
If the row originates on DB A, then DB B will get all changes to it, but and change DB B makes is not reflected back to DB A (divergence occurs). If the tuple originates on DB B, then changes made in either DB A or B show up in both databases.
I found that modifying the configuration of DB B to (below) will make changes made in either DB appear in the opposite DB.
forward_origins := '{all}' ## or omitting for default
Workaround:
I think it works by making DB A get change events for its own changes (noisy, but oh well), but doesnt create an infinite loop because DB B for some reason doesnt need this workaround, and can stay with forward_origins := '{}'