Commit 7917e8cc authored by unknown's avatar unknown

Post review fix (serg).

Added more checks.


storage/maria/ha_maria.cc:
  Let control size to my_get_opts().
storage/maria/ma_loghandler.c:
  Let control size to my_get_opts().
  Removed unused function.
  Assert to check log file size.
  Additional compilation warnings.
storage/maria/ma_loghandler.h:
  New log size bounds.
  Removed unused function.
storage/maria/unittest/ma_test_loghandler-t.c:
  Fixed test to confirm new log size bounds.
parent ce91156c
...@@ -2693,7 +2693,7 @@ static void update_log_file_size(MYSQL_THD thd, ...@@ -2693,7 +2693,7 @@ static void update_log_file_size(MYSQL_THD thd,
void *var_ptr, void *save) void *var_ptr, void *save)
{ {
uint32 size= (uint32)((ulong)(*(long *)save)); uint32 size= (uint32)((ulong)(*(long *)save));
size= translog_set_file_size(size); translog_set_file_size(size);
*(ulong *)var_ptr= size; *(ulong *)var_ptr= size;
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
/* number of opened log files in the pagecache (should be at least 2) */ /* number of opened log files in the pagecache (should be at least 2) */
#define OPENED_FILES_NUM 3 #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) #define TRANSLOG_WRITE_BUFFER (1024*1024)
/* min chunk length */ /* min chunk length */
#define TRANSLOG_MIN_CHUNK 3 #define TRANSLOG_MIN_CHUNK 3
...@@ -2812,18 +2812,6 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr) ...@@ -2812,18 +2812,6 @@ static my_bool translog_truncate_log(TRANSLOG_ADDRESS addr)
DBUG_RETURN(0); 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 Initialize transaction log
...@@ -2857,6 +2845,9 @@ my_bool translog_init(const char *directory, ...@@ -2857,6 +2845,9 @@ my_bool translog_init(const char *directory,
my_bool version_changed= 0; my_bool version_changed= 0;
DBUG_ENTER("translog_init"); DBUG_ENTER("translog_init");
DBUG_ASSERT(translog_inited == 0); 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 */ loghandler_init(); /* Safe to do many times */
...@@ -2890,9 +2881,12 @@ my_bool translog_init(const char *directory, ...@@ -2890,9 +2881,12 @@ my_bool translog_init(const char *directory,
} }
log_descriptor.in_buffers_only= LSN_IMPOSSIBLE; 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) */ /* max size of one log size (for new logs creation) */
log_file_size= log_descriptor.log_file_max_size= log_file_size= log_descriptor.log_file_max_size=
translog_round_log_size(log_file_max_size); log_file_max_size;
/* server version */ /* server version */
log_descriptor.server_version= server_version; log_descriptor.server_version= server_version;
/* server ID */ /* server ID */
...@@ -7218,11 +7212,15 @@ uint32 translog_get_file_size() ...@@ -7218,11 +7212,15 @@ uint32 translog_get_file_size()
@return Returns actually set transaction log 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(); 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 current file longer then finish it*/
if (LSN_OFFSET(log_descriptor.horizon) >= log_descriptor.log_file_max_size) if (LSN_OFFSET(log_descriptor.horizon) >= log_descriptor.log_file_max_size)
{ {
...@@ -7231,6 +7229,6 @@ uint32 translog_set_file_size(uint32 size) ...@@ -7231,6 +7229,6 @@ uint32 translog_set_file_size(uint32 size)
translog_buffer_unlock(old_buffer); translog_buffer_unlock(old_buffer);
} }
translog_unlock(); translog_unlock();
return (res); DBUG_VOID_RETURN;
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
/* transaction log default file size */ /* transaction log default file size */
#define TRANSLOG_FILE_SIZE (1024*1024*1024) #define TRANSLOG_FILE_SIZE (1024*1024*1024)
/* minimum possible transaction log size */ /* 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) */ /* transaction log default flags (TODO: make it global variable) */
#define TRANSLOG_DEFAULT_FLAGS 0 #define TRANSLOG_DEFAULT_FLAGS 0
...@@ -313,8 +313,7 @@ extern my_bool translog_purge_at_flush(); ...@@ -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_file(TRANSLOG_ADDRESS horizon);
extern uint32 translog_get_first_needed_file(); extern uint32 translog_get_first_needed_file();
extern char *translog_filename_by_fileno(uint32 file_no, char *path); extern char *translog_filename_by_fileno(uint32 file_no, char *path);
extern uint32 translog_get_file_size(); extern void translog_set_file_size(uint32 size);
extern uint32 translog_set_file_size(uint32 size);
/* record parts descriptor */ /* record parts descriptor */
struct st_translog_parts struct st_translog_parts
......
...@@ -18,12 +18,12 @@ static TRN *trn= &dummy_transaction_object; ...@@ -18,12 +18,12 @@ static TRN *trn= &dummy_transaction_object;
#ifdef LONG_LOG_TEST #ifdef LONG_LOG_TEST
#define LOG_FLAGS 0 #define LOG_FLAGS 0
#define LOG_FILE_SIZE (1024L*1024L) #define LOG_FILE_SIZE (1024L*1024L*8)
#define ITERATIONS (1600*4) #define ITERATIONS (1600*4)
#else #else
#define LOG_FLAGS (TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC) #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 #define ITERATIONS 1600
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment