From: Timo Sirainen Date: Fri, 12 Oct 2012 05:31:15 +0000 (+0300) Subject: lib-index: Log a warning if locking transaction log takes longer than 30 secs. X-Git-Tag: 2.2.alpha1~20^2~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b886e3df92063a741201d5c37c4d52412ede2269;p=thirdparty%2Fdovecot%2Fcore.git lib-index: Log a warning if locking transaction log takes longer than 30 secs. --- diff --git a/src/lib-index/mail-transaction-log-private.h b/src/lib-index/mail-transaction-log-private.h index fa99ac397e..877d196944 100644 --- a/src/lib-index/mail-transaction-log-private.h +++ b/src/lib-index/mail-transaction-log-private.h @@ -10,6 +10,7 @@ struct dotlock_settings; mails. */ #define MAIL_TRANSCATION_LOG_LOCK_TIMEOUT (3*60) #define MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT (3*60) +#define MAIL_TRANSACTION_LOG_LOCK_WARN_SECS 30 /* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */ #define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*32) diff --git a/src/lib-index/mail-transaction-log.c b/src/lib-index/mail-transaction-log.c index f66e54421a..eb9a8ca4a2 100644 --- a/src/lib-index/mail-transaction-log.c +++ b/src/lib-index/mail-transaction-log.c @@ -416,6 +416,7 @@ int mail_transaction_log_find_file(struct mail_transaction_log *log, int mail_transaction_log_lock_head(struct mail_transaction_log *log) { struct mail_transaction_log_file *file; + time_t lock_wait_started, lock_secs = 0; int ret = 0; if (!log->log_2_unlink_checked) { @@ -437,6 +438,7 @@ int mail_transaction_log_lock_head(struct mail_transaction_log *log) can lock it and don't see another file, we can be sure no-one is creating a new log at the moment */ + lock_wait_started = time(NULL); for (;;) { file = log->head; if (mail_transaction_log_file_lock(file) < 0) @@ -451,6 +453,7 @@ int mail_transaction_log_lock_head(struct mail_transaction_log *log) if (ret == 0 && log->head == file) { /* success */ + lock_secs = file->lock_created - lock_wait_started; break; } @@ -462,6 +465,10 @@ int mail_transaction_log_lock_head(struct mail_transaction_log *log) /* try again */ } + if (lock_secs > MAIL_TRANSACTION_LOG_LOCK_WARN_SECS) { + i_warning("Locking transaction log file %s took %ld seconds", + log->head->filepath, (long)lock_secs); + } i_assert(ret < 0 || log->head != NULL); return ret;