dovecot-2.2: dsync: If incremental sync fails because of desync,...

dovecot at dovecot.org dovecot at dovecot.org
Mon May 12 10:22:10 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/1aa94368ab28
changeset: 17378:1aa94368ab28
user:      Timo Sirainen <tss at iki.fi>
date:      Mon May 12 13:21:28 2014 +0300
description:
dsync: If incremental sync fails because of desync, log the reason why

diffstat:

 src/doveadm/dsync/dsync-brain-mailbox.c        |  41 ++++++++++++++++++++-----
 src/doveadm/dsync/dsync-transaction-log-scan.c |   9 ++++-
 src/doveadm/dsync/dsync-transaction-log-scan.h |   3 +-
 3 files changed, 41 insertions(+), 12 deletions(-)

diffs (119 lines):

diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-brain-mailbox.c
--- a/src/doveadm/dsync/dsync-brain-mailbox.c	Mon May 12 12:51:50 2014 +0300
+++ b/src/doveadm/dsync/dsync-brain-mailbox.c	Mon May 12 13:21:28 2014 +0300
@@ -230,6 +230,8 @@
 	enum dsync_mailbox_exporter_flags exporter_flags = 0;
 	uint32_t last_common_uid, highest_wanted_uid;
 	uint64_t last_common_modseq, last_common_pvt_modseq;
+	const char *desync_reason = "";
+	bool pvt_too_old;
 	int ret;
 
 	i_assert(brain->log_scan == NULL);
@@ -245,31 +247,52 @@
 					      highest_wanted_uid,
 					      last_common_modseq,
 					      last_common_pvt_modseq,
-					      &brain->log_scan);
+					      &brain->log_scan, &pvt_too_old);
 	if (ret < 0) {
 		i_error("Failed to read transaction log for mailbox %s",
 			mailbox_get_vname(brain->box));
 		brain->failed = TRUE;
 		return -1;
 	}
+	if (ret == 0) {
+		if (pvt_too_old) {
+			desync_reason = t_strdup_printf(
+				"Private modseq %llu no longer in transaction log",
+				(unsigned long long)last_common_pvt_modseq);
+		} else {
+			desync_reason = t_strdup_printf(
+				"Modseq %llu no longer in transaction log",
+				(unsigned long long)last_common_modseq);
+		}
+	}
 
 	if (last_common_uid != 0) {
 		mailbox_get_open_status(brain->box, STATUS_UIDNEXT |
 					STATUS_HIGHESTMODSEQ |
 					STATUS_HIGHESTPVTMODSEQ, &status);
-		if (status.uidnext < last_common_uid ||
-		    status.highest_modseq < last_common_modseq ||
-		    status.highest_pvt_modseq < last_common_pvt_modseq) {
-			/* last_common_* is higher than our current ones.
-			   incremental sync state is stale, we need to do
-			   a full resync */
+		/* if last_common_* is higher than our current ones it means
+		   that the incremental sync state is stale and we need to do
+		   a full resync */
+		if (status.uidnext < last_common_uid) {
+			desync_reason = t_strdup_printf("uidnext %u < %u",
+				status.uidnext, last_common_uid);
+			ret = 0;
+		} else if (status.highest_modseq < last_common_modseq) {
+			desync_reason = t_strdup_printf("highest_modseq %llu < %llu",
+				(unsigned long long)status.highest_modseq,
+				(unsigned long long)last_common_modseq);
+			ret = 0;
+		} else if (status.highest_pvt_modseq < last_common_pvt_modseq) {
+			desync_reason = t_strdup_printf("highest_pvt_modseq %llu < %llu",
+				(unsigned long long)status.highest_pvt_modseq,
+				(unsigned long long)last_common_pvt_modseq);
 			ret = 0;
 		}
 	}
 	if (ret == 0) {
 		i_warning("Failed to do incremental sync for mailbox %s, "
-			  "retry with a full sync",
-			  mailbox_get_vname(brain->box));
+			  "retry with a full sync (%s)",
+			  mailbox_get_vname(brain->box), desync_reason);
 		brain->changes_during_sync = TRUE;
 		brain->require_full_resync = TRUE;
 		return 0;
diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-transaction-log-scan.c
--- a/src/doveadm/dsync/dsync-transaction-log-scan.c	Mon May 12 12:51:50 2014 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.c	Mon May 12 13:21:28 2014 +0300
@@ -506,12 +506,15 @@
 				    struct mail_index_view *pvt_view,
 				    uint32_t highest_wanted_uid,
 				    uint64_t modseq, uint64_t pvt_modseq,
-				    struct dsync_transaction_log_scan **scan_r)
+				    struct dsync_transaction_log_scan **scan_r,
+				    bool *pvt_too_old_r)
 {
 	struct dsync_transaction_log_scan *ctx;
 	pool_t pool;
 	int ret, ret2;
 
+	*pvt_too_old_r = FALSE;
+
 	pool = pool_alloconly_create(MEMPOOL_GROWING"dsync transaction log scan",
 				     10240);
 	ctx = p_new(pool, struct dsync_transaction_log_scan, 1);
@@ -528,8 +531,10 @@
 	if (pvt_view != NULL) {
 		if ((ret2 = dsync_log_scan(ctx, pvt_view, pvt_modseq, TRUE)) < 0)
 			return -1;
-		if (ret2 == 0)
+		if (ret2 == 0) {
 			ret = 0;
+			*pvt_too_old_r = TRUE;
+		}
 	}
 
 	*scan_r = ctx;
diff -r a21ac1261487 -r 1aa94368ab28 src/doveadm/dsync/dsync-transaction-log-scan.h
--- a/src/doveadm/dsync/dsync-transaction-log-scan.h	Mon May 12 12:51:50 2014 +0300
+++ b/src/doveadm/dsync/dsync-transaction-log-scan.h	Mon May 12 13:21:28 2014 +0300
@@ -14,7 +14,8 @@
 				    struct mail_index_view *pvt_view,
 				    uint32_t highest_wanted_uid,
 				    uint64_t modseq, uint64_t pvt_modseq,
-				    struct dsync_transaction_log_scan **scan_r);
+				    struct dsync_transaction_log_scan **scan_r,
+				    bool *pvt_too_old_r);
 HASH_TABLE_TYPE(dsync_uid_mail_change)
 dsync_transaction_log_scan_get_hash(struct dsync_transaction_log_scan *scan);
 HASH_TABLE_TYPE(dsync_attr_change)


More information about the dovecot-cvs mailing list