Commit 91a81997 authored by unknown's avatar unknown

Postmerge fix (including changing type of LSN)

Some debug info and comments added


include/pagecache.h:
  postmerge fix
mysys/mf_pagecache.c:
  Postmerge fix (including changing type of LSN)
  Additional DBUG_ASSERTs added
  Comment about pinning mechanism added
storage/maria/ma_control_file.c:
  Used the same LSN storing procedure everywhere
  Postmerge fix (including changing type of LSN)
storage/maria/ma_control_file.h:
  Postmerge fix (including changing type of LSN)
storage/maria/ma_loghandler.c:
  Postmerge fix (including changing type of LSN)
storage/maria/ma_loghandler.h:
  Postmerge fix (including changing type of LSN)
storage/maria/ma_loghandler_lsn.h:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/Makefile.am:
  Postmerge fix
storage/maria/unittest/ma_control_file-t.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/ma_test_loghandler-t.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/mf_pagecache_consist.c:
  Postmerge fix (including changing type of LSN)
storage/maria/unittest/mf_pagecache_single.c:
  Postmerge fix (including changing type of LSN)
parent 199ea756
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
C_MODE_START C_MODE_START
#include "../storage/maria/ma_loghandler_lsn.h" #include "../storage/maria/ma_loghandler_lsn.h"
#include <m_string.h>
/* Type of the page */ /* Type of the page */
enum pagecache_page_type enum pagecache_page_type
...@@ -73,8 +74,6 @@ enum pagecache_write_mode ...@@ -73,8 +74,6 @@ enum pagecache_write_mode
typedef void *PAGECACHE_PAGE_LINK; typedef void *PAGECACHE_PAGE_LINK;
typedef uint64 LSN;
/* file descriptor for Maria */ /* file descriptor for Maria */
typedef struct st_pagecache_file typedef struct st_pagecache_file
{ {
...@@ -152,8 +151,8 @@ typedef struct st_pagecache ...@@ -152,8 +151,8 @@ typedef struct st_pagecache
ulong param_division_limit; /* min. percentage of warm blocks */ ulong param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */ ulong param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_key_cache_counters(). */ /* Statistics variables. These are reset in reset_pagecache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */ ulong global_blocks_changed; /* number of currently dirty blocks */
ulonglong global_cache_w_requests;/* number of write requests (write hits) */ ulonglong global_cache_w_requests;/* number of write requests (write hits) */
ulonglong global_cache_write; /* number of writes from cache to files */ ulonglong global_cache_write; /* number of writes from cache to files */
ulonglong global_cache_r_requests;/* number of read requests (read hits) */ ulonglong global_cache_r_requests;/* number of read requests (read hits) */
...@@ -200,14 +199,12 @@ extern void pagecache_unlock_page(PAGECACHE *pagecache, ...@@ -200,14 +199,12 @@ extern void pagecache_unlock_page(PAGECACHE *pagecache,
pgcache_page_no_t pageno, pgcache_page_no_t pageno,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
my_bool stamp_this_page, LSN first_REDO_LSN_for_page);
LSN_PTR first_REDO_LSN_for_page);
extern void pagecache_unlock(PAGECACHE *pagecache, extern void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link, PAGECACHE_PAGE_LINK *link,
enum pagecache_page_lock lock, enum pagecache_page_lock lock,
enum pagecache_page_pin pin, enum pagecache_page_pin pin,
my_bool stamp_this_page, LSN first_REDO_LSN_for_page);
LSN_PTR first_REDO_LSN_for_page);
extern void pagecache_unpin_page(PAGECACHE *pagecache, extern void pagecache_unpin_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file, PAGECACHE_FILE *file,
pgcache_page_no_t pageno); pgcache_page_no_t pageno);
...@@ -225,6 +222,7 @@ extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup); ...@@ -225,6 +222,7 @@ extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup);
extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LEX_STRING *str, LEX_STRING *str,
LSN *max_lsn); LSN *max_lsn);
extern int reset_pagecache_counters(const char *name, PAGECACHE *pagecache);
C_MODE_END C_MODE_END
#endif /* _keycache_h */ #endif /* _keycache_h */
This diff is collapsed.
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#define CONTROL_FILE_CHECKSUM_OFFSET (CONTROL_FILE_MAGIC_STRING_OFFSET + CONTROL_FILE_MAGIC_STRING_SIZE) #define CONTROL_FILE_CHECKSUM_OFFSET (CONTROL_FILE_MAGIC_STRING_OFFSET + CONTROL_FILE_MAGIC_STRING_SIZE)
#define CONTROL_FILE_CHECKSUM_SIZE 1 #define CONTROL_FILE_CHECKSUM_SIZE 1
#define CONTROL_FILE_LSN_OFFSET (CONTROL_FILE_CHECKSUM_OFFSET + CONTROL_FILE_CHECKSUM_SIZE) #define CONTROL_FILE_LSN_OFFSET (CONTROL_FILE_CHECKSUM_OFFSET + CONTROL_FILE_CHECKSUM_SIZE)
#define CONTROL_FILE_LSN_SIZE (4+4) #define CONTROL_FILE_LSN_SIZE (3+4)
#define CONTROL_FILE_FILENO_OFFSET (CONTROL_FILE_LSN_OFFSET + CONTROL_FILE_LSN_SIZE) #define CONTROL_FILE_FILENO_OFFSET (CONTROL_FILE_LSN_OFFSET + CONTROL_FILE_LSN_SIZE)
#define CONTROL_FILE_FILENO_SIZE 4 #define CONTROL_FILE_FILENO_SIZE 4
#define CONTROL_FILE_SIZE (CONTROL_FILE_FILENO_OFFSET + CONTROL_FILE_FILENO_SIZE) #define CONTROL_FILE_SIZE (CONTROL_FILE_FILENO_OFFSET + CONTROL_FILE_FILENO_SIZE)
...@@ -59,20 +59,6 @@ uint32 last_logno; ...@@ -59,20 +59,6 @@ uint32 last_logno;
*/ */
static int control_file_fd= -1; static int control_file_fd= -1;
static void lsn8store(char *buffer, const LSN *lsn)
{
int4store(buffer, lsn->file_no);
int4store(buffer + CONTROL_FILE_FILENO_SIZE, lsn->rec_offset);
}
static LSN lsn8korr(char *buffer)
{
LSN tmp;
tmp.file_no= uint4korr(buffer);
tmp.rec_offset= uint4korr(buffer + CONTROL_FILE_FILENO_SIZE);
return tmp;
}
static char simple_checksum(char *buffer, uint size) static char simple_checksum(char *buffer, uint size)
{ {
/* TODO: improve this sum if we want */ /* TODO: improve this sum if we want */
...@@ -120,7 +106,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open() ...@@ -120,7 +106,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
"*store" and "*korr" calls in this file, and can even create backward "*store" and "*korr" calls in this file, and can even create backward
compatibility problems. Beware! compatibility problems. Beware!
*/ */
DBUG_ASSERT(CONTROL_FILE_LSN_SIZE == (4+4)); DBUG_ASSERT(CONTROL_FILE_LSN_SIZE == (3+4));
DBUG_ASSERT(CONTROL_FILE_FILENO_SIZE == 4); DBUG_ASSERT(CONTROL_FILE_FILENO_SIZE == 4);
if (control_file_fd >= 0) /* already open */ if (control_file_fd >= 0) /* already open */
...@@ -154,11 +140,9 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open() ...@@ -154,11 +140,9 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
usable as soon as it has been written to the log). usable as soon as it has been written to the log).
*/ */
LSN imposs_lsn= CONTROL_FILE_IMPOSSIBLE_LSN;
uint32 imposs_logno= CONTROL_FILE_IMPOSSIBLE_FILENO;
/* init the file with these "undefined" values */ /* init the file with these "undefined" values */
DBUG_RETURN(ma_control_file_write_and_force(&imposs_lsn, imposs_logno, DBUG_RETURN(ma_control_file_write_and_force(CONTROL_FILE_IMPOSSIBLE_LSN,
CONTROL_FILE_IMPOSSIBLE_FILENO,
CONTROL_FILE_UPDATE_ALL)); CONTROL_FILE_UPDATE_ALL));
} }
...@@ -216,7 +200,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open() ...@@ -216,7 +200,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
error= CONTROL_FILE_BAD_CHECKSUM; error= CONTROL_FILE_BAD_CHECKSUM;
goto err; goto err;
} }
last_checkpoint_lsn= lsn8korr(buffer + CONTROL_FILE_LSN_OFFSET); last_checkpoint_lsn= lsn7korr(buffer + CONTROL_FILE_LSN_OFFSET);
last_logno= uint4korr(buffer + CONTROL_FILE_FILENO_OFFSET); last_logno= uint4korr(buffer + CONTROL_FILE_FILENO_OFFSET);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -253,7 +237,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open() ...@@ -253,7 +237,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
1 - Error 1 - Error
*/ */
int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno, int ma_control_file_write_and_force(const LSN checkpoint_lsn, uint32 logno,
uint objs_to_write) uint objs_to_write)
{ {
char buffer[CONTROL_FILE_SIZE]; char buffer[CONTROL_FILE_SIZE];
...@@ -277,9 +261,9 @@ int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno, ...@@ -277,9 +261,9 @@ int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno,
DBUG_ASSERT(0); DBUG_ASSERT(0);
if (update_checkpoint_lsn) if (update_checkpoint_lsn)
lsn8store(buffer + CONTROL_FILE_LSN_OFFSET, checkpoint_lsn); lsn7store(buffer + CONTROL_FILE_LSN_OFFSET, checkpoint_lsn);
else /* store old value == change nothing */ else /* store old value == change nothing */
lsn8store(buffer + CONTROL_FILE_LSN_OFFSET, &last_checkpoint_lsn); lsn7store(buffer + CONTROL_FILE_LSN_OFFSET, last_checkpoint_lsn);
if (update_logno) if (update_logno)
int4store(buffer + CONTROL_FILE_FILENO_OFFSET, logno); int4store(buffer + CONTROL_FILE_FILENO_OFFSET, logno);
...@@ -297,7 +281,7 @@ int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno, ...@@ -297,7 +281,7 @@ int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno,
/* TODO: you need some protection to be able to write last_* global vars */ /* TODO: you need some protection to be able to write last_* global vars */
if (update_checkpoint_lsn) if (update_checkpoint_lsn)
last_checkpoint_lsn= *checkpoint_lsn; last_checkpoint_lsn= checkpoint_lsn;
if (update_logno) if (update_logno)
last_logno= logno; last_logno= logno;
......
...@@ -30,16 +30,14 @@ ...@@ -30,16 +30,14 @@
#define CONTROL_FILE_IMPOSSIBLE_FILENO 0 #define CONTROL_FILE_IMPOSSIBLE_FILENO 0
/* logs always have a header */ /* logs always have a header */
#define CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET 0 #define CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET 0
/* /* indicate absence of LSN. */
indicate absence of LSN. #define CONTROL_FILE_IMPOSSIBLE_LSN ((LSN)0)
*/
#define CONTROL_FILE_IMPOSSIBLE_LSN ((LSN){CONTROL_FILE_IMPOSSIBLE_FILENO,CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET})
/* Here is the interface of this module */ /* Here is the interface of this module */
/* /*
LSN of the last checkoint LSN of the last checkoint
(if last_checkpoint_lsn.file_no == CONTROL_FILE_IMPOSSIBLE_FILENO (if last_checkpoint_lsn == CONTROL_FILE_IMPOSSIBLE_LSN
then there was never a checkpoint) then there was never a checkpoint)
*/ */
extern LSN last_checkpoint_lsn; extern LSN last_checkpoint_lsn;
...@@ -72,7 +70,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open(); ...@@ -72,7 +70,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open();
#define CONTROL_FILE_UPDATE_ALL 0 #define CONTROL_FILE_UPDATE_ALL 0
#define CONTROL_FILE_UPDATE_ONLY_LSN 1 #define CONTROL_FILE_UPDATE_ONLY_LSN 1
#define CONTROL_FILE_UPDATE_ONLY_LOGNO 2 #define CONTROL_FILE_UPDATE_ONLY_LOGNO 2
int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno, int ma_control_file_write_and_force(const LSN checkpoint_lsn, uint32 logno,
uint objs_to_write); uint objs_to_write);
......
This diff is collapsed.
...@@ -218,7 +218,7 @@ void translog_destroy(); ...@@ -218,7 +218,7 @@ void translog_destroy();
part of the header part of the header
*/ */
translog_size_t translog_read_record_header(LSN *lsn, translog_size_t translog_read_record_header(LSN lsn,
TRANSLOG_HEADER_BUFFER *buff); TRANSLOG_HEADER_BUFFER *buff);
...@@ -249,7 +249,7 @@ void translog_free_record_header(TRANSLOG_HEADER_BUFFER *buff); ...@@ -249,7 +249,7 @@ void translog_free_record_header(TRANSLOG_HEADER_BUFFER *buff);
length of data actually read length of data actually read
*/ */
translog_size_t translog_read_record(LSN *lsn, translog_size_t translog_read_record(LSN lsn,
translog_size_t offset, translog_size_t offset,
translog_size_t length, translog_size_t length,
uchar *buffer, uchar *buffer,
...@@ -269,7 +269,7 @@ translog_size_t translog_read_record(LSN *lsn, ...@@ -269,7 +269,7 @@ translog_size_t translog_read_record(LSN *lsn,
1 - Error 1 - Error
*/ */
my_bool translog_flush(LSN *lsn); my_bool translog_flush(LSN lsn);
/* /*
...@@ -304,7 +304,7 @@ my_bool translog_flush(LSN *lsn); ...@@ -304,7 +304,7 @@ my_bool translog_flush(LSN *lsn);
part of the header part of the header
*/ */
translog_size_t translog_read_next_record_header(LSN *lsn, translog_size_t translog_read_next_record_header(LSN lsn,
TRANSLOG_HEADER_BUFFER *buff, TRANSLOG_HEADER_BUFFER *buff,
my_bool fixed_horizon, my_bool fixed_horizon,
struct struct
......
...@@ -2,11 +2,7 @@ ...@@ -2,11 +2,7 @@
#define _ma_loghandler_lsn_h #define _ma_loghandler_lsn_h
/* Transaction log record address (file_no is int24 on the disk) */ /* Transaction log record address (file_no is int24 on the disk) */
typedef struct st_translog_address typedef int64 TRANSLOG_ADDRESS;
{
uint32 file_no;
uint32 rec_offset;
} TRANSLOG_ADDRESS;
/* /*
Compare addresses Compare addresses
...@@ -14,26 +10,39 @@ typedef struct st_translog_address ...@@ -14,26 +10,39 @@ typedef struct st_translog_address
A1 == A2 -> 0 A1 == A2 -> 0
A1 < A2 -> result < 0 A1 < A2 -> result < 0
*/ */
#define cmp_translog_addr(A1,A2) \ #define cmp_translog_addr(A1,A2) ((A1) - (A2))
((A1).file_no == (A2).file_no ? \
((int64)(A1).rec_offset) - (int64)(A2).rec_offset : \
((int64)(A1).file_no - (int64)(A2).file_no))
/* LSN type (address of certain log record chank */ /* LSN type (address of certain log record chank */
typedef TRANSLOG_ADDRESS LSN; typedef TRANSLOG_ADDRESS LSN;
/* Gets file number part of a LSN/log address */
#define LSN_FILE_NO(L) ((L) >> 32)
/* Gets raw file number part of a LSN/log address */
#define LSN_FINE_NO_PART(L) ((L) & ((int64)0xFFFFFF00000000LL))
/* Gets record offset of a LSN/log address */
#define LSN_OFFSET(L) ((L) & 0xFFFFFFFFL)
/* Makes lsn/log address from file number and record offset */
#define MAKE_LSN(F,S) ((((uint64)(F)) << 32) | (S))
/* checks LSN */
#define LSN_VALID(L) DBUG_ASSERT((L) >= 0 && (L) < (uint64)0xFFFFFFFFFFFFFFLL)
/* Puts LSN into buffer (dst) */ /* Puts LSN into buffer (dst) */
#define lsn7store(dst, lsn) \ #define lsn7store(dst, lsn) \
do { \ do { \
int3store((dst), (lsn)->file_no); \ int3store((dst), LSN_FILE_NO(lsn)); \
int4store((dst) + 3, (lsn)->rec_offset); \ int4store((dst) + 3, LSN_OFFSET(lsn)); \
} while (0) } while (0)
/* Unpacks LSN from the buffer (P) */ /* Unpacks LSN from the buffer (P) */
#define lsn7korr(lsn, P) \ #define lsn7korr(P) MAKE_LSN(uint3korr(P), uint4korr((P) + 3))
do { \
(lsn)->file_no= uint3korr(P); \ /* what we need to add to LSN to increase it on one file */
(lsn)->rec_offset= uint4korr((P) + 3); \ #define LSN_ONE_FILE ((int64)0x100000000LL)
} while (0)
#define LSN_REPLACE_OFFSET(L, S) (LSN_FINE_NO_PART(L) | (S))
#endif #endif
...@@ -30,14 +30,15 @@ LDADD= $(top_builddir)/unittest/mytap/libmytap.a \ ...@@ -30,14 +30,15 @@ LDADD= $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/storage/maria/ma_loghandler.o $(top_builddir)/storage/maria/ma_loghandler.o
noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
mf_pagecache_single_1k-t mf_pagecache_single_8k-t \ mf_pagecache_single_1k-t mf_pagecache_single_8k-t \
mf_pagecache_single_64k-t \ mf_pagecache_single_64k-t-big \
mf_pagecache_consist_1k-t mf_pagecache_consist_64k-t \ mf_pagecache_consist_1k-t-big \
mf_pagecache_consist_1kHC-t \ mf_pagecache_consist_64k-t-big \
mf_pagecache_consist_64kHC-t \ mf_pagecache_consist_1kHC-t-big \
mf_pagecache_consist_1kRD-t \ mf_pagecache_consist_64kHC-t-big \
mf_pagecache_consist_64kRD-t \ mf_pagecache_consist_1kRD-t-big \
mf_pagecache_consist_1kWR-t \ mf_pagecache_consist_64kRD-t-big \
mf_pagecache_consist_64kWR-t \ mf_pagecache_consist_1kWR-t-big \
mf_pagecache_consist_64kWR-t-big \
ma_test_loghandler-t \ ma_test_loghandler-t \
ma_test_loghandler_multigroup-t \ ma_test_loghandler_multigroup-t \
ma_test_loghandler_multithread-t \ ma_test_loghandler_multithread-t \
...@@ -49,34 +50,33 @@ mf_pagecache_common_cppflags = -DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN ...@@ -49,34 +50,33 @@ mf_pagecache_common_cppflags = -DEXTRA_DEBUG -DPAGECACHE_DEBUG -DMAIN
mf_pagecache_single_1k_t_SOURCES = $(mf_pagecache_single_src) mf_pagecache_single_1k_t_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_8k_t_SOURCES = $(mf_pagecache_single_src) mf_pagecache_single_8k_t_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_64k_t_SOURCES = $(mf_pagecache_single_src) mf_pagecache_single_64k_t_big_SOURCES = $(mf_pagecache_single_src)
mf_pagecache_single_1k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 mf_pagecache_single_1k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_single_8k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=8192 mf_pagecache_single_8k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=8192
mf_pagecache_single_64k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 mf_pagecache_single_64k_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536
mf_pagecache_consist_1k_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_1k_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 mf_pagecache_consist_1k_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_consist_64k_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_64k_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 mf_pagecache_consist_64k_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536
mf_pagecache_consist_1kHC_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_1kHC_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kHC_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY mf_pagecache_consist_1kHC_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_64kHC_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_64kHC_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kHC_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY mf_pagecache_consist_64kHC_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_1kRD_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_1kRD_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kRD_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS mf_pagecache_consist_1kRD_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS
mf_pagecache_consist_64kRD_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_64kRD_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kRD_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS mf_pagecache_consist_64kRD_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS
mf_pagecache_consist_1kWR_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_1kWR_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kWR_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS mf_pagecache_consist_1kWR_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS
mf_pagecache_consist_64kWR_t_SOURCES = $(mf_pagecache_consist_src) mf_pagecache_consist_64kWR_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64kWR_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS mf_pagecache_consist_64kWR_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS
# the generic lock manager may not be used in the end and lockman1-t crashes, # the generic lock manager may not be used in the end and lockman1-t crashes,
# so we don't build lockman-t and lockman1-t # so we don't build lockman-t and lockman1-t
CLEANFILES = maria_control page_cache_test_file_1 \ CLEANFILES = maria_control page_cache_test_file_1 \
maria_log.???????? maria_control maria_log.????????
noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t
...@@ -133,10 +133,8 @@ static int delete_file(myf my_flags) ...@@ -133,10 +133,8 @@ static int delete_file(myf my_flags)
static int verify_module_values_match_expected() static int verify_module_values_match_expected()
{ {
RET_ERR_UNLESS(last_logno == expect_logno); RET_ERR_UNLESS(last_logno == expect_logno);
RET_ERR_UNLESS(last_checkpoint_lsn.file_no == RET_ERR_UNLESS(last_checkpoint_lsn ==
expect_checkpoint_lsn.file_no); expect_checkpoint_lsn);
RET_ERR_UNLESS(last_checkpoint_lsn.rec_offset ==
expect_checkpoint_lsn.rec_offset);
return 0; return 0;
} }
...@@ -148,10 +146,8 @@ static int verify_module_values_match_expected() ...@@ -148,10 +146,8 @@ static int verify_module_values_match_expected()
static int verify_module_values_are_impossible() static int verify_module_values_are_impossible()
{ {
RET_ERR_UNLESS(last_logno == CONTROL_FILE_IMPOSSIBLE_FILENO); RET_ERR_UNLESS(last_logno == CONTROL_FILE_IMPOSSIBLE_FILENO);
RET_ERR_UNLESS(last_checkpoint_lsn.file_no == RET_ERR_UNLESS(last_checkpoint_lsn ==
CONTROL_FILE_IMPOSSIBLE_FILENO); CONTROL_FILE_IMPOSSIBLE_LSN);
RET_ERR_UNLESS(last_checkpoint_lsn.rec_offset ==
CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET);
return 0; return 0;
} }
...@@ -173,9 +169,9 @@ static int create_or_open_file() ...@@ -173,9 +169,9 @@ static int create_or_open_file()
return 0; return 0;
} }
static int write_file(const LSN *checkpoint_lsn, static int write_file(const LSN checkpoint_lsn,
uint32 logno, uint32 logno,
uint objs_to_write) uint objs_to_write)
{ {
RET_ERR_UNLESS(ma_control_file_write_and_force(checkpoint_lsn, logno, RET_ERR_UNLESS(ma_control_file_write_and_force(checkpoint_lsn, logno,
objs_to_write) == 0); objs_to_write) == 0);
...@@ -191,8 +187,9 @@ static int test_one_log() ...@@ -191,8 +187,9 @@ static int test_one_log()
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK); RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 123; expect_logno= 123;
RET_ERR_UNLESS(write_file(NULL, expect_logno, RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN,
objs_to_write) == 0); expect_logno,
objs_to_write) == 0);
RET_ERR_UNLESS(close_file() == 0); RET_ERR_UNLESS(close_file() == 0);
return 0; return 0;
} }
...@@ -208,8 +205,8 @@ static int test_five_logs() ...@@ -208,8 +205,8 @@ static int test_five_logs()
for (i= 0; i<5; i++) for (i= 0; i<5; i++)
{ {
expect_logno*= 3; expect_logno*= 3;
RET_ERR_UNLESS(write_file(NULL, expect_logno, RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN, expect_logno,
objs_to_write) == 0); objs_to_write) == 0);
} }
RET_ERR_UNLESS(close_file() == 0); RET_ERR_UNLESS(close_file() == 0);
return 0; return 0;
...@@ -224,29 +221,29 @@ static int test_3_checkpoints_and_2_logs() ...@@ -224,29 +221,29 @@ static int test_3_checkpoints_and_2_logs()
*/ */
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK); RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){5, 10000}; expect_checkpoint_lsn= MAKE_LSN(5, 10000);
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn, RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0); expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 17; expect_logno= 17;
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn, RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0); expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){17, 20000}; expect_checkpoint_lsn= MAKE_LSN(17, 20000);
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn, RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0); expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){17, 45000}; expect_checkpoint_lsn= MAKE_LSN(17, 45000);
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn, RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0); expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO; objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 19; expect_logno= 19;
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn, RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0); expect_logno, objs_to_write) == 0);
RET_ERR_UNLESS(close_file() == 0); RET_ERR_UNLESS(close_file() == 0);
return 0; return 0;
} }
...@@ -274,9 +271,9 @@ static int test_binary_content() ...@@ -274,9 +271,9 @@ static int test_binary_content()
RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0); RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0);
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK); RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
i= uint4korr(buffer+5); i= uint4korr(buffer+5);
RET_ERR_UNLESS(i == last_checkpoint_lsn.file_no); RET_ERR_UNLESS(i == LSN_FILE_NO(last_checkpoint_lsn));
i= uint4korr(buffer+9); i= uint4korr(buffer+9);
RET_ERR_UNLESS(i == last_checkpoint_lsn.rec_offset); RET_ERR_UNLESS(i == LSN_OFFSET(last_checkpoint_lsn));
i= uint4korr(buffer+13); i= uint4korr(buffer+13);
RET_ERR_UNLESS(i == last_logno); RET_ERR_UNLESS(i == last_logno);
RET_ERR_UNLESS(close_file() == 0); RET_ERR_UNLESS(close_file() == 0);
......
#include "../maria_def.h" #include "../maria_def.h"
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h>
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -102,7 +103,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec, ...@@ -102,7 +103,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
translog_size_t len; translog_size_t len;
DBUG_ENTER("read_and_check_content"); DBUG_ENTER("read_and_check_content");
DBUG_ASSERT(rec->record_length < LONG_BUFFER_SIZE + 7 * 2 + 2); DBUG_ASSERT(rec->record_length < LONG_BUFFER_SIZE + 7 * 2 + 2);
if ((len= translog_read_record(&rec->lsn, 0, rec->record_length, if ((len= translog_read_record(rec->lsn, 0, rec->record_length,
buffer, NULL)) != rec->record_length) buffer, NULL)) != rec->record_length)
{ {
fprintf(stderr, "Requested %lu byte, read %lu\n", fprintf(stderr, "Requested %lu byte, read %lu\n",
...@@ -149,16 +150,17 @@ void writer(int num) ...@@ -149,16 +150,17 @@ void writer(int num)
DBUG_PRINT("info", ("thread: %u, iteration: %u, len: %lu, " DBUG_PRINT("info", ("thread: %u, iteration: %u, len: %lu, "
"lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)", "lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)",
num, i, (ulong) lens[num][i], num, i, (ulong) lens[num][i],
(ulong) lsns1[num][i].file_no, (ulong) LSN_FILE_NO(lsns1[num][i]),
(ulong) lsns1[num][i].rec_offset, (ulong) LSN_OFFSET(lsns1[num][i]),
(ulong) lsns2[num][i].file_no, (ulong) LSN_FILE_NO(lsns2[num][i]),
(ulong) lsns2[num][i].rec_offset)); (ulong) LSN_OFFSET(lsns2[num][i])));
printf("thread: %u, iteration: %u, len: %lu, " printf("thread: %u, iteration: %u, len: %lu, "
"lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)\n", "lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)\n",
num, i, (ulong) lens[num][i], num, i, (ulong) lens[num][i],
(ulong) lsns1[num][i].file_no, (ulong) LSN_FILE_NO(lsns1[num][i]),
(ulong) lsns1[num][i].rec_offset, (ulong) LSN_OFFSET(lsns1[num][i]),
(ulong) lsns2[num][i].file_no, (ulong) lsns2[num][i].rec_offset); (ulong) LSN_FILE_NO(lsns2[num][i]),
(ulong) LSN_OFFSET(lsns2[num][i]));
} }
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -191,7 +193,7 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -191,7 +193,7 @@ int main(int argc, char **argv __attribute__ ((unused)))
uint32 i; uint32 i;
uint pagen; uint pagen;
PAGECACHE pagecache; PAGECACHE pagecache;
LSN first_lsn, *lsn_ptr; LSN first_lsn, lsn_ptr;
TRANSLOG_HEADER_BUFFER rec; TRANSLOG_HEADER_BUFFER rec;
struct st_translog_scanner_data scanner; struct st_translog_scanner_data scanner;
pthread_t tid; pthread_t tid;
...@@ -344,20 +346,18 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -344,20 +346,18 @@ int main(int argc, char **argv __attribute__ ((unused)))
/* Find last LSN and flush up to it (all our log) */ /* Find last LSN and flush up to it (all our log) */
{ {
LSN max= LSN max= 0;
{
0, 0
};
for (i= 0; i < WRITERS; i++) for (i= 0; i < WRITERS; i++)
{ {
if (cmp_translog_addr(lsns2[i][ITERATIONS - 1], max) > 0) if (cmp_translog_addr(lsns2[i][ITERATIONS - 1], max) > 0)
max= lsns2[i][ITERATIONS - 1]; max= lsns2[i][ITERATIONS - 1];
} }
DBUG_PRINT("info", ("first lsn: (%lu,0x%lx), max lsn: (%lu,0x%lx)", DBUG_PRINT("info", ("first lsn: (%lu,0x%lx), max lsn: (%lu,0x%lx)",
(ulong) first_lsn.file_no, (ulong) LSN_FILE_NO(first_lsn),
(ulong) first_lsn.rec_offset, (ulong) LSN_OFFSET(first_lsn),
(ulong) max.file_no, (ulong) max.rec_offset)); (ulong) LSN_FILE_NO(max),
translog_flush(&max); (ulong) LSN_OFFSET(max)));
translog_flush(max);
} }
rc= 1; rc= 1;
...@@ -369,11 +369,11 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -369,11 +369,11 @@ int main(int argc, char **argv __attribute__ ((unused)))
bzero(indeces, sizeof(indeces)); bzero(indeces, sizeof(indeces));
lsn_ptr= &first_lsn; lsn_ptr= first_lsn;
for (i= 0;; i++) for (i= 0;; i++)
{ {
len= translog_read_next_record_header(lsn_ptr, &rec, 1, &scanner); len= translog_read_next_record_header(lsn_ptr, &rec, 1, &scanner);
lsn_ptr= NULL; lsn_ptr= 0;
if (len == 0) if (len == 0)
{ {
...@@ -382,7 +382,7 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -382,7 +382,7 @@ int main(int argc, char **argv __attribute__ ((unused)))
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
if (rec.lsn.file_no == CONTROL_FILE_IMPOSSIBLE_FILENO) if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN)
{ {
if (i != WRITERS * ITERATIONS * 2) if (i != WRITERS * ITERATIONS * 2)
{ {
...@@ -412,9 +412,10 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -412,9 +412,10 @@ int main(int argc, char **argv __attribute__ ((unused)))
(uint) rec.short_trid, (uint) uint2korr(rec.header), (uint) rec.short_trid, (uint) uint2korr(rec.header),
(uint) rec.record_length, (uint) rec.record_length,
(uint) index, (uint) uint4korr(rec.header + 2), (uint) index, (uint) uint4korr(rec.header + 2),
(ulong) rec.lsn.file_no, (ulong) rec.lsn.rec_offset, (ulong) LSN_FILE_NO(rec.lsn),
(ulong) lsns1[rec.short_trid][index].file_no, (ulong) LSN_OFFSET(rec.lsn),
(ulong) lsns1[rec.short_trid][index].rec_offset); (ulong) LSN_FILE_NO(lsns1[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns1[rec.short_trid][index]));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -437,9 +438,10 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -437,9 +438,10 @@ int main(int argc, char **argv __attribute__ ((unused)))
(uint) len, (uint) len,
(ulong) rec.record_length, lens[rec.short_trid][index], (ulong) rec.record_length, lens[rec.short_trid][index],
(rec.record_length != lens[rec.short_trid][index]), (rec.record_length != lens[rec.short_trid][index]),
(ulong) rec.lsn.file_no, (ulong) rec.lsn.rec_offset, (ulong) LSN_FILE_NO(rec.lsn),
(ulong) lsns2[rec.short_trid][index].file_no, (ulong) LSN_OFFSET(rec.lsn),
(ulong) lsns2[rec.short_trid][index].rec_offset); (ulong) LSN_FILE_NO(lsns2[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns2[rec.short_trid][index]));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
...@@ -447,8 +449,9 @@ int main(int argc, char **argv __attribute__ ((unused))) ...@@ -447,8 +449,9 @@ int main(int argc, char **argv __attribute__ ((unused)))
{ {
fprintf(stderr, fprintf(stderr,
"Incorrect LOGREC_REDO_INSERT_ROW_HEAD in whole rec read " "Incorrect LOGREC_REDO_INSERT_ROW_HEAD in whole rec read "
"lsn(%u,0x%lx)\n", "lsn(%lu,0x%lx)\n",
(uint) rec.lsn.file_no, (ulong) rec.lsn.rec_offset); (ulong) LSN_FILE_NO(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec); translog_free_record_header(&rec);
goto err; goto err;
} }
......
#include "../maria_def.h" #include "../maria_def.h"
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <tap.h>
#ifndef DBUG_OFF #ifndef DBUG_OFF
static const char *default_dbug_option; static const char *default_dbug_option;
...@@ -106,7 +107,7 @@ int main(int argc, char *argv[]) ...@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
bzero(page, PCACHE_PAGE); bzero(page, PCACHE_PAGE);
#define PAGE_LSN_OFFSET 0 #define PAGE_LSN_OFFSET 0
lsn7store(page + PAGE_LSN_OFFSET, &lsn); lsn7store(page + PAGE_LSN_OFFSET, lsn);
pagecache_write(&pagecache, &file1, 0, 3, (char*)page, pagecache_write(&pagecache, &file1, 0, 3, (char*)page,
PAGECACHE_LSN_PAGE, PAGECACHE_LSN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED, PAGECACHE_LOCK_LEFT_UNLOCKED,
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <my_sys.h> #include <my_sys.h>
#include <m_string.h> #include <m_string.h>
#include "test_file.h" #include "test_file.h"
#include <tap.h>
#define PCACHE_SIZE (PAGE_SIZE*1024*8) #define PCACHE_SIZE (PAGE_SIZE*1024*8)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <my_sys.h> #include <my_sys.h>
#include <m_string.h> #include <m_string.h>
#include "test_file.h" #include "test_file.h"
#include <tap.h>
#define PCACHE_SIZE (PAGE_SIZE*1024*10) #define PCACHE_SIZE (PAGE_SIZE*1024*10)
...@@ -235,7 +236,7 @@ int simple_pin_test() ...@@ -235,7 +236,7 @@ int simple_pin_test()
0, 0,
PAGECACHE_LOCK_READ_UNLOCK, PAGECACHE_LOCK_READ_UNLOCK,
PAGECACHE_UNPIN, PAGECACHE_UNPIN,
0, 0); 0);
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE)) if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
{ {
diag("Got error in flush_pagecache_blocks\n"); diag("Got error in flush_pagecache_blocks\n");
...@@ -364,7 +365,7 @@ int simple_big_test() ...@@ -364,7 +365,7 @@ int simple_big_test()
0); 0);
} }
desc[i].length= 0; desc[i].length= 0;
desc[i].content= NULL; desc[i].content= '\0';
ok(1, "Simple big file write"); ok(1, "Simple big file write");
/* check written pages sequentally read */ /* check written pages sequentally read */
for (i= 0; i < PCACHE_SIZE/(PAGE_SIZE/2); i++) for (i= 0; i < PCACHE_SIZE/(PAGE_SIZE/2); i++)
......
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