dovecot-2.0: maildir: Log a warning if mailbox synchronization t...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Sep 23 20:39:41 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/41b3ab0a3241
changeset: 12164:41b3ab0a3241
user: Timo Sirainen <tss at iki.fi>
date: Thu Sep 23 18:39:22 2010 +0100
description:
maildir: Log a warning if mailbox synchronization takes longer than 1 min.
diffstat:
src/lib-storage/index/maildir/maildir-save.c | 1 +
src/lib-storage/index/maildir/maildir-sync-index.c | 27 +++++++++++++++++++++++++++
src/lib-storage/index/maildir/maildir-sync.h | 2 ++
3 files changed, 30 insertions(+), 0 deletions(-)
diffs (104 lines):
diff -r 62d3c2dfee6d -r 41b3ab0a3241 src/lib-storage/index/maildir/maildir-save.c
--- a/src/lib-storage/index/maildir/maildir-save.c Thu Sep 23 18:21:09 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-save.c Thu Sep 23 18:39:22 2010 +0100
@@ -863,6 +863,7 @@
prev_mf = mf;
}
+ maildir_sync_set_new_msgs_count(ctx->sync_ctx, array_count(&files));
return maildir_transaction_fsync_dirs(ctx, new_changed, cur_changed);
}
diff -r 62d3c2dfee6d -r 41b3ab0a3241 src/lib-storage/index/maildir/maildir-sync-index.c
--- a/src/lib-storage/index/maildir/maildir-sync-index.c Thu Sep 23 18:21:09 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-sync-index.c Thu Sep 23 18:39:22 2010 +0100
@@ -15,6 +15,8 @@
#include <stdlib.h>
#include <unistd.h>
+#define MAILDIR_SYNC_TIME_WARN_SECS 60
+
struct maildir_index_sync_context {
struct maildir_mailbox *mbox;
struct maildir_sync_context *maildir_sync_ctx;
@@ -31,6 +33,9 @@
uint32_t uid;
bool update_maildir_hdr_cur;
+
+ time_t start_time;
+ unsigned int flag_change_count, expunge_count, new_msgs_count;
};
struct maildir_keywords_sync_ctx *
@@ -39,6 +44,12 @@
return ctx->keywords_sync_ctx;
}
+void maildir_sync_set_new_msgs_count(struct maildir_index_sync_context *ctx,
+ unsigned int count)
+{
+ ctx->new_msgs_count = count;
+}
+
static bool
maildir_expunge_is_valid_guid(struct maildir_index_sync_context *ctx,
uint32_t uid, const char *filename,
@@ -76,6 +87,8 @@
{
struct mailbox *box = &mbox->box;
+ ctx->expunge_count++;
+
if (unlink(path) == 0) {
if (box->v.sync_notify != NULL) {
box->v.sync_notify(box, ctx->uid,
@@ -100,6 +113,8 @@
enum mail_index_sync_type sync_type;
uint8_t flags8;
+ ctx->flag_change_count++;
+
fname = strrchr(path, '/');
i_assert(fname != NULL);
fname++;
@@ -228,6 +243,7 @@
ctx->sync_changes =
index_sync_changes_init(ctx->sync_ctx, ctx->view, ctx->trans,
mbox->box.backend_readonly);
+ ctx->start_time = time(NULL);
*ctx_r = ctx;
return 0;
@@ -286,8 +302,19 @@
bool success)
{
struct maildir_mailbox *mbox = ctx->mbox;
+ unsigned int time_diff;
int ret = success ? 0 : -1;
+ time_diff = time(NULL) - ctx->start_time;
+ if (time_diff >= MAILDIR_SYNC_TIME_WARN_SECS) {
+ i_warning("Maildir %s: Synchronization took %u seconds "
+ "(%u new msgs, %u flag change attempts, "
+ "%u expunge attempts)",
+ ctx->mbox->box.path, time_diff,
+ ctx->new_msgs_count, ctx->flag_change_count,
+ ctx->expunge_count);
+ }
+
if (ret < 0)
mail_index_sync_rollback(&ctx->sync_ctx);
else {
diff -r 62d3c2dfee6d -r 41b3ab0a3241 src/lib-storage/index/maildir/maildir-sync.h
--- a/src/lib-storage/index/maildir/maildir-sync.h Thu Sep 23 18:21:09 2010 +0100
+++ b/src/lib-storage/index/maildir/maildir-sync.h Thu Sep 23 18:39:22 2010 +0100
@@ -37,6 +37,8 @@
struct maildir_keywords_sync_ctx *
maildir_sync_get_keywords_sync_ctx(struct maildir_index_sync_context *ctx);
void maildir_sync_notify(struct maildir_sync_context *ctx);
+void maildir_sync_set_new_msgs_count(struct maildir_index_sync_context *ctx,
+ unsigned int count);
int maildir_list_index_has_changed(struct mailbox *box,
struct mail_index_view *list_view,
More information about the dovecot-cvs
mailing list