Mercurial > dovecot > core-2.2
changeset 22335:510ee47cc21f
lib-index: If refreshing finds dovecot.index.log gone, assume the mailbox was deleted
Don't try to recreate the log file again. It can just cause further problems.
A way to reproduce this problem with NFS when INDEX dir is specified:
* create mailbox foo, select foo, IDLE
* delete mailbox foo
--> foo's index is recreated back by IDLEing process
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 14 Jul 2017 01:54:31 +0300 |
parents | 985aa5b0546b |
children | 8f674d4111cf |
files | src/lib-index/mail-transaction-log.c |
diffstat | 1 files changed, 9 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log.c Thu Jul 13 03:15:36 2017 +0300 +++ b/src/lib-index/mail-transaction-log.c Fri Jul 14 01:54:31 2017 +0300 @@ -336,27 +336,15 @@ *reason_r = t_strdup_printf("stat(%s) failed: %m", log->filepath); return -1; } - /* see if the whole directory got deleted */ - if (nfs_safe_stat(log->index->dir, &st) < 0 && - errno == ENOENT) { - log->index->index_deleted = TRUE; - *reason_r = "Index directory was deleted"; - return -1; - } - - /* the file should always exist at this point. if it doesn't, - someone deleted it manually while the index was open. try to - handle this nicely by creating a new log file. */ - file = log->head; - if (mail_transaction_log_create(log, FALSE) < 0) { - *reason_r = "Failed to create log"; - return -1; - } - i_assert(file->refcount > 0); - file->refcount--; - log->index->need_recreate = TRUE; - *reason_r = "Log created"; - return 0; + /* We shouldn't lose dovecot.index.log unless the mailbox was + deleted or renamed. Just fail this and let the mailbox + opening code figure out whether to create a new log file + or not. Anything else can cause unwanted behavior (e.g. + mailbox deletion not fully finishing due to .nfs* files and + an IDLEing IMAP process creating the index back here). */ + log->index->index_deleted = TRUE; + *reason_r = "Trasnaction log lost while it was open"; + return -1; } else if (log->head->st_ino == st.st_ino && CMP_DEV_T(log->head->st_dev, st.st_dev)) { /* NFS: log files get rotated to .log.2 files instead