1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

run monitoring more quickly when unhealthy and at startup

(This used to be ctdb commit ff1c205928e3ef5bcc6bf4e4b2122a19fa38d8f4)
This commit is contained in:
Andrew Tridgell 2007-09-24 10:12:18 +10:00
parent b87ddd9148
commit 80100c3573
3 changed files with 18 additions and 8 deletions

View File

@ -80,6 +80,7 @@ struct ctdb_tunable {
uint32_t election_timeout;
uint32_t takeover_timeout;
uint32_t monitor_interval;
uint32_t monitor_retry;
uint32_t tickle_update_interval;
uint32_t script_timeout;
uint32_t recovery_grace_period;

View File

@ -98,10 +98,7 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
TDB_DATA data;
struct ctdb_node_flag_change c;
event_add_timed(ctdb->ev, ctdb->monitor_context,
timeval_current_ofs(ctdb->tunable.monitor_interval, 0),
ctdb_check_health, ctdb);
uint32_t next_interval;
c.pnn = ctdb->pnn;
c.old_flags = node->flags;
@ -111,9 +108,20 @@ static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
node->flags |= NODE_FLAGS_UNHEALTHY;
} else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(0,("monitor event OK - node re-enabled\n"));
ctdb->nodes[ctdb->pnn]->flags &= ~NODE_FLAGS_UNHEALTHY;
node->flags &= ~NODE_FLAGS_UNHEALTHY;
}
if (node->flags & NODE_FLAGS_UNHEALTHY) {
next_interval = ctdb->tunable.monitor_retry;
} else {
/* no change */
next_interval = ctdb->tunable.monitor_interval;
}
event_add_timed(ctdb->ev, ctdb->monitor_context,
timeval_current_ofs(next_interval, 0),
ctdb_check_health, ctdb);
if (c.old_flags == node->flags) {
return;
}
@ -151,7 +159,7 @@ static void ctdb_check_health(struct event_context *ev, struct timed_event *te,
if (ret != 0) {
DEBUG(0,("Unable to launch monitor event script\n"));
event_add_timed(ctdb->ev, ctdb->monitor_context,
timeval_current_ofs(ctdb->tunable.monitor_interval, 0),
timeval_current_ofs(ctdb->tunable.monitor_retry, 0),
ctdb_check_health, ctdb);
}
}
@ -179,7 +187,7 @@ void ctdb_start_monitoring(struct ctdb_context *ctdb)
CTDB_NO_MEMORY_FATAL(ctdb, te);
te = event_add_timed(ctdb->ev, ctdb->monitor_context,
timeval_current_ofs(ctdb->tunable.monitor_interval, 0),
timeval_current_ofs(ctdb->tunable.monitor_retry, 0),
ctdb_check_health, ctdb);
CTDB_NO_MEMORY_FATAL(ctdb, te);
}

View File

@ -36,6 +36,7 @@ static const struct {
{ "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) },
{ "TakeoverTimeout", 5, offsetof(struct ctdb_tunable, takeover_timeout) },
{ "MonitorInterval", 15, offsetof(struct ctdb_tunable, monitor_interval) },
{ "MonitorRetry", 5, offsetof(struct ctdb_tunable, monitor_retry) },
{ "TickleUpdateInterval",20, offsetof(struct ctdb_tunable, tickle_update_interval) },
{ "EventScriptTimeout", 20, offsetof(struct ctdb_tunable, script_timeout) },
{ "RecoveryGracePeriod", 60, offsetof(struct ctdb_tunable, recovery_grace_period) },