comment on function @NAMESPACE@.storeNode(p_no_id int4, p_no_comment text) is
'no_id - Node ID #
-no_comment - Human-oriented comment
+no_comment - Human-oriented commentb
Generate the STORE_NODE event for node no_id';
-- provider for all subscriptions served
-- by the failed node. (otherwise it
-- wouldn't be a allowable backup node).
+-- delete from @NAMESPACE@.sl_subscribe
+-- where sub_receiver=p_backup_node;
+
update @NAMESPACE@.sl_subscribe
set sub_provider=p_backup_node
from @NAMESPACE@.sl_node
where sub_provider=p_failed_node
and sl_node.no_id=sub_receiver
- and sl_node.no_failed=false;
-
+ and sl_node.no_failed=false
+ and sub_receiver<>p_backup_node;
+
+ update @NAMESPACE@.sl_subscribe
+ set sub_provider=(select set_origin from
+ @NAMESPACE@.sl_set where set_id=
+ sub_set)
+ where sub_provider=p_failed_node
+ and sub_receiver=p_backup_node;
+
update @NAMESPACE@.sl_node
set no_active=false WHERE
no_id=p_failed_node;
char seqbuf[64];
bool event_ok;
bool need_reloadListen = false;
+ bool need_reloadSets = false;
+
char conn_symname[32];
SlonSyncStatus sync_status = SYNC_INITIAL;
rtcfg_namespace,
rtcfg_namespace,
failed_node, node->no_id, seq_no_c);
-
+ slon_log(SLON_INFO, "remoteWorkerThread_%d FAILOVER_NODE finished %d\n"
+ ,node->no_id,
+ failed_node);
+ /**
+ * The list of set origins has now changed.
+ */
need_reloadListen = true;
+ need_reloadSets = true;
}
else if (strcmp(event->ev_type, "SUBSCRIBE_SET") == 0)
{
rtcfg_reloadListen(local_dbconn);
need_reloadListen = false;
}
+ if(need_reloadSets)
+ {
+ rtcfg_reloadSets(local_dbconn);
+ need_reloadSets = true;
+ }
}
#ifdef SLON_MEMDEBUG
rtcfg_unlock();
}
+/* ------
+ * rtcfg_reloadSets
+ */
+void rtcfg_reloadSets(PGconn * db)
+{
+ SlonDString query;
+ PGresult *res;
+ int i,
+ n;
+ SlonSet *set;
+
+ rtcfg_lock();
+
+ /*
+ * Read configuration table sl_set
+ */
+ slon_mkquery(&query,
+ "select set_id, set_origin, set_comment "
+ "from %s.sl_set",
+ rtcfg_namespace);
+ res = PQexec(db, dstring_data(&query));
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)
+ {
+ slon_log(SLON_FATAL, "main: Cannot get set config - %s\n",
+ PQresultErrorMessage(res));
+ PQclear(res);
+ dstring_free(&query);
+ slon_retry();
+ }
+ for (i = 0, n = PQntuples(res); i < n; i++)
+ {
+ int set_id = (int) strtol(PQgetvalue(res, i, 0), NULL, 10);
+ int set_origin = (int) strtol(PQgetvalue(res, i, 1), NULL, 10);
+ for (set = rtcfg_set_list_head; set; set = set->next)
+ {
+ if (set->set_id == set_id)
+ {
+ set->set_origin=set_origin;
+ }
+ }/*for set in array*/
+ }/*for tuple*/
+ PQclear(res);
+ rtcfg_unlock();
+}
+
+
+
+
/* ----------
* rtcfg_moveSet
* ----------
extern void rtcfg_dropSet(int set_id);
extern void rtcfg_moveSet(int set_id, int old_origin, int new_origin,
int sub_provider);
+extern void rtcfg_reloadSets(PGconn *db);
extern void rtcfg_storeSubscribe(int sub_set, int sub_provider,
char *sub_forward);