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

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>
This commit is contained in:
Volker Lendecke 2013-02-01 12:49:52 +01:00
parent a92fd11ad1
commit 34bfd0b6d2

View File

@ -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);