mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
make recovery daemon values tunable
(This used to be ctdb commit ec29dbf2f5110428df8b97801443ba7addf61353)
This commit is contained in:
parent
fcce534f23
commit
39ced972ae
@ -523,14 +523,7 @@ struct ctdb_context *ctdb_init(struct event_context *ev)
|
||||
ctdb->recovery_lock_fd = -1;
|
||||
ctdb->monitoring_mode = CTDB_MONITORING_ACTIVE;
|
||||
|
||||
/* set default values for tunables */
|
||||
ctdb->tunable.max_redirect_count = 3;
|
||||
ctdb->tunable.seqnum_frequency = 1;
|
||||
ctdb->tunable.control_timeout = 60;
|
||||
ctdb->tunable.traverse_timeout = 20;
|
||||
ctdb->tunable.monitoring_timeout = 2;
|
||||
ctdb->tunable.monitoring_limit = 3;
|
||||
ctdb->tunable.max_lacount = 7;
|
||||
ctdb_tunables_set_defaults(ctdb);
|
||||
|
||||
return ctdb;
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ static void timeout_func(struct event_context *ev, struct timed_event *te,
|
||||
timed_out = 1;
|
||||
}
|
||||
|
||||
#define CONTROL_TIMEOUT() timeval_current_ofs(5, 0)
|
||||
#define MONITOR_TIMEOUT() timeval_current_ofs(1, 0)
|
||||
#define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0)
|
||||
#define MONITOR_TIMEOUT() timeval_current_ofs(ctdb->tunable.monitor_frequency, 0)
|
||||
|
||||
static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t rec_mode)
|
||||
{
|
||||
@ -50,7 +50,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no
|
||||
}
|
||||
|
||||
if (rec_mode == CTDB_RECOVERY_ACTIVE) {
|
||||
ret = ctdb_ctrl_freeze(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
|
||||
ret = ctdb_ctrl_freeze(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
|
||||
if (ret != 0) {
|
||||
DEBUG(0, (__location__ " Unable to freeze node %u\n", nodemap->nodes[j].vnn));
|
||||
return -1;
|
||||
@ -64,7 +64,7 @@ static int set_recovery_mode(struct ctdb_context *ctdb, struct ctdb_node_map *no
|
||||
}
|
||||
|
||||
if (rec_mode == CTDB_RECOVERY_NORMAL) {
|
||||
ret = ctdb_ctrl_thaw(ctdb, timeval_current_ofs(5, 0), nodemap->nodes[j].vnn);
|
||||
ret = ctdb_ctrl_thaw(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].vnn);
|
||||
if (ret != 0) {
|
||||
DEBUG(0, (__location__ " Unable to thaw node %u\n", nodemap->nodes[j].vnn));
|
||||
return -1;
|
||||
@ -652,14 +652,16 @@ static void force_election(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint3
|
||||
|
||||
/* wait for a few seconds to collect all responses */
|
||||
timed_out = 0;
|
||||
event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(3, 0),
|
||||
event_add_timed(ctdb->ev, mem_ctx, timeval_current_ofs(ctdb->tunable.election_timeout, 0),
|
||||
timeout_func, ctdb);
|
||||
while (!timed_out) {
|
||||
event_loop_once(ctdb->ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
the main monitoring loop
|
||||
*/
|
||||
void monitor_cluster(struct ctdb_context *ctdb)
|
||||
{
|
||||
uint32_t vnn, num_active, recmode, recmaster;
|
||||
@ -688,6 +690,14 @@ again:
|
||||
event_loop_once(ctdb->ev);
|
||||
}
|
||||
|
||||
/* get relevant tunables */
|
||||
ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE,
|
||||
"RecoverTimeout", &ctdb->tunable.recover_timeout);
|
||||
ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE,
|
||||
"MonitorFrequency", &ctdb->tunable.monitor_frequency);
|
||||
ctdb_ctrl_get_tunable(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE,
|
||||
"ElectionTimeout", &ctdb->tunable.election_timeout);
|
||||
|
||||
vnn = ctdb_ctrl_getvnn(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE);
|
||||
if (vnn == (uint32_t)-1) {
|
||||
DEBUG(0,("Failed to get local vnn - retrying\n"));
|
||||
|
@ -22,17 +22,32 @@
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
size_t offset;
|
||||
uint32_t default_v;
|
||||
size_t offset;
|
||||
} tunable_map[] = {
|
||||
{ "MaxRedirectCount", offsetof(struct ctdb_tunable, max_redirect_count) },
|
||||
{ "SeqnumFrequency", offsetof(struct ctdb_tunable, seqnum_frequency) },
|
||||
{ "ControlTimeout", offsetof(struct ctdb_tunable, control_timeout) },
|
||||
{ "TraverseTimeout", offsetof(struct ctdb_tunable, traverse_timeout) },
|
||||
{ "MonitoringTimeout", offsetof(struct ctdb_tunable, monitoring_timeout) },
|
||||
{ "MonitoringLimit", offsetof(struct ctdb_tunable, monitoring_limit) },
|
||||
{ "MaxLACount", offsetof(struct ctdb_tunable, max_lacount) },
|
||||
{ "MaxRedirectCount", 3, offsetof(struct ctdb_tunable, max_redirect_count) },
|
||||
{ "SeqnumFrequency", 1, offsetof(struct ctdb_tunable, seqnum_frequency) },
|
||||
{ "ControlTimeout", 60, offsetof(struct ctdb_tunable, control_timeout) },
|
||||
{ "TraverseTimeout", 20, offsetof(struct ctdb_tunable, traverse_timeout) },
|
||||
{ "MonitoringTimeout", 2, offsetof(struct ctdb_tunable, monitoring_timeout) },
|
||||
{ "MonitoringLimit", 3, offsetof(struct ctdb_tunable, monitoring_limit) },
|
||||
{ "MaxLACount", 7, offsetof(struct ctdb_tunable, max_lacount) },
|
||||
{ "RecoverTimeout", 5, offsetof(struct ctdb_tunable, recover_timeout) },
|
||||
{ "MonitorFrequency", 1, offsetof(struct ctdb_tunable, monitor_frequency) },
|
||||
{ "ElectionTimeout", 3, offsetof(struct ctdb_tunable, election_timeout) },
|
||||
};
|
||||
|
||||
/*
|
||||
set all tunables to defaults
|
||||
*/
|
||||
void ctdb_tunables_set_defaults(struct ctdb_context *ctdb)
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<ARRAY_SIZE(tunable_map);i++) {
|
||||
*(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable) = tunable_map[i].default_v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
get a tunable
|
||||
|
@ -47,6 +47,9 @@ struct ctdb_tunable {
|
||||
uint32_t monitoring_timeout;
|
||||
uint32_t monitoring_limit;
|
||||
uint32_t max_lacount;
|
||||
uint32_t recover_timeout;
|
||||
uint32_t monitor_frequency;
|
||||
uint32_t election_timeout;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -971,4 +974,6 @@ int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
|
||||
int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
||||
|
||||
void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user