summaryrefslogtreecommitdiffstats
path: root/source3/lib/dbwrap
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2013-05-06 10:56:12 +0200
committerVolker Lendecke <vl@samba.org>2014-01-16 09:18:45 +0100
commitb64abab807655114285be578564fd5d3a5f5e2e1 (patch)
tree5e26005e70a2bef2224b15bd7624cc978c13e321 /source3/lib/dbwrap
parent34bfd0b6d210e9f617ace69dbf80a55f0988d81d (diff)
downloadsamba-b64abab807655114285be578564fd5d3a5f5e2e1.tar.gz
samba-b64abab807655114285be578564fd5d3a5f5e2e1.tar.xz
samba-b64abab807655114285be578564fd5d3a5f5e2e1.zip
dbwrap_ctdb: Instrument chainunlock timing
We need an indication whether we run into the fcntl thundering herd. fcntl unlock should be blindingly fast in the normal case. If it takes longer than 5 milliseconds, warn. The timeout can be adapted by setting ctdb:unlock_warn_threshold = <number-of-milliseconds> Reviewed-by: Christof Schmitt <cs@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/lib/dbwrap')
-rw-r--r--source3/lib/dbwrap/dbwrap_ctdb.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c
index fa2246b2a9d..b0baa147235 100644
--- a/source3/lib/dbwrap/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap/dbwrap_ctdb.c
@@ -944,6 +944,9 @@ static int db_ctdb_record_destr(struct db_record* data)
struct db_ctdb_rec *crec = talloc_get_type_abort(
data->private_data, struct db_ctdb_rec);
int threshold;
+ int ret;
+ struct timeval before;
+ double timediff;
DEBUG(10, (DEBUGLEVEL > 10
? "Unlocking db %u key %s\n"
@@ -952,11 +955,32 @@ static int db_ctdb_record_destr(struct db_record* data)
hex_encode_talloc(data, (unsigned char *)data->key.dptr,
data->key.dsize)));
- tdb_chainunlock(crec->ctdb_ctx->wtdb->tdb, data->key);
+ before = timeval_current();
+
+ ret = tdb_chainunlock(crec->ctdb_ctx->wtdb->tdb, data->key);
+
+ timediff = timeval_elapsed(&before);
+ timediff *= 1000; /* get us milliseconds */
+
+ if (timediff > lp_parm_int(-1, "ctdb", "unlock_warn_threshold", 5)) {
+ char *key;
+ key = hex_encode_talloc(talloc_tos(),
+ (unsigned char *)data->key.dptr,
+ data->key.dsize);
+ DEBUG(0, ("tdb_chainunlock on db %s, key %s took %f milliseconds\n",
+ tdb_name(crec->ctdb_ctx->wtdb->tdb), key,
+ timediff));
+ TALLOC_FREE(key);
+ }
+
+ if (ret != 0) {
+ DEBUG(0, ("tdb_chainunlock failed\n"));
+ return -1;
+ }
threshold = lp_ctdb_locktime_warn_threshold();
if (threshold != 0) {
- double timediff = timeval_elapsed(&crec->lock_time);
+ timediff = timeval_elapsed(&crec->lock_time);
if ((timediff * 1000) > threshold) {
const char *key;