This adds more serialisation to the startup, ensuring that the
"startup" event runs after everything to do with the first recovery
(including the "recovered" event).
Given that it now takes longer to get to the "startup" state, the
initscript needs to wait until ctdbd gets to "first_recovery".
Signed-off-by: Martin Schwenke <martin@meltin.net>
Pair-programmed-with: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit
ed6814ff0a59ddbb1c1b3128b505380f60d7aeb7)
{ CTDB_RUNSTATE_UNKNOWN, "UNKNOWN" },
{ CTDB_RUNSTATE_INIT, "INIT" },
{ CTDB_RUNSTATE_SETUP, "SETUP" },
+ { CTDB_RUNSTATE_FIRST_RECOVERY, "FIRST_RECOVERY" },
{ CTDB_RUNSTATE_STARTUP, "STARTUP" },
{ CTDB_RUNSTATE_RUNNING, "RUNNING" },
{ CTDB_RUNSTATE_SHUTDOWN, "SHUTDOWN" },
_timeout="${1:-10}" # default is 10 seconds
_count=0
- while ! ctdb runstate startup running >/dev/null 2>&1 ; do
+ while ! ctdb runstate first_recovery startup running >/dev/null 2>&1 ; do
if [ $_count -ge $_timeout ] ; then
return 1
fi
</screen>
</refsect2>
- <refsect2><title>runstate [setup|startup|running]</title>
+ <refsect2><title>runstate [setup|first_recovery|startup|running]</title>
<para>
Print the runstate of the specified node. Runstates are used
to serialise important state transitions in CTDB, particularly
CTDB_RUNSTATE_UNKNOWN,
CTDB_RUNSTATE_INIT,
CTDB_RUNSTATE_SETUP,
+ CTDB_RUNSTATE_FIRST_RECOVERY,
CTDB_RUNSTATE_STARTUP,
CTDB_RUNSTATE_RUNNING,
CTDB_RUNSTATE_SHUTDOWN,
}
ctdb_run_notification_script(ctdb, "setup");
- ctdb_set_runstate(ctdb, CTDB_RUNSTATE_STARTUP);
+ ctdb_set_runstate(ctdb, CTDB_RUNSTATE_FIRST_RECOVERY);
/* tell all other nodes we've just started up */
ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL,
}
ctdb->db_persistent_check_errors = 0;
- DEBUG(DEBUG_NOTICE,(__location__ " Recoveries finished. Running the \"startup\" event.\n"));
event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
timeval_current(),
ctdb_check_health, ctdb);
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
int ret = 0;
+ if (ctdb->runstate < CTDB_RUNSTATE_STARTUP) {
+ DEBUG(DEBUG_NOTICE,("Not yet in startup runstate. Wait one more second\n"));
+ event_add_timed(ctdb->ev, ctdb->monitor->monitor_context,
+ timeval_current_ofs(1, 0),
+ ctdb_check_health, ctdb);
+ return;
+ }
+
if (ctdb->recovery_mode != CTDB_RECOVERY_NORMAL ||
(ctdb->monitor->monitoring_mode == CTDB_MONITORING_DISABLED &&
ctdb->runstate == CTDB_RUNSTATE_RUNNING)) {
}
if (ctdb->runstate == CTDB_RUNSTATE_STARTUP) {
+ DEBUG(DEBUG_NOTICE,("Recoveries finished. Running the \"startup\" event.\n"));
ret = ctdb_event_script_callback(ctdb,
ctdb->monitor->monitor_context, ctdb_startup_callback,
ctdb, false,
talloc_free(state);
gettimeofday(&ctdb->last_recovery_finished, NULL);
+
+ if (ctdb->runstate == CTDB_RUNSTATE_FIRST_RECOVERY) {
+ ctdb_set_runstate(ctdb, CTDB_RUNSTATE_STARTUP);
+ }
}
/*
{ "status", control_status, true, false, "show node status" },
{ "uptime", control_uptime, true, false, "show node uptime" },
{ "ping", control_ping, true, false, "ping all nodes" },
- { "runstate", control_runstate, true, false, "get/check runstate of a node", "[setup|startup|running]" },
+ { "runstate", control_runstate, true, false, "get/check runstate of a node", "[setup|first_recovery|startup|running]" },
{ "getvar", control_getvar, true, false, "get a tunable variable", "<name>"},
{ "setvar", control_setvar, true, false, "set a tunable variable", "<name> <value>"},
{ "listvars", control_listvars, true, false, "list tunable variables"},