From: Ronnie Sahlberg Date: Tue, 21 Aug 2007 23:46:48 +0000 (+1000) Subject: if lockwait takes an excessive time to complete. log the time it took to X-Git-Tag: tevent-0.9.20~348^2~2437^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5fef81a6f18ce7d6814b5e75a968a93ad77c9af8;p=thirdparty%2Fsamba.git if lockwait takes an excessive time to complete. log the time it took to complete and also the name of the database (This used to be ctdb commit 221ef0348fd8113a017d229d8c2c7aa5c4dfb5c2) --- diff --git a/ctdb/server/ctdb_lockwait.c b/ctdb/server/ctdb_lockwait.c index 5b0019836e8..ba2e1088eee 100644 --- a/ctdb/server/ctdb_lockwait.c +++ b/ctdb/server/ctdb_lockwait.c @@ -38,6 +38,9 @@ struct lockwait_handle { struct timeval start_time; }; + +/* This handler is called when a lockwait child process has completed the lock + */ static void lockwait_handler(struct event_context *ev, struct fd_event *fde, uint16_t flags, void *private_data) { @@ -49,10 +52,20 @@ static void lockwait_handler(struct event_context *ev, struct fd_event *fde, TDB_DATA key = h->key; struct tdb_context *tdb = h->ctdb_db->ltdb->tdb; TALLOC_CTX *tmp_ctx = talloc_new(ev); + double l; key.dptr = talloc_memdup(tmp_ctx, key.dptr, key.dsize); talloc_set_destructor(h, NULL); + + /* If a lockwait takes excessive time to complete we want + this logged + */ + l = timeval_elapsed(&h->start_time); + if (l > 1.0) { + DEBUG(0,("Lockwait took %.6f seconds to complete for database %s\n", l, h->ctdb_db->db_name)); + } + ctdb_latency(&h->ctdb->statistics.max_lockwait_latency, h->start_time); h->ctdb->statistics.pending_lockwait_calls--;