Mercurial > dovecot > core-2.2
changeset 12164:41b3ab0a3241
maildir: Log a warning if mailbox synchronization takes longer than 1 min.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 23 Sep 2010 18:39:22 +0100 |
parents | 62d3c2dfee6d |
children | acd30d4601f9 |
files | src/lib-storage/index/maildir/maildir-save.c src/lib-storage/index/maildir/maildir-sync-index.c src/lib-storage/index/maildir/maildir-sync.h |
diffstat | 3 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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 {
--- 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,