Use correct replication set and apply delay config in apply.
authorPetr Jelinek <pjmodos@pjmodos.net>
Wed, 6 May 2015 14:51:53 +0000 (16:51 +0200)
committerPetr Jelinek <pjmodos@pjmodos.net>
Wed, 6 May 2015 14:52:08 +0000 (16:52 +0200)
bdr_apply.c
expected/ddl/replication_set.out
sql/ddl/replication_set.sql

index f6c931a0a4fae0e95b1a13ffc684c3241ddc44f3..624fe7504921af00433ae0c429db1ed794880a61 100644 (file)
@@ -2455,6 +2455,27 @@ bdr_apply_main(Datum main_arg)
           bdr_apply_config->timeline == bdr_apply_worker->remote_timeline &&
           bdr_apply_config->dboid == bdr_apply_worker->remote_dboid);
 
+   /*
+    * Got default remote connection info, read also local defaults.
+    * Otherwise we would be using replication sets and apply delay from the
+    * remote node instead of the local one.
+    *
+    * Note: this is slightly hacky and we should probably use the bdr_nodes
+    * for this instead.
+    */
+   if (!bdr_apply_config->origin_is_my_id &&
+       !bdr_apply_config->is_unidirectional)
+   {
+       BdrConnectionConfig *cfg =
+           bdr_get_connection_config(GetSystemIdentifier(), ThisTimeLineID,
+                                     MyDatabaseId, false);
+
+       bdr_apply_config->apply_delay = cfg->apply_delay;
+       pfree(bdr_apply_config->replication_sets);
+       bdr_apply_config->replication_sets = pstrdup(cfg->replication_sets);
+       bdr_free_connection_config(cfg);
+   }
+
    CurrentResourceOwner = ResourceOwnerCreate(NULL, "bdr apply top-level resource owner");
    bdr_saved_resowner = CurrentResourceOwner;
 
index c95dde34857227a2d8d37187d04c7aeb463c2af7..5d7de207b2e34dfff9172810b17cac0d6203c7e1 100644 (file)
@@ -190,7 +190,7 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r
  * node1: dbname regression, sets: default, important, for-node-1
  * node2: dbname postgres, sets: default, important, for-node-2
  */
-\c regression
+\c postgres
 CREATE TABLE settest_1(data text primary key);
 INSERT INTO settest_1(data) VALUES ('should-replicate-via-default');
 SELECT bdr.table_set_replication_sets('settest_1', '{}');
@@ -254,7 +254,7 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r
  
 (2 rows)
 
-\c postgres
+\c regression
 SELECT * FROM settest_1 ORDER BY data;
                         data                         
 -----------------------------------------------------
@@ -264,7 +264,7 @@ SELECT * FROM settest_1 ORDER BY data;
  should-replicate-via-for-node-2-even-though-unknown
 (4 rows)
 
-\c regression
+\c postgres
 DROP TABLE settest_1;
 /*
  * Now test configurations where only some actions are replicated.
@@ -371,7 +371,7 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r
  
 (2 rows)
 
-\c postgres
+\c regression
 SELECT * FROM settest_2 ORDER BY data;
                 data                
 ------------------------------------
@@ -385,4 +385,3 @@ SELECT * FROM settest_2 ORDER BY data;
  repl-update--insert-#4
 (8 rows)
 
-\c regression
index d9d98eed0e23ddd0d2c1b3e00f80f12daa3bb155..ad661c7d32d8c28fae29e1ca9e18f55e9c4e0f58 100644 (file)
@@ -66,7 +66,7 @@ SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_r
  * node1: dbname regression, sets: default, important, for-node-1
  * node2: dbname postgres, sets: default, important, for-node-2
  */
-\c regression
+\c postgres
 
 CREATE TABLE settest_1(data text primary key);
 
@@ -92,9 +92,9 @@ INSERT INTO settest_1(data) VALUES ('should-replicate-via-for-node-2-and-importa
 
 SELECT * FROM settest_1 ORDER BY data;
 SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
-\c postgres
-SELECT * FROM settest_1 ORDER BY data;
 \c regression
+SELECT * FROM settest_1 ORDER BY data;
+\c postgres
 DROP TABLE settest_1;
 
 
@@ -181,6 +181,5 @@ WHERE data = 'repl-combined--insert-#2-then-delete';
 
 SELECT * FROM settest_2 ORDER BY data;
 SELECT pg_xlog_wait_remote_apply(pg_current_xlog_location(), pid) FROM pg_stat_replication;
-\c postgres
-SELECT * FROM settest_2 ORDER BY data;
 \c regression
+SELECT * FROM settest_2 ORDER BY data;