dovecot-2.2: dsync: If unexpected changes happened during sync, ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 5 17:15:06 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/5593d6129712
changeset: 16454:5593d6129712
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 05 17:14:49 2013 +0300
description:
dsync: If unexpected changes happened during sync, log a warning and exit with code 2.
This was done by v2.1 dsync, but the code got temporarily lost in v2.2.

diffstat:

 src/doveadm/dsync/doveadm-dsync.c |  13 +++++++++++--
 src/doveadm/dsync/dsync-brain.c   |   5 +++++
 src/doveadm/dsync/dsync-brain.h   |   2 ++
 3 files changed, 18 insertions(+), 2 deletions(-)

diffs (74 lines):

diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Wed Jun 05 16:40:01 2013 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Wed Jun 05 17:14:49 2013 +0300
@@ -291,7 +291,8 @@
 
 static int
 cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
-		    struct dsync_brain *brain, struct dsync_ibc *ibc2)
+		    struct dsync_brain *brain, struct dsync_ibc *ibc2,
+		    bool *changes_during_sync_r)
 {
 	struct dsync_brain *brain2;
 	struct mail_user *user2;
@@ -357,6 +358,7 @@
 		brain2_running = dsync_brain_run(brain2, &changed2);
 	}
 	mail_user_unref(&user2);
+	*changes_during_sync_r = dsync_brain_has_unexpected_changes(brain2);
 	if (dsync_brain_deinit(&brain2) < 0) {
 		ctx->ctx.exit_code = EX_TEMPFAIL;
 		return -1;
@@ -490,6 +492,7 @@
 	struct dsync_brain_settings set;
 	enum dsync_brain_flags brain_flags;
 	bool remote_errors_logged = FALSE;
+	bool changes_during_sync = FALSE;
 	int status = 0, ret = 0;
 
 	memset(&set, 0, sizeof(set));
@@ -540,7 +543,8 @@
 					brain_flags, &set);
 
 	if (ctx->run_type == DSYNC_RUN_TYPE_LOCAL) {
-		if (cmd_dsync_run_local(ctx, user, brain, ibc2) < 0)
+		if (cmd_dsync_run_local(ctx, user, brain, ibc2,
+					&changes_during_sync) < 0)
 			ret = -1;
 	} else {
 		cmd_dsync_run_remote(user);
@@ -552,6 +556,11 @@
 		doveadm_print(str_c(state_str));
 	}
 
+	if (dsync_brain_has_unexpected_changes(brain) || changes_during_sync) {
+		i_warning("Mailbox changes caused a desync. "
+			  "You may want to run dsync again.");
+		ctx->ctx.exit_code = 2;
+	}
 	if (dsync_brain_deinit(&brain) < 0) {
 		ctx->ctx.exit_code = EX_TEMPFAIL;
 		ret = -1;
diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c	Wed Jun 05 16:40:01 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain.c	Wed Jun 05 17:14:49 2013 +0300
@@ -513,3 +513,8 @@
 {
 	return brain->failed;
 }
+
+bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain)
+{
+	return brain->changes_during_sync;
+}
diff -r bcf93c30a500 -r 5593d6129712 src/doveadm/dsync/dsync-brain.h
--- a/src/doveadm/dsync/dsync-brain.h	Wed Jun 05 16:40:01 2013 +0300
+++ b/src/doveadm/dsync/dsync-brain.h	Wed Jun 05 17:14:49 2013 +0300
@@ -67,5 +67,7 @@
 void dsync_brain_get_state(struct dsync_brain *brain, string_t *output);
 /* Returns the sync type that was used. Mainly useful with slave brain. */
 enum dsync_brain_sync_type dsync_brain_get_sync_type(struct dsync_brain *brain);
+/* Returns TRUE if there were any unexpected changes during the sync. */
+bool dsync_brain_has_unexpected_changes(struct dsync_brain *brain);
 
 #endif


More information about the dovecot-cvs mailing list