changeset 5283:8f9af66ee313 HEAD

If transaction log grows larger than 1MB, rotate it even if it was created less than 5 minutes ago.
author Timo Sirainen <tss@iki.fi>
date Sun, 11 Mar 2007 18:40:58 +0200
parents a8317e816609
children 6ba1cd2580ee
files src/lib-index/mail-transaction-log-append.c src/lib-index/mail-transaction-log-private.h
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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. */
--- 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)