We can not always rely on the recovery daemon pinging us in a timely manner
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 13 Jan 2011 22:46:04 +0000 (09:46 +1100)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 13 Jan 2011 22:46:04 +0000 (09:46 +1100)
so we need a "ticker" in the main ctdbd daemon too to ensure we get at least one event to process every second.

This will improve the accuracy of "Time jumped" messages and remove false positives when the recovery daemon is "slow".

server/ctdb_daemon.c

index 72c7293258c40b74a88b43a92c7d37b81b3fe586..362f1cee5768a4fc098c59b36b3d25bb7973af07 100644 (file)
@@ -43,6 +43,33 @@ static void print_exit_message(void)
        DEBUG(DEBUG_NOTICE,("CTDB daemon shutting down\n"));
 }
 
+
+
+static void ctdb_time_tick(struct event_context *ev, struct timed_event *te, 
+                                 struct timeval t, void *private_data)
+{
+       struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
+
+       if (getpid() != ctdbd_pid) {
+               return;
+       }
+
+       event_add_timed(ctdb->ev, ctdb, 
+                       timeval_current_ofs(1, 0), 
+                       ctdb_time_tick, ctdb);
+}
+
+/* Used to trigger a dummy event once per second, to make
+ * detection of hangs more reliable.
+ */
+static void ctdb_start_time_tickd(struct ctdb_context *ctdb)
+{
+       event_add_timed(ctdb->ev, ctdb, 
+                       timeval_current_ofs(1, 0), 
+                       ctdb_time_tick, ctdb);
+}
+
+
 /* called when the "startup" event script has finished */
 static void ctdb_start_transport(struct ctdb_context *ctdb)
 {
@@ -77,6 +104,9 @@ static void ctdb_start_transport(struct ctdb_context *ctdb)
 
        /* start listening for recovery daemon pings */
        ctdb_control_recd_ping(ctdb);
+
+       /* start listening to timer ticks */
+       ctdb_start_time_tickd(ctdb);
 }
 
 static void block_signal(int signum)