Commit 8e49d20d authored by unknown's avatar unknown

Postreview changes.

Fixed befaviour when loghandler flags changed from one
run to another one.
Description of maria transaction log and control file
added to the file commandÍs magic number file.


mysys/mf_pagecache.c:
  postreview changes
storage/maria/ma_control_file.c:
  Postreview changes.
storage/maria/ma_control_file.h:
  Postreview changes.
storage/maria/ma_loghandler.c:
  Postreview changes.
  Fixed befaviour when loghandler flags changed from
  one run to another one.
storage/maria/ma_loghandler.h:
  Postreview changes.
  Functions comment left only near the function body.
storage/maria/ma_loghandler_lsn.h:
  Postreview changes.
storage/maria/unittest/ma_test_loghandler-t.c:
  Postreview changes.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Postreview changes.
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Postreview changes.
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  Postreview changes.
support-files/magic:
  Description of maria transaction log and control file
  added to the file commandÕs magic number file.
parent 1f59a95c
......@@ -570,7 +570,7 @@ static uint pagecache_fwrite(PAGECACHE *pagecache,
DBUG_PRINT("info", ("Log handler call"));
/* TODO: integrate with page format */
#define PAGE_LSN_OFFSET 0
lsn= lsn7korr(buffer + PAGE_LSN_OFFSET);
lsn= lsn_korr(buffer + PAGE_LSN_OFFSET);
/*
check CONTROL_FILE_IMPOSSIBLE_FILENO &
CONTROL_FILE_IMPOSSIBLE_LOG_OFFSET
......
......@@ -21,7 +21,6 @@
*/
#include "maria_def.h"
#include "ma_control_file.h"
/* Here is the implementation of this module */
......@@ -31,13 +30,13 @@
*/
/* total size should be < sector size for atomic write operation */
#define CONTROL_FILE_MAGIC_STRING "MACF"
#define CONTROL_FILE_MAGIC_STRING "\xfe\xfe\xc\1MACF"
#define CONTROL_FILE_MAGIC_STRING_OFFSET 0
#define CONTROL_FILE_MAGIC_STRING_SIZE (sizeof(CONTROL_FILE_MAGIC_STRING)-1)
#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 (3+4)
#define CONTROL_FILE_LSN_SIZE LSN_STORE_SIZE
#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)
......@@ -200,7 +199,7 @@ CONTROL_FILE_ERROR ma_control_file_create_or_open()
error= CONTROL_FILE_BAD_CHECKSUM;
goto err;
}
last_checkpoint_lsn= lsn7korr(buffer + CONTROL_FILE_LSN_OFFSET);
last_checkpoint_lsn= lsn_korr(buffer + CONTROL_FILE_LSN_OFFSET);
last_logno= uint4korr(buffer + CONTROL_FILE_FILENO_OFFSET);
DBUG_RETURN(0);
......@@ -261,9 +260,9 @@ int ma_control_file_write_and_force(const LSN checkpoint_lsn, uint32 logno,
DBUG_ASSERT(0);
if (update_checkpoint_lsn)
lsn7store(buffer + CONTROL_FILE_LSN_OFFSET, checkpoint_lsn);
lsn_store(buffer + CONTROL_FILE_LSN_OFFSET, checkpoint_lsn);
else /* store old value == change nothing */
lsn7store(buffer + CONTROL_FILE_LSN_OFFSET, last_checkpoint_lsn);
lsn_store(buffer + CONTROL_FILE_LSN_OFFSET, last_checkpoint_lsn);
if (update_logno)
int4store(buffer + CONTROL_FILE_FILENO_OFFSET, logno);
......
......@@ -19,9 +19,6 @@
First version written by Guilhem Bichot on 2006-04-27.
*/
#ifndef _ma_control_file_h
#define _ma_control_file_h
#define CONTROL_FILE_BASE_NAME "maria_control"
/*
indicate absence of the log file number; first log is always number 1, 0 is
......@@ -47,11 +44,6 @@ extern LSN last_checkpoint_lsn;
*/
extern uint32 last_logno;
/*
Looks for the control file. If absent, it's a fresh start, create file.
If present, read it to find out last checkpoint's LSN and last log.
Called at engine's start.
*/
typedef enum enum_control_file_error {
CONTROL_FILE_OK= 0,
CONTROL_FILE_TOO_SMALL,
......@@ -60,21 +52,26 @@ typedef enum enum_control_file_error {
CONTROL_FILE_BAD_CHECKSUM,
CONTROL_FILE_UNKNOWN_ERROR /* any other error */
} CONTROL_FILE_ERROR;
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
/*
Looks for the control file. If absent, it's a fresh start, create file.
If present, read it to find out last checkpoint's LSN and last log.
Called at engine's start.
*/
CONTROL_FILE_ERROR ma_control_file_create_or_open();
/*
Write information durably to the control file.
Called when we have created a new log (after syncing this log's creation)
and when we have written a checkpoint (after syncing this log record).
*/
#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,
uint objs_to_write);
/* Free resources taken by control file subsystem */
int ma_control_file_end();
#endif
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -30,15 +30,18 @@ typedef TRANSLOG_ADDRESS LSN;
/* checks LSN */
#define LSN_VALID(L) DBUG_ASSERT((L) >= 0 && (L) < (uint64)0xFFFFFFFFFFFFFFLL)
/* size of stored LSN on a disk */
#define LSN_STORE_SIZE 7
/* Puts LSN into buffer (dst) */
#define lsn7store(dst, lsn) \
#define lsn_store(dst, lsn) \
do { \
int3store((dst), LSN_FILE_NO(lsn)); \
int4store((dst) + 3, LSN_OFFSET(lsn)); \
} while (0)
/* Unpacks LSN from the buffer (P) */
#define lsn7korr(P) MAKE_LSN(uint3korr(P), uint4korr((P) + 3))
#define lsn_korr(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)
......
......@@ -27,7 +27,7 @@ static uint thread_count;
static ulong lens[WRITERS][ITERATIONS];
static LSN lsns1[WRITERS][ITERATIONS];
static LSN lsns2[WRITERS][ITERATIONS];
static uchar *long_buffer;
static byte *long_buffer;
/*
Get pseudo-random length of the field in
......@@ -65,12 +65,12 @@ static uint32 get_len()
1 - Error
*/
static my_bool check_content(uchar *ptr, ulong length)
static my_bool check_content(byte *ptr, ulong length)
{
ulong i;
for (i= 0; i < length; i++)
{
if (ptr[i] != (i & 0xFF))
if (((uchar)ptr[i]) != (i & 0xFF))
{
fprintf(stderr, "Byte # %lu is %x instead of %x",
i, (uint) ptr[i], (uint) (i & 0xFF));
......@@ -97,7 +97,7 @@ static my_bool check_content(uchar *ptr, ulong length)
static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
uchar *buffer, uint skip)
byte *buffer, uint skip)
{
int res= 0;
translog_size_t len;
......@@ -117,7 +117,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
void writer(int num)
{
LSN lsn;
uchar long_tr_id[6];
byte long_tr_id[6];
uint i;
DBUG_ENTER("writer");
......@@ -193,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;
TRANSLOG_HEADER_BUFFER rec;
struct st_translog_scanner_data scanner;
pthread_t tid;
......@@ -290,7 +290,7 @@ int main(int argc, char **argv __attribute__ ((unused)))
srandom(122334817L);
{
uchar long_tr_id[6]=
byte long_tr_id[6]=
{
0x11, 0x22, 0x33, 0x44, 0x55, 0x66
};
......@@ -369,11 +369,14 @@ int main(int argc, char **argv __attribute__ ((unused)))
bzero(indeces, sizeof(indeces));
lsn_ptr= first_lsn;
if (translog_init_scanner(first_lsn, 1, &scanner))
{
fprintf(stderr, "scanner init failed\n");
goto err;
}
for (i= 0;; i++)
{
len= translog_read_next_record_header(lsn_ptr, &rec, 1, &scanner);
lsn_ptr= 0;
len= translog_read_next_record_header(&scanner, &rec);
if (len == 0)
{
......
......@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
bzero(page, PCACHE_PAGE);
#define PAGE_LSN_OFFSET 0
lsn7store(page + PAGE_LSN_OFFSET, lsn);
lsn_store(page + PAGE_LSN_OFFSET, lsn);
pagecache_write(&pagecache, &file1, 0, 3, (char*)page,
PAGECACHE_LSN_PAGE,
PAGECACHE_LOCK_LEFT_UNLOCKED,
......
......@@ -17,3 +17,10 @@
0 belong&0xffffff00 0xfefe0600 MySQL ISAM compressed data file
>3 byte x Version %d
0 string \376bin MySQL replication log
0 belong&0xffffff00 0xfefe0b00
>4 string MARIALOG MySQL Maria transaction log file
>>3 byte x Version %d
0 belong&0xffffff00 0xfefe0c00
>4 string MACF MySQL Maria control file
>>3 byte x Version %d
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