bdr: Wakeup perdb worker when bdr_node changes are replayed.
authorAndres Freund <andres@anarazel.de>
Sun, 8 Feb 2015 17:41:00 +0000 (18:41 +0100)
committerAndres Freund <andres@anarazel.de>
Thu, 12 Feb 2015 09:16:59 +0000 (10:16 +0100)
bdr.h
bdr_apply.c
bdr_perdb.c

diff --git a/bdr.h b/bdr.h
index 0169c591fc7080599c5b5e42a49ad9f0c9e995b8..65f44f6a564d9344a13a6cfdaf7e8a46b607430f 100644 (file)
--- a/bdr.h
+++ b/bdr.h
@@ -488,6 +488,8 @@ extern int find_perdb_worker_slot(Oid dboid,
 
 extern void bdr_launch_apply_workers(Oid dboid);
 
+extern Datum bdr_connections_changed(PG_FUNCTION_ARGS);
+
 /* Information functions */
 extern int bdr_parse_version(const char * bdr_version_str, int *o_major,
                             int *o_minor, int *o_rev, int *o_subrev);
index 1cabee4b0ba9b8856fb03a2107b4fcb91bbaa30e..122eefdc33812bb6489176e7ef5b57a1da845076 100644 (file)
@@ -116,7 +116,7 @@ static void check_apply_update(BdrConflictType conflict_type,
                               bool *perform_update, bool *log_update,
                               BdrConflictResolution *resolution);
 
-static void check_sequencer_wakeup(BDRRelation *rel);
+static void check_bdr_wakeups(BDRRelation *rel);
 #ifdef BUILDING_BDR
 static HeapTuple process_queued_drop(HeapTuple cmdtup);
 #endif
@@ -587,7 +587,7 @@ process_remote_insert(StringInfo s)
 
    ExecCloseIndices(estate->es_result_relation_info);
 
-   check_sequencer_wakeup(rel);
+   check_bdr_wakeups(rel);
 
    /* execute DDL if insertion was into the ddl command queue */
    if (RelationGetRelid(rel->rel) == QueuedDDLCommandsRelid ||
@@ -871,7 +871,7 @@ process_remote_update(StringInfo s)
 
    PopActiveSnapshot();
 
-   check_sequencer_wakeup(rel);
+   check_bdr_wakeups(rel);
 
    /* release locks upon commit */
    index_close(idxrel, NoLock);
@@ -1017,7 +1017,7 @@ process_remote_delete(StringInfo s)
 
    PopActiveSnapshot();
 
-   check_sequencer_wakeup(rel);
+   check_bdr_wakeups(rel);
 
    index_close(idxrel, NoLock);
    bdr_heap_close(rel, NoLock);
@@ -1839,11 +1839,19 @@ bdr_performing_work(void)
 }
 
 static void
-check_sequencer_wakeup(BDRRelation *rel)
+check_bdr_wakeups(BDRRelation *rel)
 {
-#ifdef BUILDING_BDR
+   Oid         schemaoid = RelationGetNamespace(rel->rel);
    Oid         reloid = RelationGetRelid(rel->rel);
 
+   if (schemaoid != BdrSchemaOid)
+       return;
+
+   /* has the node/connection state been changed on another system? */
+   if (reloid == BdrNodesRelid)
+       bdr_connections_changed(NULL);
+
+#ifdef BUILDING_BDR
    if (reloid == BdrSequenceValuesRelid ||
        reloid == BdrSequenceElectionsRelid ||
        reloid == BdrVotesRelid)
index 838ebad062bc7da11b29557e53ead924f81eca59..b1aa785d30c76e3458ea5129918fe0a1509f869e 100644 (file)
@@ -46,9 +46,6 @@
 
 PG_FUNCTION_INFO_V1(bdr_connections_changed);
 
-Datum
-bdr_connections_changed(PG_FUNCTION_ARGS);
-
 /* In the commit hook, should we attempt to start a per-db worker? */
 static bool xacthook_registered = false;
 static bool xacthook_connections_changed = false;