dovecot-2.2: lib-index: Log a warning if locking transaction log...

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 17:55:54 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/e44579c5b52b
changeset: 15306:e44579c5b52b
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Oct 12 08:31:15 2012 +0300
description:
lib-index: Log a warning if locking transaction log takes longer than 30 secs.

diffstat:

 src/lib-index/mail-transaction-log-private.h |  1 +
 src/lib-index/mail-transaction-log.c         |  7 +++++++
 2 files changed, 8 insertions(+), 0 deletions(-)

diffs (49 lines):

diff -r 9542732069ff -r e44579c5b52b src/lib-index/mail-transaction-log-private.h
--- a/src/lib-index/mail-transaction-log-private.h	Fri Oct 12 00:30:23 2012 +0300
+++ b/src/lib-index/mail-transaction-log-private.h	Fri Oct 12 08:31:15 2012 +0300
@@ -10,6 +10,7 @@
    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 -r 9542732069ff -r e44579c5b52b src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c	Fri Oct 12 00:30:23 2012 +0300
+++ b/src/lib-index/mail-transaction-log.c	Fri Oct 12 08:31:15 2012 +0300
@@ -416,6 +416,7 @@
 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 @@
 	   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 @@
 
 		if (ret == 0 && log->head == file) {
 			/* success */
+			lock_secs = file->lock_created - lock_wait_started;
 			break;
 		}
 
@@ -462,6 +465,10 @@
 
 		/* 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;


More information about the dovecot-cvs mailing list