Commit d0398f72 authored by unknown's avatar unknown

Storing/getting maximum LSN of the record which parts written

in the file to the file header.


storage/maria/ma_loghandler.h:
  Getting maximum LSN of the record which parts written
  in the file to the file header.
storage/maria/unittest/Makefile.am:
  Test suite for getting max LSN added.
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  Spelling fixed.
  Cleanup fixed.
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  Cleanup fixed.
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  New BitKeeper file ``storage/maria/unittest/ma_test_loghandler_max_lsn-t.c''
parent 4cf6756e
This diff is collapsed.
......@@ -250,6 +250,7 @@ extern my_bool translog_init_scanner(LSN lsn,
extern int translog_read_next_record_header(TRANSLOG_SCANNER_DATA *scanner,
TRANSLOG_HEADER_BUFFER *buff);
extern LSN translog_get_file_max_lsn_stored(ulong file);
extern my_bool translog_lock();
extern my_bool translog_unlock();
extern void translog_lock_assert_owner();
......
......@@ -44,7 +44,8 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
ma_test_loghandler_pagecache-t \
ma_test_loghandler_long-t-big \
ma_test_loghandler_noflush-t \
ma_test_loghandler_first_lsn-t
ma_test_loghandler_first_lsn-t \
ma_test_loghandler_max_lsn-t
ma_test_loghandler_t_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c
ma_test_loghandler_multigroup_t_SOURCES = ma_test_loghandler_multigroup-t.c ma_maria_log_cleanup.c
......@@ -54,6 +55,7 @@ ma_test_loghandler_long_t_big_SOURCES = ma_test_loghandler-t.c ma_maria_log_clea
ma_test_loghandler_long_t_big_CPPFLAGS = -DLONG_LOG_TEST
ma_test_loghandler_noflush_t_SOURCES = ma_test_loghandler_noflush-t.c ma_maria_log_cleanup.c
ma_test_loghandler_first_lsn_t_SOURCES = ma_test_loghandler_first_lsn-t.c ma_maria_log_cleanup.c
ma_test_loghandler_max_lsn_t_SOURCES = ma_test_loghandler_max_lsn-t.c ma_maria_log_cleanup.c
ma_pagecache_single_src = ma_pagecache_single.c test_file.c
ma_pagecache_consist_src = ma_pagecache_consist.c test_file.c
......
......@@ -89,7 +89,7 @@ int main(int argc __attribute__((unused)), char *argv[])
first_lsn= translog_first_lsn_in_log();
if (first_lsn != LSN_IMPOSSIBLE)
{
fprintf(stderr, "Incorrect first lsn responce (%lu,0x%lx).",
fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).",
(ulong) LSN_FILE_NO(first_lsn),
(ulong) LSN_OFFSET(first_lsn));
translog_destroy();
......@@ -143,8 +143,7 @@ int main(int argc __attribute__((unused)), char *argv[])
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
my_delete(first_translog_file, MYF(0));
if (maria_log_remove())
exit(1);
exit(0);
}
#include "../maria_def.h"
#include <stdio.h>
#include <errno.h>
#include <tap.h>
#include "../trnman.h"
extern my_bool maria_log_remove();
#ifndef DBUG_OFF
static const char *default_dbug_option;
#endif
#define PCACHE_SIZE (1024*1024*10)
#define PCACHE_PAGE TRANSLOG_PAGE_SIZE
#define LOG_FILE_SIZE (4*1024L*1024L)
#define LOG_FLAGS 0
int main(int argc __attribute__((unused)), char *argv[])
{
ulong i;
uint pagen;
uchar long_tr_id[6];
PAGECACHE pagecache;
LSN lsn, max_lsn, last_lsn= LSN_IMPOSSIBLE;
MY_STAT st;
LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
MY_INIT(argv[0]);
plan(2);
bzero(&pagecache, sizeof(pagecache));
maria_data_root= ".";
if (maria_log_remove())
exit(1);
bzero(long_tr_id, 6);
#ifndef DBUG_OFF
#if defined(__WIN__)
default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
#else
default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace";
#endif
if (argc > 1)
{
DBUG_SET(default_dbug_option);
DBUG_SET_INITIAL(default_dbug_option);
}
#endif
if (ma_control_file_create_or_open(TRUE))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
}
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
PCACHE_PAGE)) == 0)
{
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
exit(1);
}
if (translog_init(".", LOG_FILE_SIZE, 50112, 0, &pagecache, LOG_FLAGS))
{
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
translog_destroy();
exit(1);
}
example_loghandler_init();
max_lsn= translog_get_file_max_lsn_stored(1);
if (max_lsn == 1)
{
fprintf(stderr, "Error reading the first log file.");
translog_destroy();
exit(1);
}
if (max_lsn != LSN_IMPOSSIBLE)
{
fprintf(stderr, "Incorrect first lsn response (%lu,0x%lx).",
(ulong) LSN_FILE_NO(max_lsn),
(ulong) LSN_OFFSET(max_lsn));
translog_destroy();
exit(1);
}
ok(1, "Empty log response");
/* write more then 1 file */
int4store(long_tr_id, 0);
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
for(i= 0; i < LOG_FILE_SIZE/6; i++)
{
if (translog_write_record(&lsn,
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
&dummy_transaction_object, NULL, 6,
TRANSLOG_INTERNAL_PARTS + 1,
parts, NULL))
{
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
translog_destroy();
exit(1);
}
if (LSN_FILE_NO(lsn) == 1)
last_lsn= lsn;
}
max_lsn= translog_get_file_max_lsn_stored(1);
if (max_lsn == 1)
{
fprintf(stderr, "Error reading the first log file\n");
translog_destroy();
exit(1);
}
if (max_lsn == LSN_IMPOSSIBLE)
{
fprintf(stderr, "Isn't first file still finished?!!\n");
translog_destroy();
exit(1);
}
if (max_lsn != last_lsn)
{
fprintf(stderr, "Incorrect max lsn: (%lu,0x%lx) "
" last lsn on first file: (%lu,0x%lx)\n",
(ulong) LSN_FILE_NO(max_lsn),
(ulong) LSN_OFFSET(max_lsn),
(ulong) LSN_FILE_NO(last_lsn),
(ulong) LSN_OFFSET(last_lsn));
translog_destroy();
exit(1);
}
ok(1, "First file max LSN");
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
if (maria_log_remove())
exit(1);
exit(0);
}
......@@ -125,8 +125,8 @@ err:
translog_destroy();
end_pagecache(&pagecache, 1);
ma_control_file_end();
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
my_delete(first_translog_file, MYF(0));
if (maria_log_remove())
exit(1);
exit(rc);
}
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