diff options
author | Volker Lendecke <vl@samba.org> | 2013-02-01 12:49:52 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2014-01-16 09:18:45 +0100 |
commit | 34bfd0b6d210e9f617ace69dbf80a55f0988d81d (patch) | |
tree | 6f8324a4ee07a01b1b6c4fbfab03813a02df392b /source3/lib | |
parent | a92fd11ad1ccc904a999a254d249bbdc74f08f84 (diff) | |
download | samba-34bfd0b6d210e9f617ace69dbf80a55f0988d81d.tar.gz samba-34bfd0b6d210e9f617ace69dbf80a55f0988d81d.tar.xz samba-34bfd0b6d210e9f617ace69dbf80a55f0988d81d.zip |
ctdb_conn: Log long fetch_lock calls
With this patch, the number of fetch_lock attempts before dbwrap_ctdb
logs that it took x attempts to get a record is configurable with
net conf setparm global ctdb:migrate_attempts 10
This patch also adds
net conf setparm global ctdb:migrate_duration 5000
to trigger the same log message if it took longer than x milliseconds
to retrieve a record.
Reviewed-by: Christof Schmitt <cs@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/dbwrap/dbwrap_ctdb.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source3/lib/dbwrap/dbwrap_ctdb.c b/source3/lib/dbwrap/dbwrap_ctdb.c index 5a473f98af..fa2246b2a9 100644 --- a/source3/lib/dbwrap/dbwrap_ctdb.c +++ b/source3/lib/dbwrap/dbwrap_ctdb.c @@ -1017,7 +1017,9 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx, struct db_ctdb_rec *crec; NTSTATUS status; TDB_DATA ctdb_data; - int migrate_attempts = 0; + int migrate_attempts; + struct timeval migrate_start; + int duration_msecs; int lockret; if (!(result = talloc(mem_ctx, struct db_record))) { @@ -1044,6 +1046,9 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx, return NULL; } + migrate_attempts = 0; + GetTimeOfDay(&migrate_start); + /* * Do a blocking lock on the record */ @@ -1110,13 +1115,26 @@ again: goto again; } - if (migrate_attempts > 10) { + { + double duration; + duration = timeval_elapsed(&migrate_start); + + /* + * Convert the duration to milliseconds to avoid a + * floating-point division of + * lp_parm_int("migrate_duration") by 1000. + */ + duration_msecs = duration * 1000; + } + + if ((migrate_attempts > lp_parm_int(-1, "ctdb", "migrate_attempts", 10)) || + (duration_msecs > lp_parm_int(-1, "ctdb", "migrate_duration", 5000))) { DEBUG(0, ("db_ctdb_fetch_locked for %s key %s needed %d " - "attempts\n", tdb_name(ctx->wtdb->tdb), + "attempts, %d milliseconds\n", tdb_name(ctx->wtdb->tdb), hex_encode_talloc(talloc_tos(), (unsigned char *)key.dptr, key.dsize), - migrate_attempts)); + migrate_attempts, duration_msecs)); } GetTimeOfDay(&crec->lock_time); |