dovecot-2.2: lib-index: Include reason string in warnings about ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Oct 9 15:26:46 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/fce66ec2ac1c
changeset: 17927:fce66ec2ac1c
user: Timo Sirainen <tss at iki.fi>
date: Thu Oct 09 18:26:05 2014 +0300
description:
lib-index: Include reason string in warnings about keeping transaction log locked for too long.
diffstat:
src/lib-index/mail-index-fsck.c | 2 +-
src/lib-index/mail-index-sync.c | 11 ++++++-----
src/lib-index/mail-transaction-log-append.c | 2 +-
src/lib-index/mail-transaction-log-file.c | 9 +++++----
src/lib-index/mail-transaction-log-private.h | 3 ++-
src/lib-index/mail-transaction-log.c | 14 +++++++++-----
src/lib-index/mail-transaction-log.h | 3 ++-
src/lib-index/test-mail-transaction-log-append.c | 3 ++-
8 files changed, 28 insertions(+), 19 deletions(-)
diffs (193 lines):
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-index-fsck.c
--- a/src/lib-index/mail-index-fsck.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-index-fsck.c Thu Oct 09 18:26:05 2014 +0300
@@ -457,7 +457,7 @@
mail_index_write(index, FALSE);
if (!orig_locked)
- mail_transaction_log_sync_unlock(index->log);
+ mail_transaction_log_sync_unlock(index->log, "fsck");
return 0;
}
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-index-sync.c
--- a/src/lib-index/mail-index-sync.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-index-sync.c Thu Oct 09 18:26:05 2014 +0300
@@ -348,14 +348,14 @@
if ((ret = mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD)) <= 0) {
if (ret == 0) {
if (locked)
- mail_transaction_log_sync_unlock(index->log);
+ mail_transaction_log_sync_unlock(index->log, "sync init failure");
return -1;
}
/* let's try again */
if (mail_index_map(index, MAIL_INDEX_SYNC_HANDLER_HEAD) <= 0) {
if (locked)
- mail_transaction_log_sync_unlock(index->log);
+ mail_transaction_log_sync_unlock(index->log, "sync init failure");
return -1;
}
}
@@ -363,7 +363,7 @@
if (!mail_index_need_sync(index, flags, log_file_seq, log_file_offset) &&
!index->index_deleted) {
if (locked)
- mail_transaction_log_sync_unlock(index->log);
+ mail_transaction_log_sync_unlock(index->log, "syncing determined unnecessary");
return 0;
}
@@ -379,7 +379,7 @@
(flags & MAIL_INDEX_SYNC_FLAG_DELETING_INDEX) == 0) {
/* index is already deleted. we can't sync. */
if (locked)
- mail_transaction_log_sync_unlock(index->log);
+ mail_transaction_log_sync_unlock(index->log, "syncing detected deleted index");
return -1;
}
@@ -725,7 +725,8 @@
*_ctx = NULL;
ctx->index->syncing = FALSE;
- mail_transaction_log_sync_unlock(ctx->index->log);
+ mail_transaction_log_sync_unlock(ctx->index->log,
+ "Mailbox was synchronized");
mail_index_view_close(&ctx->view);
mail_index_transaction_rollback(&ctx->sync_trans);
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-transaction-log-append.c Thu Oct 09 18:26:05 2014 +0300
@@ -247,7 +247,7 @@
ret = mail_transaction_log_append_locked(ctx);
if (!index->log_sync_locked)
- mail_transaction_log_file_unlock(index->log->head);
+ mail_transaction_log_file_unlock(index->log->head, "appending");
buffer_free(&ctx->output);
i_free(ctx);
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-transaction-log-file.c Thu Oct 09 18:26:05 2014 +0300
@@ -394,7 +394,8 @@
return -1;
}
-void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file)
+void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file,
+ const char *lock_reason)
{
unsigned int lock_time;
@@ -408,9 +409,9 @@
return;
lock_time = time(NULL) - file->lock_created;
- if (lock_time >= MAIL_TRANSACTION_LOG_LOCK_TIMEOUT) {
- i_warning("Transaction log file %s was locked for %u seconds",
- file->filepath, lock_time);
+ if (lock_time >= MAIL_TRANSACTION_LOG_LOCK_TIMEOUT && lock_reason != NULL) {
+ i_warning("Transaction log file %s was locked for %u seconds (%s)",
+ file->filepath, lock_time, lock_reason);
}
if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) {
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-transaction-log-private.h
--- a/src/lib-index/mail-transaction-log-private.h Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-transaction-log-private.h Thu Oct 09 18:26:05 2014 +0300
@@ -137,7 +137,8 @@
bool mail_transaction_log_want_rotate(struct mail_transaction_log *log);
int mail_transaction_log_rotate(struct mail_transaction_log *log, bool reset);
int mail_transaction_log_lock_head(struct mail_transaction_log *log);
-void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file);
+void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file,
+ const char *lock_reason);
void mail_transaction_update_modseq(const struct mail_transaction_header *hdr,
const void *data, uint64_t *cur_modseq);
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-transaction-log.c Thu Oct 09 18:26:05 2014 +0300
@@ -269,7 +269,9 @@
else {
/* the newly created log file is already locked */
i_assert(file->locked);
- mail_transaction_log_file_unlock(log->head);
+ mail_transaction_log_file_unlock(log->head,
+ !log->index->log_sync_locked ? "rotating" :
+ "rotating while syncing");
}
mail_transaction_log_set_head(log, file);
return 0;
@@ -448,6 +450,7 @@
file->refcount++;
ret = mail_transaction_log_refresh(log, TRUE);
if (--file->refcount == 0) {
+ mail_transaction_log_file_unlock(file, "trying to lock head");
mail_transaction_logs_clean(log);
file = NULL;
}
@@ -460,7 +463,7 @@
}
if (file != NULL)
- mail_transaction_log_file_unlock(file);
+ mail_transaction_log_file_unlock(file, "trying to lock head");
if (ret < 0)
break;
@@ -487,7 +490,7 @@
/* update sync_offset */
if (mail_transaction_log_file_map(log->head, log->head->sync_offset,
(uoff_t)-1) <= 0) {
- mail_transaction_log_file_unlock(log->head);
+ mail_transaction_log_file_unlock(log->head, "trying to lock syncing");
return -1;
}
@@ -497,12 +500,13 @@
return 0;
}
-void mail_transaction_log_sync_unlock(struct mail_transaction_log *log)
+void mail_transaction_log_sync_unlock(struct mail_transaction_log *log,
+ const char *log_reason)
{
i_assert(log->index->log_sync_locked);
log->index->log_sync_locked = FALSE;
- mail_transaction_log_file_unlock(log->head);
+ mail_transaction_log_file_unlock(log->head, log_reason);
}
void mail_transaction_log_get_head(struct mail_transaction_log *log,
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/mail-transaction-log.h
--- a/src/lib-index/mail-transaction-log.h Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/mail-transaction-log.h Thu Oct 09 18:26:05 2014 +0300
@@ -279,7 +279,8 @@
written to while it's locked. Returns end offset. */
int mail_transaction_log_sync_lock(struct mail_transaction_log *log,
uint32_t *file_seq_r, uoff_t *file_offset_r);
-void mail_transaction_log_sync_unlock(struct mail_transaction_log *log);
+void mail_transaction_log_sync_unlock(struct mail_transaction_log *log,
+ const char *lock_reason);
/* Returns the current head. Works only when log is locked. */
void mail_transaction_log_get_head(struct mail_transaction_log *log,
uint32_t *file_seq_r, uoff_t *file_offset_r);
diff -r 623a9f46c747 -r fce66ec2ac1c src/lib-index/test-mail-transaction-log-append.c
--- a/src/lib-index/test-mail-transaction-log-append.c Thu Oct 09 18:23:41 2014 +0300
+++ b/src/lib-index/test-mail-transaction-log-append.c Thu Oct 09 18:26:05 2014 +0300
@@ -22,7 +22,8 @@
return log_lock_failure ? -1 : 0;
}
-void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file ATTR_UNUSED) {}
+void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file ATTR_UNUSED,
+ const char *lock_reason ATTR_UNUSED) {}
void mail_transaction_update_modseq(const struct mail_transaction_header *hdr,
const void *data ATTR_UNUSED,
More information about the dovecot-cvs
mailing list