# HG changeset patch # User Timo Sirainen # Date 1173631258 -7200 # Node ID 8f9af66ee3134d303eb66bab5350c440aaba6b87 # Parent a8317e816609f3c566837100e5f6e8261e5a5df5 If transaction log grows larger than 1MB, rotate it even if it was created less than 5 minutes ago. diff -r a8317e816609 -r 8f9af66ee313 src/lib-index/mail-transaction-log-append.c --- a/src/lib-index/mail-transaction-log-append.c Sun Mar 11 18:30:05 2007 +0200 +++ b/src/lib-index/mail-transaction-log-append.c Sun Mar 11 18:40:58 2007 +0200 @@ -363,6 +363,12 @@ return 0; } +#define LOG_WANT_ROTATE(file) \ + (((file)->sync_offset > MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE && \ + (time_t)(file)->hdr.create_stamp < \ + ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_TIME) || \ + ((file)->sync_offset > MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE)) + #define ARE_ALL_TRANSACTIONS_IN_INDEX(log, idx_hdr) \ ((log)->head->hdr.file_seq == (idx_hdr)->log_file_seq && \ (log)->head->sync_offset == (idx_hdr)->log_file_int_offset && \ @@ -394,9 +400,7 @@ return -1; } - if (log->head->sync_offset > MAIL_TRANSACTION_LOG_ROTATE_SIZE && - (time_t)log->head->hdr.create_stamp < - ioloop_time - MAIL_TRANSACTION_LOG_ROTATE_TIME && + if (LOG_WANT_ROTATE(log->head) && ARE_ALL_TRANSACTIONS_IN_INDEX(log, index->hdr)) { /* we might want to rotate, but check first that everything is synced in index. */ diff -r a8317e816609 -r 8f9af66ee313 src/lib-index/mail-transaction-log-private.h --- a/src/lib-index/mail-transaction-log-private.h Sun Mar 11 18:30:05 2007 +0200 +++ b/src/lib-index/mail-transaction-log-private.h Sun Mar 11 18:40:58 2007 +0200 @@ -4,7 +4,10 @@ #include "file-dotlock.h" #include "mail-transaction-log.h" -#define MAIL_TRANSACTION_LOG_ROTATE_SIZE (1024*128) +/* Rotate when log is older than ROTATE_TIME and larger than MIN_SIZE */ +#define MAIL_TRANSACTION_LOG_ROTATE_MIN_SIZE (1024*128) +/* If log is larger than MAX_SIZE, rotate regardless of the time */ +#define MAIL_TRANSACTION_LOG_ROTATE_MAX_SIZE (1024*1024) #define MAIL_TRANSACTION_LOG_ROTATE_TIME (60*5) #define MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file) ((file)->fd == -1)