diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 82bcbdd07c7f8841e4981dcf3816f43911522ef2..606710f1f6c1d68a60e50049bf75d00dad7169d7 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2693,7 +2693,7 @@ static void update_log_file_size(MYSQL_THD thd, void *var_ptr, void *save) { uint32 size= (uint32)((ulong)(*(long *)save)); - size= translog_set_file_size(size); + translog_set_file_size(size); *(ulong *)var_ptr= size; } diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index 1c9abd8508cdb1ea325291e903f2e7e2b8718764..9fa556cec68ff39758811a0324f33062949c8b89 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -29,7 +29,7 @@ /* number of opened log files in the pagecache (should be at least 2) */ #define OPENED_FILES_NUM 3 -/* records buffer size (should be LOG_PAGE_SIZE * n) */ +/* records buffer size (should be TRANSLOG_PAGE_SIZE * n) */ #define TRANSLOG_WRITE_BUFFER (1024*1024) /* min chunk length */ #define TRANSLOG_MIN_CHUNK 3 @@ -2812,18 +2812,6 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr) DBUG_RETURN(0); } -/** - @brief round correctly transaction log size - - @return maximum possible log size less or equal then given one -*/ - -static uint32 translog_round_log_size(uint32 size) -{ - size= (size - (size % TRANSLOG_PAGE_SIZE)); - return max(size, TRANSLOG_MIN_FILE_SIZE); -} - /* Initialize transaction log @@ -2857,6 +2845,9 @@ my_bool translog_init(const char *directory, my_bool version_changed= 0; DBUG_ENTER("translog_init"); DBUG_ASSERT(translog_inited == 0); + compile_time_assert(TRANSLOG_MIN_FILE_SIZE > + TRANSLOG_WRITE_BUFFER * TRANSLOG_BUFFERS_NO); + compile_time_assert(TRANSLOG_WRITE_BUFFER % TRANSLOG_PAGE_SIZE == 0); loghandler_init(); /* Safe to do many times */ @@ -2890,9 +2881,12 @@ my_bool translog_init(const char *directory, } log_descriptor.in_buffers_only= LSN_IMPOSSIBLE; + DBUG_ASSERT(log_file_max_size % TRANSLOG_PAGE_SIZE == 0 && + log_file_max_size >= TRANSLOG_MIN_FILE_SIZE && + log_file_max_size <= 0xffffffffL); /* max size of one log size (for new logs creation) */ log_file_size= log_descriptor.log_file_max_size= - translog_round_log_size(log_file_max_size); + log_file_max_size; /* server version */ log_descriptor.server_version= server_version; /* server ID */ @@ -7218,11 +7212,15 @@ uint32 translog_get_file_size() @return Returns actually set transaction log size */ -uint32 translog_set_file_size(uint32 size) +void translog_set_file_size(uint32 size) { - uint32 res; + DBUG_ENTER("translog_set_file_size"); translog_lock(); - res= log_descriptor.log_file_max_size= translog_round_log_size(size); + DBUG_PRINT("enter", ("Size: %lu", (ulong) size)); + DBUG_ASSERT(size % TRANSLOG_PAGE_SIZE == 0 && + size >= TRANSLOG_MIN_FILE_SIZE && + size <= 0xffffffffL); + log_descriptor.log_file_max_size= size; /* if current file longer then finish it*/ if (LSN_OFFSET(log_descriptor.horizon) >= log_descriptor.log_file_max_size) { @@ -7231,6 +7229,6 @@ uint32 translog_set_file_size(uint32 size) translog_buffer_unlock(old_buffer); } translog_unlock(); - return (res); + DBUG_VOID_RETURN; } diff --git a/storage/maria/ma_loghandler.h b/storage/maria/ma_loghandler.h index 8d8494696bf17d973fef91c64fd73526d399e241..da233f2d7155a45c07d8a8bdb8860069b3a3c722 100644 --- a/storage/maria/ma_loghandler.h +++ b/storage/maria/ma_loghandler.h @@ -21,7 +21,7 @@ /* transaction log default file size */ #define TRANSLOG_FILE_SIZE (1024*1024*1024) /* minimum possible transaction log size */ -#define TRANSLOG_MIN_FILE_SIZE (1024*1024*4) +#define TRANSLOG_MIN_FILE_SIZE (1024*1024*8) /* transaction log default flags (TODO: make it global variable) */ #define TRANSLOG_DEFAULT_FLAGS 0 @@ -313,8 +313,7 @@ extern my_bool translog_purge_at_flush(); extern uint32 translog_get_first_file(TRANSLOG_ADDRESS horizon); extern uint32 translog_get_first_needed_file(); extern char *translog_filename_by_fileno(uint32 file_no, char *path); -extern uint32 translog_get_file_size(); -extern uint32 translog_set_file_size(uint32 size); +extern void translog_set_file_size(uint32 size); /* record parts descriptor */ struct st_translog_parts diff --git a/storage/maria/unittest/ma_test_loghandler-t.c b/storage/maria/unittest/ma_test_loghandler-t.c index a5a85c2e58988a7a0eaa1d8ec653b22058add481..6c0b86142852a13339c2e53ac0eb17847262075f 100644 --- a/storage/maria/unittest/ma_test_loghandler-t.c +++ b/storage/maria/unittest/ma_test_loghandler-t.c @@ -18,12 +18,12 @@ static TRN *trn= &dummy_transaction_object; #ifdef LONG_LOG_TEST #define LOG_FLAGS 0 -#define LOG_FILE_SIZE (1024L*1024L) +#define LOG_FILE_SIZE (1024L*1024L*8) #define ITERATIONS (1600*4) #else #define LOG_FLAGS (TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC) -#define LOG_FILE_SIZE (1024L*1024L*3L) +#define LOG_FILE_SIZE (1024L*1024L*8L) #define ITERATIONS 1600 #endif