if (brain->box_importer != NULL) {
uint32_t last_common_uid, last_messages_count;
uint64_t last_common_modseq, last_common_pvt_modseq;
- bool changes_during_sync;
+ bool changes_during_sync, require_full_resync;
i_assert(brain->failed);
(void)dsync_mailbox_import_deinit(&brain->box_importer,
&last_common_pvt_modseq,
&last_messages_count,
&changes_during_sync,
+ &require_full_resync,
&brain->mail_error);
+ if (require_full_resync)
+ brain->require_full_resync = TRUE;
}
if (brain->log_scan != NULL)
dsync_transaction_log_scan_deinit(&brain->log_scan);
static void dsync_brain_sync_half_finished(struct dsync_brain *brain)
{
struct dsync_mailbox_state state;
+ bool require_full_resync;
if (brain->box_recv_state < DSYNC_BOX_STATE_RECV_LAST_COMMON ||
brain->box_send_state < DSYNC_BOX_STATE_RECV_LAST_COMMON)
&state.last_common_pvt_modseq,
&state.last_messages_count,
&state.changes_during_sync,
+ &require_full_resync,
&brain->mail_error) < 0) {
- brain->failed = TRUE;
- return;
+ if (require_full_resync) {
+ /* don't treat this as brain failure or the
+ state won't be sent to the other brain.
+ this also means we'll continue syncing the
+ following mailboxes. */
+ brain->require_full_resync = TRUE;
+ } else {
+ brain->failed = TRUE;
+ }
}
if (state.changes_during_sync)
brain->changes_during_sync = TRUE;
}
+ if (brain->require_full_resync) {
+ state.last_uidvalidity = 0;
+ state.changes_during_sync = TRUE;
+ }
brain->mailbox_state = state;
dsync_ibc_send_mailbox_state(brain->ibc, &state);
}
enum mail_error mail_error;
unsigned int failed:1;
+ unsigned int require_full_resync:1;
unsigned int debug:1;
unsigned int stateful_import:1;
unsigned int last_common_uid_found:1;
"(dsync must be run again without the state)",
mailbox_get_vname(importer->box), error);
}
- importer->mail_error = MAIL_ERROR_TEMP;
- importer->failed = TRUE;
+ importer->require_full_resync = TRUE;
}
static void
if (importer->failed)
return -1;
+ if (importer->require_full_resync)
+ return 0;
if (!importer->last_common_uid_found) {
result = NULL;
if (importer->failed)
return -1;
+ if (importer->require_full_resync)
+ return 0;
if (importer->last_common_uid_found) {
/* a) uid <= last_common_uid for flag changes and expunges.
if (importer->failed)
return -1;
+ if (importer->require_full_resync)
+ return 0;
imp_debug(importer, "Import mail body for GUID=%s UID=%u",
mail->guid, mail->uid);
uint64_t *last_common_pvt_modseq_r,
uint32_t *last_messages_count_r,
bool *changes_during_sync_r,
+ bool *require_full_resync_r,
enum mail_error *error_r)
{
struct dsync_mailbox_importer *importer = *_importer;
*_importer = NULL;
*changes_during_sync_r = FALSE;
+ *require_full_resync_r = importer->require_full_resync;
- if (!success && !importer->failed) {
+ if ((!success || importer->require_full_resync) && !importer->failed) {
importer->mail_error = MAIL_ERROR_TEMP;
importer->failed = TRUE;
}
uint64_t *last_common_pvt_modseq_r,
uint32_t *last_messages_count_r,
bool *changes_during_sync_r,
+ bool *require_full_resync_r,
enum mail_error *error_r);
const char *dsync_mailbox_import_get_proctitle(struct dsync_mailbox_importer *importer);