]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Log a warning if locking transaction log takes longer than 30 secs.
authorTimo Sirainen <tss@iki.fi>
Fri, 12 Oct 2012 05:31:15 +0000 (08:31 +0300)
committerTimo Sirainen <tss@iki.fi>
Fri, 12 Oct 2012 05:31:15 +0000 (08:31 +0300)
src/lib-index/mail-transaction-log-private.h
src/lib-index/mail-transaction-log.c

index fa99ac397e7f750fe539908c4f435d2b583ab928..877d19694411891810d2d22deca02a10b10f5241 100644 (file)
@@ -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)
index f66e54421acdcfe82a7eda930aa38cf82beb896d..eb9a8ca4a2577b11164714d537d2c49d14ff6306 100644 (file)
@@ -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;