1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

add control and logging of very high latencies.

log the type of operation and the database name for all latencies higher
than a treshold

(This used to be ctdb commit 1d581dcd507e8e13d7ae085ff4d6a9f3e2aaeba5)
This commit is contained in:
Ronnie Sahlberg 2008-10-30 12:49:53 +11:00
parent 0e7fa751af
commit e1b0cea427
6 changed files with 17 additions and 9 deletions

View File

@ -124,12 +124,18 @@ static void *_idr_find_type(struct idr_context *idp, int id, const char *type, c
/*
update a max latency number
*/
void ctdb_latency(double *latency, struct timeval t)
void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t)
{
double l = timeval_elapsed(&t);
if (l > *latency) {
*latency = l;
}
if (ctdb_db->ctdb->tunable.log_latency_ms !=0) {
if (l > ctdb_db->ctdb->tunable.log_latency_ms) {
DEBUG(DEBUG_WARNING, ("High latency %f for operation %s on database %s\n", l, name, ctdb_db->db_name));
}
}
}
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state)

View File

@ -116,6 +116,7 @@ struct ctdb_tunable {
uint32_t verbose_memory_names;
uint32_t recd_ping_timeout;
uint32_t recd_ping_failcount;
uint32_t log_latency_ms;
};
/*
@ -967,7 +968,7 @@ void ctdb_recv_raw_pkt(void *p, uint8_t *data, uint32_t length);
int ctdb_socket_connect(struct ctdb_context *ctdb);
void ctdb_latency(double *latency, struct timeval t);
void ctdb_latency(struct ctdb_db_context *ctdb_db, const char *name, double *latency, struct timeval t);
uint32_t ctdb_reqid_new(struct ctdb_context *ctdb, void *state);
void *_ctdb_reqid_find(struct ctdb_context *ctdb, uint32_t reqid, const char *type, const char *location);

View File

@ -277,7 +277,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
if (res != 0) {
DEBUG(DEBUG_ERR, (__location__ " ctdbd_call_recv() returned error\n"));
client->ctdb->statistics.pending_calls--;
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
ctdb_latency(state->ctdb_db, "call_from_client_cb 1", &client->ctdb->statistics.max_call_latency, dstate->start_time);
return;
}
@ -287,7 +287,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
if (r == NULL) {
DEBUG(DEBUG_ERR, (__location__ " Failed to allocate reply_call in ctdb daemon\n"));
client->ctdb->statistics.pending_calls--;
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
ctdb_latency(state->ctdb_db, "call_from_client_cb 2", &client->ctdb->statistics.max_call_latency, dstate->start_time);
return;
}
r->hdr.reqid = dstate->reqid;
@ -298,7 +298,7 @@ static void daemon_call_from_client_callback(struct ctdb_call_state *state)
if (res != 0) {
DEBUG(DEBUG_ERR, (__location__ " Failed to queue packet from daemon to client\n"));
}
ctdb_latency(&client->ctdb->statistics.max_call_latency, dstate->start_time);
ctdb_latency(state->ctdb_db, "call_from_client_cb 3", &client->ctdb->statistics.max_call_latency, dstate->start_time);
talloc_free(dstate);
client->ctdb->statistics.pending_calls--;
}
@ -406,7 +406,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
ctdb_ltdb_unlock(ctdb_db, key);
DEBUG(DEBUG_ERR,(__location__ " Unable to allocate call\n"));
ctdb->statistics.pending_calls--;
ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
ctdb_latency(ctdb_db, "call_from_client 1", &ctdb->statistics.max_call_latency, dstate->start_time);
return;
}
@ -427,7 +427,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
if (state == NULL) {
DEBUG(DEBUG_ERR,(__location__ " Unable to setup call send\n"));
ctdb->statistics.pending_calls--;
ctdb_latency(&ctdb->statistics.max_call_latency, dstate->start_time);
ctdb_latency(ctdb_db, "call_from_client 2", &ctdb->statistics.max_call_latency, dstate->start_time);
return;
}
talloc_steal(state, dstate);

View File

@ -53,7 +53,7 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde,
key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize);
talloc_set_destructor(h, NULL);
ctdb_latency(&h->ctdb->statistics.max_lockwait_latency, h->start_time);
ctdb_latency(h->ctdb_db, "lockwait", &h->ctdb->statistics.max_lockwait_latency, h->start_time);
h->ctdb->statistics.pending_lockwait_calls--;
/* the handle needs to go away when the context is gone - when

View File

@ -330,7 +330,7 @@ static void childwrite_handler(struct event_context *ev, struct fd_event *fde,
int ret;
char c;
ctdb_latency(&h->ctdb->statistics.max_childwrite_latency, h->start_time);
ctdb_latency(h->ctdb_db, "persistent", &h->ctdb->statistics.max_childwrite_latency, h->start_time);
h->ctdb->statistics.pending_childwrite_calls--;
/* the handle needs to go away when the context is gone - when

View File

@ -52,6 +52,7 @@ static const struct {
{ "VerboseMemoryNames", 0, offsetof(struct ctdb_tunable, verbose_memory_names) },
{ "RecdPingTimeout", 20, offsetof(struct ctdb_tunable, recd_ping_timeout) },
{ "RecdFailCount", 3, offsetof(struct ctdb_tunable, recd_ping_failcount) },
{ "LogLatencyMs", 0, offsetof(struct ctdb_tunable, log_latency_ms) },
};
/*