mail-transaction-log-file.c revision 85144b5f0bc763de14c7d87291a90ef74ac241a2
1516N/A/* Copyright (c) 2003-2008 Dovecot authors, see the included COPYING file */ 2084N/A /* indexid=0 marks the log file as corrupted */ 2339N/A "Corrupted transaction log file %s: %s",
2339N/A /* we can get a valid log offset from index file. initialize 2339N/A sync_offset from it so we don't have to read the whole log 2339N/A "%s: log_file_head_offset too small",
2339N/A /* highest_modseq not synced, start from beginning */ 2339N/A "%s: modseq_hdr.log_offset too large",
2339N/A /* start from where we last stopped tracking modseqs */ 3337N/A /* insert it to correct position */ 3337N/A /* not creating index - make sure we have latest header */ 3337N/A /* if we got here from mapping, the .log file is 2084N/A corrupted. use whatever values we got from index 1505N/A /* make sure the sequence grows */ 222N/A /* this should be always up-to-date */ 2084N/A "Timeout while waiting for " 2958N/A "dotlock for transaction log file %s",
3366N/A "Dotlock was lost for transaction log file %s",
2905N/A "mail_index_wait_lock_fd()");
3337N/A "Timeout while waiting for lock for transaction log file %s",
2185N/A "unexpected end of file while reading header");
2528N/A /* incompatible version - fix silently */ 2528N/A /* @UNSAFE: smaller than we expected - zero out the fields we 2528N/A "Transaction log file %s: marked corrupted",
2528N/A /* index file was probably just rebuilt and we don't 2528N/A "indexid changed %u -> %u",
2528N/A /* creating index file. since transaction log is created 2528N/A first, use the indexid in it to create the main index 2528N/A /* make sure we already don't have a file with the same sequence 2528N/A opened. it shouldn't happen unless the old log file was 2528N/A /* mark the old file corrupted. we can't safely remove 2528N/A it from the list however, so return failure. */ 2528N/A "duplicate transaction log sequence (%u)",
2528N/A /* although we check also mtime and file size below, it's done 2476N/A only to fix broken log files. we don't bother flushing 2476N/A attribute cache just for that. */ 2476N/A /* log creation is locked now - see if someone already created it. 2476N/A note that if we're rotating, we need to keep the log locked until 2476N/A the file has been rewritten. and because fcntl() locks are stupid, 3337N/A if we go and open()+close() the file and we had it already opened, 3337N/A its locks are lost. so we use stat() to check if the file has been 2476N/A recreated, although it almost never is. */ 3366N/A but not when we're replacing a broken log file */ 3366N/A /* no-one else recreated the file */ 3366N/A /* recreated. use the file if its header is ok */ /* the header isn't important, so don't bother calling fdatasync() unless NFS is used */ /* we'll need to preserve the lock */ /* if we return -1 the dotlock deletion code closes the fd */ /* rename() would be nice and easy way to do this, except then there's a race condition between the rename and file_dotlock_replace(). during that time the log file doesn't exist, which could cause problems. */ /* try to link() anyway */ /* ignore the error. we don't care that much about the second log file and we're going to overwrite this /* With dotlocking we might already have path.lock created, so this filename has to be different. */ /* either fd gets used or the dotlock gets deleted and returned fd is for the existing file */ "header update extends beyond record size");
"log_file_tail_offset shrank");
/* modseqs not tracked yet. see if this is a modseq extension introduction. */ /* modseq tracking started */ /* not tracking modseqs */ /* ignore expunge requests */ /* these changes increase modseq */ /* @UNSAFE: move it to top */ unsigned int i,
best = -
1U;
unsigned int i,
best = -
1U;
/* we've already synced this record at some point. it should "Transaction log corrupted unexpectedly");
/* nothing usable in cache - scan from beginning */ /* use cache to skip over some records */ "%s: Transaction log corrupted, can't get modseq",
/* @UNSAFE: cache the value */ /* nothing usable in cache - scan from beginning */ /* use cache to skip over some records */ "%s: Transaction log corrupted, can't get modseq",
/* if we got to sync_offset, cur_modseq should be "%s: Transaction log changed unexpectedly, " /* @UNSAFE: cache the value */ /* external transactions: */ /* see if this updates mailbox_sync_offset */ /* external transactions aren't synced to mailbox. we can update mailbox sync offset to skip this transaction to avoid re-reading it at the next sync. */ /* transaction has been fully written */ /* Now that all the mmaped pages have page faulted, check if the file had changed while doing that. Only after the last page has faulted, the size returned by fstat() can be trusted. Otherwise it might point to a page boundary while the next page is still being written. Without this check we might see partial transactions, sometimes causing "Extension record updated without intro /* There's more data than we could sync at the moment. If the last record's size wasn't valid, we can't know if it will be updated unless we've locked the log. */ /* pread()s or the above fstat() check for mmaps should have guaranteed that this doesn't happen */ "Unexpected garbage at EOF");
/* The size field will be updated soon */ "Invalid transaction log size " /* failure. don't leave ourself to inconsistent state */ /* log file was deleted in NFS server, fail silently */ /* log file was deleted in NFS server, fail silently */ /* we already have a newer log file which says that we haven't synced the entire file. */ /* NFS: if file isn't locked, we're optimistic that we can read enough data without flushing attribute cache. if after reading we notice that we really should have read more, flush the cache and try again. if file is locked, the attribute cache was already flushed when /* we have to insert missing data to beginning of buffer */ /* we didn't read enough data. flush and try again. */ /* broken start offset */ /* in case we just switched to mmaping */ /* we are going to mmap() this file, but it's not necessarily /* we already have the whole file mapped */ /* size changed, re-mmap */ /* just reading the file is probably faster */ /* we're not interested of going further than sync_offset */ /* see if we already have it */ /* we had moved the log to memory but failed to read the beginning of the log file */ "%s: Beginning of the log isn't available",
/* although we could just skip over the unwanted data, we have to sync everything so that modseqs are calculated /* just copy to memory */ /* we don't have the full log in the memory. read it. */