Commit 1f59a95c 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 39ed39eb
......@@ -21,6 +21,7 @@
C_MODE_START
#include "../storage/maria/ma_loghandler_lsn.h"
#include <m_string.h>
/* Type of the page */
enum pagecache_page_type
......@@ -73,8 +74,6 @@ enum pagecache_write_mode
typedef void *PAGECACHE_PAGE_LINK;
typedef uint64 LSN;
/* file descriptor for Maria */
typedef struct st_pagecache_file
{
......@@ -152,8 +151,8 @@ typedef struct st_pagecache
ulong param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_key_cache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */
/* Statistics variables. These are reset in reset_pagecache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */
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_r_requests;/* number of read requests (read hits) */
......@@ -200,14 +199,12 @@ extern void pagecache_unlock_page(PAGECACHE *pagecache,
pgcache_page_no_t pageno,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
my_bool stamp_this_page,
LSN_PTR first_REDO_LSN_for_page);
LSN first_REDO_LSN_for_page);
extern void pagecache_unlock(PAGECACHE *pagecache,
PAGECACHE_PAGE_LINK *link,
enum pagecache_page_lock lock,
enum pagecache_page_pin pin,
my_bool stamp_this_page,
LSN_PTR first_REDO_LSN_for_page);
LSN first_REDO_LSN_for_page);
extern void pagecache_unpin_page(PAGECACHE *pagecache,
PAGECACHE_FILE *file,
pgcache_page_no_t pageno);
......@@ -225,6 +222,7 @@ extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup);
extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LEX_STRING *str,
LSN *max_lsn);
extern int reset_pagecache_counters(const char *name, PAGECACHE *pagecache);
C_MODE_END
#endif /* _keycache_h */
This diff is collapsed.
......@@ -37,7 +37,7 @@
#define CONTROL_FILE_CHECKSUM_OFFSET (CONTROL_FILE_MAGIC_STRING_OFFSET + CONTROL_FILE_MAGIC_STRING_SIZE)
#define CONTROL_FILE_CHECKSUM_SIZE 1
#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_SIZE 4
#define CONTROL_FILE_SIZE (CONTROL_FILE_FILENO_OFFSET + CONTROL_FILE_FILENO_SIZE)
......@@ -59,20 +59,6 @@ uint32 last_logno;
*/
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)
{
/* TODO: improve this sum if we want */
......@@ -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
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);
if (control_file_fd >= 0) /* already 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).
*/
LSN imposs_lsn= CONTROL_FILE_IMPOSSIBLE_LSN;
uint32 imposs_logno= CONTROL_FILE_IMPOSSIBLE_FILENO;
/* 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));
}
......@@ -216,7 +200,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
error= CONTROL_FILE_BAD_CHECKSUM;
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);
DBUG_RETURN(0);
......@@ -253,7 +237,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
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)
{
char buffer[CONTROL_FILE_SIZE];
......@@ -277,9 +261,9 @@ int ma_control_file_write_and_force(const LSN *checkpoint_lsn, uint32 logno,
DBUG_ASSERT(0);
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 */
lsn8store(buffer + CONTROL_FILE_LSN_OFFSET, &last_checkpoint_lsn);
lsn7store(buffer + CONTROL_FILE_LSN_OFFSET, last_checkpoint_lsn);
if (update_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,
/* TODO: you need some protection to be able to write last_* global vars */
if (update_checkpoint_lsn)
last_checkpoint_lsn= *checkpoint_lsn;
last_checkpoint_lsn= checkpoint_lsn;
if (update_logno)
last_logno= logno;
......
......@@ -30,16 +30,14 @@
#define CONTROL_FILE_IMPOSSIBLE_FILENO 0
/* logs always have a header */
#define CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET 0
/*
indicate absence of LSN.
*/
#define CONTROL_FILE_IMPOSSIBLE_LSN ((LSN){CONTROL_FILE_IMPOSSIBLE_FILENO,CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET})
/* indicate absence of LSN. */
#define CONTROL_FILE_IMPOSSIBLE_LSN ((LSN)0)
/* Here is the interface of this module */
/*
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)
*/
extern LSN last_checkpoint_lsn;
......@@ -72,7 +70,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open();
#define CONTROL_FILE_UPDATE_ALL 0
#define CONTROL_FILE_UPDATE_ONLY_LSN 1
#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);
......
This diff is collapsed.
......@@ -218,7 +218,7 @@ void translog_destroy();
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);
......@@ -249,7 +249,7 @@ void translog_free_record_header(TRANSLOG_HEADER_BUFFER *buff);
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 length,
uchar *buffer,
......@@ -269,7 +269,7 @@ translog_size_t translog_read_record(LSN *lsn,
1 - Error
*/
my_bool translog_flush(LSN *lsn);
my_bool translog_flush(LSN lsn);
/*
......@@ -304,7 +304,7 @@ my_bool translog_flush(LSN *lsn);
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,
my_bool fixed_horizon,
struct
......
......@@ -2,11 +2,7 @@
#define _ma_loghandler_lsn_h
/* Transaction log record address (file_no is int24 on the disk) */
typedef struct st_translog_address
{
uint32 file_no;
uint32 rec_offset;
} TRANSLOG_ADDRESS;
typedef int64 TRANSLOG_ADDRESS;
/*
Compare addresses
......@@ -14,26 +10,39 @@ typedef struct st_translog_address
A1 == A2 -> 0
A1 < A2 -> result < 0
*/
#define cmp_translog_addr(A1,A2) \
((A1).file_no == (A2).file_no ? \
((int64)(A1).rec_offset) - (int64)(A2).rec_offset : \
((int64)(A1).file_no - (int64)(A2).file_no))
#define cmp_translog_addr(A1,A2) ((A1) - (A2))
/* LSN type (address of certain log record chank */
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) */
#define lsn7store(dst, lsn) \
do { \
int3store((dst), (lsn)->file_no); \
int4store((dst) + 3, (lsn)->rec_offset); \
int3store((dst), LSN_FILE_NO(lsn)); \
int4store((dst) + 3, LSN_OFFSET(lsn)); \
} while (0)
/* Unpacks LSN from the buffer (P) */
#define lsn7korr(lsn, P) \
do { \
(lsn)->file_no= uint3korr(P); \
(lsn)->rec_offset= uint4korr((P) + 3); \
} while (0)
#define lsn7korr(P) MAKE_LSN(uint3korr(P), uint4korr((P) + 3))
/* what we need to add to LSN to increase it on one file */
#define LSN_ONE_FILE ((int64)0x100000000LL)
#define LSN_REPLACE_OFFSET(L, S) (LSN_FINE_NO_PART(L) | (S))
#endif
......@@ -30,14 +30,15 @@ LDADD= $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/storage/maria/ma_loghandler.o
noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
mf_pagecache_single_1k-t mf_pagecache_single_8k-t \
mf_pagecache_single_64k-t \
mf_pagecache_consist_1k-t mf_pagecache_consist_64k-t \
mf_pagecache_consist_1kHC-t \
mf_pagecache_consist_64kHC-t \
mf_pagecache_consist_1kRD-t \
mf_pagecache_consist_64kRD-t \
mf_pagecache_consist_1kWR-t \
mf_pagecache_consist_64kWR-t \
mf_pagecache_single_64k-t-big \
mf_pagecache_consist_1k-t-big \
mf_pagecache_consist_64k-t-big \
mf_pagecache_consist_1kHC-t-big \
mf_pagecache_consist_64kHC-t-big \
mf_pagecache_consist_1kRD-t-big \
mf_pagecache_consist_64kRD-t-big \
mf_pagecache_consist_1kWR-t-big \
mf_pagecache_consist_64kWR-t-big \
ma_test_loghandler-t \
ma_test_loghandler_multigroup-t \
ma_test_loghandler_multithread-t \
......@@ -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_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_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_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_consist_64k_t_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_64k_t_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536
mf_pagecache_consist_1k_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1k_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024
mf_pagecache_consist_64k_t_big_SOURCES = $(mf_pagecache_consist_src)
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_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_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_1kHC_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kHC_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_HIGH_CONCURENCY
mf_pagecache_consist_64kHC_t_big_SOURCES = $(mf_pagecache_consist_src)
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_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_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_READERS
mf_pagecache_consist_1kRD_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kRD_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_READERS
mf_pagecache_consist_64kRD_t_big_SOURCES = $(mf_pagecache_consist_src)
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_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_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=65536 -DTEST_WRITERS
mf_pagecache_consist_1kWR_t_big_SOURCES = $(mf_pagecache_consist_src)
mf_pagecache_consist_1kWR_t_big_CPPFLAGS = $(mf_pagecache_common_cppflags) -DPAGE_SIZE=1024 -DTEST_WRITERS
mf_pagecache_consist_64kWR_t_big_SOURCES = $(mf_pagecache_consist_src)
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,
# so we don't build lockman-t and lockman1-t
CLEANFILES = maria_control page_cache_test_file_1 \
maria_log.???????? maria_control
noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t
maria_log.????????
......@@ -133,10 +133,8 @@ static int delete_file(myf my_flags)
static int verify_module_values_match_expected()
{
RET_ERR_UNLESS(last_logno == expect_logno);
RET_ERR_UNLESS(last_checkpoint_lsn.file_no ==
expect_checkpoint_lsn.file_no);
RET_ERR_UNLESS(last_checkpoint_lsn.rec_offset ==
expect_checkpoint_lsn.rec_offset);
RET_ERR_UNLESS(last_checkpoint_lsn ==
expect_checkpoint_lsn);
return 0;
}
......@@ -148,10 +146,8 @@ static int verify_module_values_match_expected()
static int verify_module_values_are_impossible()
{
RET_ERR_UNLESS(last_logno == CONTROL_FILE_IMPOSSIBLE_FILENO);
RET_ERR_UNLESS(last_checkpoint_lsn.file_no ==
CONTROL_FILE_IMPOSSIBLE_FILENO);
RET_ERR_UNLESS(last_checkpoint_lsn.rec_offset ==
CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET);
RET_ERR_UNLESS(last_checkpoint_lsn ==
CONTROL_FILE_IMPOSSIBLE_LSN);
return 0;
}
......@@ -173,9 +169,9 @@ static int create_or_open_file()
return 0;
}
static int write_file(const LSN *checkpoint_lsn,
uint32 logno,
uint objs_to_write)
static int write_file(const LSN checkpoint_lsn,
uint32 logno,
uint objs_to_write)
{
RET_ERR_UNLESS(ma_control_file_write_and_force(checkpoint_lsn, logno,
objs_to_write) == 0);
......@@ -191,8 +187,9 @@ static int test_one_log()
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 123;
RET_ERR_UNLESS(write_file(NULL, expect_logno,
objs_to_write) == 0);
RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN,
expect_logno,
objs_to_write) == 0);
RET_ERR_UNLESS(close_file() == 0);
return 0;
}
......@@ -208,8 +205,8 @@ static int test_five_logs()
for (i= 0; i<5; i++)
{
expect_logno*= 3;
RET_ERR_UNLESS(write_file(NULL, expect_logno,
objs_to_write) == 0);
RET_ERR_UNLESS(write_file(CONTROL_FILE_IMPOSSIBLE_LSN, expect_logno,
objs_to_write) == 0);
}
RET_ERR_UNLESS(close_file() == 0);
return 0;
......@@ -224,29 +221,29 @@ static int test_3_checkpoints_and_2_logs()
*/
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){5, 10000};
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
expect_checkpoint_lsn= MAKE_LSN(5, 10000);
RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 17;
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){17, 20000};
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
expect_checkpoint_lsn= MAKE_LSN(17, 20000);
RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LSN;
expect_checkpoint_lsn= (LSN){17, 45000};
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
expect_checkpoint_lsn= MAKE_LSN(17, 45000);
RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
objs_to_write= CONTROL_FILE_UPDATE_ONLY_LOGNO;
expect_logno= 19;
RET_ERR_UNLESS(write_file(&expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
RET_ERR_UNLESS(write_file(expect_checkpoint_lsn,
expect_logno, objs_to_write) == 0);
RET_ERR_UNLESS(close_file() == 0);
return 0;
}
......@@ -274,9 +271,9 @@ static int test_binary_content()
RET_ERR_UNLESS(my_close(fd, MYF(MY_WME)) == 0);
RET_ERR_UNLESS(create_or_open_file() == CONTROL_FILE_OK);
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);
RET_ERR_UNLESS(i == last_checkpoint_lsn.rec_offset);
RET_ERR_UNLESS(i == LSN_OFFSET(last_checkpoint_lsn));
i= uint4korr(buffer+13);
RET_ERR_UNLESS(i == last_logno);
RET_ERR_UNLESS(close_file() == 0);
......
#include "../maria_def.h"
#include <stdio.h>
#include <errno.h>
#include <tap.h>
#ifndef DBUG_OFF
static const char *default_dbug_option;
......@@ -102,7 +103,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
translog_size_t len;
DBUG_ENTER("read_and_check_content");
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)
{
fprintf(stderr, "Requested %lu byte, read %lu\n",
......@@ -149,16 +150,17 @@ void writer(int num)
DBUG_PRINT("info", ("thread: %u, iteration: %u, len: %lu, "
"lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)",
num, i, (ulong) lens[num][i],
(ulong) lsns1[num][i].file_no,
(ulong) lsns1[num][i].rec_offset,
(ulong) lsns2[num][i].file_no,
(ulong) lsns2[num][i].rec_offset));
(ulong) LSN_FILE_NO(lsns1[num][i]),
(ulong) LSN_OFFSET(lsns1[num][i]),
(ulong) LSN_FILE_NO(lsns2[num][i]),
(ulong) LSN_OFFSET(lsns2[num][i])));
printf("thread: %u, iteration: %u, len: %lu, "
"lsn1 (%lu,0x%lx) lsn2 (%lu,0x%lx)\n",
num, i, (ulong) lens[num][i],
(ulong) lsns1[num][i].file_no,
(ulong) lsns1[num][i].rec_offset,
(ulong) lsns2[num][i].file_no, (ulong) lsns2[num][i].rec_offset);
(ulong) LSN_FILE_NO(lsns1[num][i]),
(ulong) LSN_OFFSET(lsns1[num][i]),
(ulong) LSN_FILE_NO(lsns2[num][i]),
(ulong) LSN_OFFSET(lsns2[num][i]));
}
DBUG_VOID_RETURN;
}
......@@ -191,7 +193,7 @@ int main(int argc, char **argv __attribute__ ((unused)))
uint32 i;
uint pagen;
PAGECACHE pagecache;
LSN first_lsn, *lsn_ptr;
LSN first_lsn, lsn_ptr;
TRANSLOG_HEADER_BUFFER rec;
struct st_translog_scanner_data scanner;
pthread_t tid;
......@@ -344,20 +346,18 @@ int main(int argc, char **argv __attribute__ ((unused)))
/* Find last LSN and flush up to it (all our log) */
{
LSN max=
{
0, 0
};
LSN max= 0;
for (i= 0; i < WRITERS; i++)
{
if (cmp_translog_addr(lsns2[i][ITERATIONS - 1], max) > 0)
max= lsns2[i][ITERATIONS - 1];
}
DBUG_PRINT("info", ("first lsn: (%lu,0x%lx), max lsn: (%lu,0x%lx)",
(ulong) first_lsn.file_no,
(ulong) first_lsn.rec_offset,
(ulong) max.file_no, (ulong) max.rec_offset));
translog_flush(&max);
(ulong) LSN_FILE_NO(first_lsn),
(ulong) LSN_OFFSET(first_lsn),
(ulong) LSN_FILE_NO(max),
(ulong) LSN_OFFSET(max)));
translog_flush(max);
}
rc= 1;
......@@ -369,11 +369,11 @@ int main(int argc, char **argv __attribute__ ((unused)))
bzero(indeces, sizeof(indeces));
lsn_ptr= &first_lsn;
lsn_ptr= first_lsn;
for (i= 0;; i++)
{
len= translog_read_next_record_header(lsn_ptr, &rec, 1, &scanner);
lsn_ptr= NULL;
lsn_ptr= 0;
if (len == 0)
{
......@@ -382,7 +382,7 @@ int main(int argc, char **argv __attribute__ ((unused)))
translog_free_record_header(&rec);
goto err;
}
if (rec.lsn.file_no == CONTROL_FILE_IMPOSSIBLE_FILENO)
if (rec.lsn == CONTROL_FILE_IMPOSSIBLE_LSN)
{
if (i != WRITERS * ITERATIONS * 2)
{
......@@ -412,9 +412,10 @@ int main(int argc, char **argv __attribute__ ((unused)))
(uint) rec.short_trid, (uint) uint2korr(rec.header),
(uint) rec.record_length,
(uint) index, (uint) uint4korr(rec.header + 2),
(ulong) rec.lsn.file_no, (ulong) rec.lsn.rec_offset,
(ulong) lsns1[rec.short_trid][index].file_no,
(ulong) lsns1[rec.short_trid][index].rec_offset);
(ulong) LSN_FILE_NO(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn),
(ulong) LSN_FILE_NO(lsns1[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns1[rec.short_trid][index]));
translog_free_record_header(&rec);
goto err;
}
......@@ -437,9 +438,10 @@ int main(int argc, char **argv __attribute__ ((unused)))
(uint) len,
(ulong) 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) lsns2[rec.short_trid][index].file_no,
(ulong) lsns2[rec.short_trid][index].rec_offset);
(ulong) LSN_FILE_NO(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn),
(ulong) LSN_FILE_NO(lsns2[rec.short_trid][index]),
(ulong) LSN_OFFSET(lsns2[rec.short_trid][index]));
translog_free_record_header(&rec);
goto err;
}
......@@ -447,8 +449,9 @@ int main(int argc, char **argv __attribute__ ((unused)))
{
fprintf(stderr,
"Incorrect LOGREC_REDO_INSERT_ROW_HEAD in whole rec read "
"lsn(%u,0x%lx)\n",
(uint) rec.lsn.file_no, (ulong) rec.lsn.rec_offset);
"lsn(%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(rec.lsn),
(ulong) LSN_OFFSET(rec.lsn));
translog_free_record_header(&rec);
goto err;
}
......
#include "../maria_def.h"
#include <stdio.h>
#include <errno.h>
#include <tap.h>
#ifndef DBUG_OFF
static const char *default_dbug_option;
......@@ -106,7 +107,7 @@ int main(int argc, char *argv[])
bzero(page, PCACHE_PAGE);
#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_LSN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......
......@@ -8,6 +8,7 @@
#include <my_sys.h>
#include <m_string.h>
#include "test_file.h"
#include <tap.h>
#define PCACHE_SIZE (PAGE_SIZE*1024*8)
......
......@@ -7,6 +7,7 @@
#include <my_sys.h>
#include <m_string.h>
#include "test_file.h"
#include <tap.h>
#define PCACHE_SIZE (PAGE_SIZE*1024*10)
......@@ -235,7 +236,7 @@ int simple_pin_test()
0,
PAGECACHE_LOCK_READ_UNLOCK,
PAGECACHE_UNPIN,
0, 0);
0);
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
{
diag("Got error in flush_pagecache_blocks\n");
......@@ -364,7 +365,7 @@ int simple_big_test()
0);
}
desc[i].length= 0;
desc[i].content= NULL;
desc[i].content= '\0';
ok(1, "Simple big file write");
/* check written pages sequentally read */
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