Commit 539bbaae authored by unknown's avatar unknown

Fix for bug in log handler observed when running maria-big

and then maria-connect under Windows 32-bit Visual Studio 2003.
Build of all Maria unit tests under Windows.


storage/maria/ma_loghandler.c:
  Assertion contributed by Sanja. Working around my_stat() bug on Windows
  (st_size is long i.e. 32-bit signed, the file was slightly bigger than
  2GB, so st_size was negative, TRANSLOG_PAGE_SIZE was int, so the
  comparison was done using long, so st_size was still negative in
  the comparison, which was incorrect). Two fixes: cast st_size to uint32
  (belt) and make TRANSLOG_PAGE_SIZE unsigned (suspenders).
  Of course 'long' is not enough for files >=4GB, but all log files of
  Maria are <4GB. The general problem of my_stat() has been passed on to
  our Windows team.
storage/maria/ma_loghandler.h:
  use unsigned ints for constants which represent sizes of pages, files...
storage/maria/unittest/CMakeLists.txt:
  a few unit tests were not built under Windows
parent 58237d22
......@@ -2798,6 +2798,7 @@ static uchar *translog_get_page(TRANSLOG_VALIDATOR_DATA *data, uchar *buffer,
cmp_translog_addr(addr, in_buffers) >= 0)
{
translog_lock();
DBUG_ASSERT(cmp_translog_addr(addr, log_descriptor.horizon) < 0);
/* recheck with locked loghandler */
in_buffers= translog_only_in_buffers();
if (cmp_translog_addr(addr, in_buffers) >= 0)
......@@ -2975,7 +2976,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
{
MY_STAT stat_buff, *local_stat;
char path[FN_REFLEN];
uint32 rec_offset;
uint32 rec_offset, file_size;
uint32 file_no= LSN_FILE_NO(*addr);
DBUG_ENTER("translog_get_last_page_addr");
......@@ -2984,11 +2985,12 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
(no_errors ? MYF(0) : MYF(MY_WME)))))
DBUG_RETURN(1);
DBUG_PRINT("info", ("File size: %lu", (ulong) local_stat->st_size));
if (local_stat->st_size > TRANSLOG_PAGE_SIZE)
file_size= (uint32)local_stat->st_size; /* st_size can be 'long' on Windows*/
if (file_size > TRANSLOG_PAGE_SIZE)
{
rec_offset= (((local_stat->st_size / TRANSLOG_PAGE_SIZE) - 1) *
rec_offset= (((file_size / TRANSLOG_PAGE_SIZE) - 1) *
TRANSLOG_PAGE_SIZE);
*last_page_ok= (local_stat->st_size == rec_offset + TRANSLOG_PAGE_SIZE);
*last_page_ok= (file_size == rec_offset + TRANSLOG_PAGE_SIZE);
}
else
{
......
......@@ -17,11 +17,11 @@
#define _ma_loghandler_h
/* transaction log default cache size (TODO: make it global variable) */
#define TRANSLOG_PAGECACHE_SIZE (1024*1024*2)
#define TRANSLOG_PAGECACHE_SIZE (1024U*1024*2)
/* transaction log default file size */
#define TRANSLOG_FILE_SIZE (1024*1024*1024)
#define TRANSLOG_FILE_SIZE (1024U*1024*1024)
/* minimum possible transaction log size */
#define TRANSLOG_MIN_FILE_SIZE (1024*1024*8)
#define TRANSLOG_MIN_FILE_SIZE (1024U*1024*8)
/* transaction log default flags (TODO: make it global variable) */
#define TRANSLOG_DEFAULT_FLAGS 0
......@@ -45,7 +45,7 @@
It should be Power of 2 and multiple of DISK_DRIVE_SECTOR_SIZE
(DISK_DRIVE_SECTOR_SIZE * 2^N)
*/
#define TRANSLOG_PAGE_SIZE (8*1024)
#define TRANSLOG_PAGE_SIZE (8U*1024)
#include "ma_loghandler_lsn.h"
#include "trnman_public.h"
......@@ -92,7 +92,7 @@ struct st_maria_handler;
Length of disk drive sector size (we assume that writing it
to disk is an atomic operation)
*/
#define DISK_DRIVE_SECTOR_SIZE 512
#define DISK_DRIVE_SECTOR_SIZE 512U
/* position reserved in an array of parts of a log record */
#define TRANSLOG_INTERNAL_PARTS 2
......@@ -166,7 +166,7 @@ enum en_key_op
/* Size of log file; One log file is restricted to 4G */
typedef uint32 translog_size_t;
#define TRANSLOG_RECORD_HEADER_MAX_SIZE 1024
#define TRANSLOG_RECORD_HEADER_MAX_SIZE 1024U
typedef struct st_translog_group_descriptor
{
......
......@@ -20,78 +20,76 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
${CMAKE_SOURCE_DIR}/unittest/mytap)
LINK_LIBRARIES(maria myisam mytap mysys dbug strings wsock32 zlib)
ADD_EXECUTABLE(ma_test_loghandler_t
ADD_EXECUTABLE(ma_control_file-t ma_control_file-t.c)
ADD_EXECUTABLE(trnman-t trnman-t.c)
ADD_EXECUTABLE(lockman2-t lockman2-t.c)
ADD_EXECUTABLE(ma_test_loghandler-t
ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_multigroup_t
ADD_EXECUTABLE(ma_test_loghandler_multigroup-t
ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_multithread_t
ADD_EXECUTABLE(ma_test_loghandler_multithread-t
ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_pagecache_t
ADD_EXECUTABLE(ma_test_loghandler_pagecache-t
ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_long_t_big
ADD_EXECUTABLE(ma_test_loghandler_long-t
ma_test_loghandler-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
SET_TARGET_PROPERTIES(ma_test_loghandler_long_t_big PROPERTIES COMPILE_FLAGS "-DLONG_LOG_TEST")
SET_TARGET_PROPERTIES(ma_test_loghandler_long-t PROPERTIES COMPILE_FLAGS "-DLONG_LOG_TEST")
ADD_EXECUTABLE(ma_test_loghandler_noflush_t
ADD_EXECUTABLE(ma_test_loghandler_noflush-t
ma_test_loghandler_noflush-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_first_lsn_t
ADD_EXECUTABLE(ma_test_loghandler_first_lsn-t
ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_max_lsn_t
ADD_EXECUTABLE(ma_test_loghandler_max_lsn-t
ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_purge_t
ADD_EXECUTABLE(ma_test_loghandler_purge-t
ma_test_loghandler_purge-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
ADD_EXECUTABLE(ma_test_loghandler_readonly_t
ADD_EXECUTABLE(ma_test_loghandler_readonly-t
ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
SET_TARGET_PROPERTIES(ma_test_loghandler_readonly_t PROPERTIES COMPILE_FLAGS "-DREADONLY_TEST")
SET_TARGET_PROPERTIES(ma_test_loghandler_readonly-t PROPERTIES COMPILE_FLAGS "-DREADONLY_TEST")
ADD_EXECUTABLE(ma_test_loghandler_nologs-t
ma_test_loghandler_nologs-t.c ma_maria_log_cleanup.c ma_loghandler_examples.c)
SET(ma_pagecache_single_src ma_pagecache_single.c test_file.c test_file.h)
SET(ma_pagecache_consist_src ma_pagecache_consist.c test_file.c test_file.h)
SET(ma_pagecache_consist_src ma_pagecache_consist.c test_file.c test_file.h)
SET(ma_pagecache_common_cppflags "-DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN")
ADD_EXECUTABLE(ma_pagecache_single_1k_t ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_1k_t
ADD_EXECUTABLE(ma_pagecache_single_1k-t ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_1k-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024")
ADD_EXECUTABLE(ma_pagecache_single_8k_t ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_8k_t
ADD_EXECUTABLE(ma_pagecache_single_8k-t ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_8k-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=8192")
ADD_EXECUTABLE(ma_pagecache_single_64k_t_big ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_64k_t_big
ADD_EXECUTABLE(ma_pagecache_single_64k-t ${ma_pagecache_single_src})
SET_TARGET_PROPERTIES(ma_pagecache_single_64k-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536")
ADD_EXECUTABLE(ma_pagecache_consist_1k_t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1k_t
ADD_EXECUTABLE(ma_pagecache_consist_1k-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1k-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024")
ADD_EXECUTABLE(ma_pagecache_consist_64k_t_big ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64k_t_big
ADD_EXECUTABLE(ma_pagecache_consist_64k-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64k-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536")
ADD_EXECUTABLE(ma_pagecache_consist_1kHC_t
ADD_EXECUTABLE(ma_pagecache_consist_1kHC-t
${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kHC_t
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kHC-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY")
ADD_EXECUTABLE(ma_pagecache_consist_64kHC_t_big
ADD_EXECUTABLE(ma_pagecache_consist_64kHC-t
${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kHC_t_big
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kHC-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY")
ADD_EXECUTABLE(ma_pagecache_consist_1kRD_t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kRD_t
ADD_EXECUTABLE(ma_pagecache_consist_1kRD-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kRD-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_READERS")
ADD_EXECUTABLE(ma_pagecache_consist_64kRD_t_big ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kRD_t_big
ADD_EXECUTABLE(ma_pagecache_consist_64kRD-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kRD-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_READERS")
ADD_EXECUTABLE(ma_pagecache_consist_1kWR_t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kWR_t
ADD_EXECUTABLE(ma_pagecache_consist_1kWR-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_1kWR-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=1024 -DTEST_WRITERS")
ADD_EXECUTABLE(ma_pagecache_consist_64kWR_t_big ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kWR_t_big
ADD_EXECUTABLE(ma_pagecache_consist_64kWR-t ${ma_pagecache_consist_src})
SET_TARGET_PROPERTIES(ma_pagecache_consist_64kWR-t
PROPERTIES COMPILE_FLAGS "${ma_pagecache_common_cppflags} -DPAGE_SIZE=65536 -DTEST_WRITERS")
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