mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Merge desktop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-maria
into desktop.sanja.is.com.ua:/home/bell/mysql/bk/work-maria-lsn storage/maria/ma_loghandler.h: Auto merged storage/maria/unittest/ma_test_loghandler_multithread-t.c: Auto merged storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Auto merged storage/maria/ma_loghandler.c: merge storage/maria/unittest/ma_test_loghandler-t.c: merge storage/maria/unittest/ma_test_loghandler_multigroup-t.c: merge
This commit is contained in:
commit
98e80921a8
9 changed files with 300 additions and 161 deletions
|
@ -3000,3 +3000,4 @@ storage/maria/unittest/ma_pagecache_consist_64kWR-t-big
|
|||
storage/maria/unittest/ma_pagecache_single_64k-t-big
|
||||
storage/maria/maria_control
|
||||
storage/maria/maria_log.*
|
||||
storage/maria/unittest/ma_test_loghandler_long-t-big
|
||||
|
|
|
@ -44,7 +44,6 @@ int maria_init(void)
|
|||
maria_inited= TRUE;
|
||||
pthread_mutex_init(&THR_LOCK_maria,MY_MUTEX_INIT_SLOW);
|
||||
_ma_init_block_record_data();
|
||||
loghandler_init();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,9 @@
|
|||
putchar('\n'); \
|
||||
} while(0);
|
||||
|
||||
|
||||
/* Maximum length of compressed LSNs (the worst case of whole LSN storing) */
|
||||
#define COMPRESSED_LSN_MAX_STORE_SIZE (2 + LSN_STORE_SIZE)
|
||||
#define MAX_NUMBER_OF_LSNS_PER_RECORD 2
|
||||
|
||||
/* record parts descriptor */
|
||||
struct st_translog_parts
|
||||
|
@ -185,7 +187,6 @@ enum record_class
|
|||
|
||||
/* compressed (relative) LSN constants */
|
||||
#define TRANSLOG_CLSN_LEN_BITS 0xC0 /* Mask to get compressed LSN length */
|
||||
#define TRANSLOG_CLSN_MAX_LEN 5 /* Maximum length of compressed LSN */
|
||||
|
||||
typedef my_bool(*prewrite_rec_hook) (enum translog_record_type type,
|
||||
TRN *trn, struct st_maria_share *share,
|
||||
|
@ -208,7 +209,10 @@ struct st_log_record_type_descriptor
|
|||
{
|
||||
/* internal class of the record */
|
||||
enum record_class class;
|
||||
/* length for fixed-size record, or maximum length of pseudo-fixed */
|
||||
/*
|
||||
length for fixed-size record, pseudo-fixed record
|
||||
length with uncompressed LSNs
|
||||
*/
|
||||
uint16 fixed_length;
|
||||
/* how much record body (belonged to headers too) read with headers */
|
||||
uint16 read_header_len;
|
||||
|
@ -238,13 +242,48 @@ static my_bool write_hook_for_undo(enum translog_record_type type,
|
|||
|
||||
NOTE that after first public Maria release, these can NOT be changed
|
||||
*/
|
||||
|
||||
typedef struct st_log_record_type_descriptor LOG_DESC;
|
||||
|
||||
static LOG_DESC log_record_type_descriptor[LOGREC_NUMBER_OF_TYPES];
|
||||
|
||||
static LOG_DESC INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE=
|
||||
{LOGRECTYPE_FIXEDLENGTH, 6, 6, NULL, NULL, NULL, 0};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE=
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 9, NULL, NULL, NULL, 0};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_FIXED_RECORD_1LSN_EXAMPLE=
|
||||
{LOGRECTYPE_PSEUDOFIXEDLENGTH, 7, 7, NULL, NULL, NULL, 1};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE=
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 12, NULL, NULL, NULL, 1};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_FIXED_RECORD_2LSN_EXAMPLE=
|
||||
{LOGRECTYPE_PSEUDOFIXEDLENGTH, 23, 23, NULL, NULL, NULL, 2};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE=
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 19, NULL, NULL, NULL, 2};
|
||||
|
||||
|
||||
void example_loghandler_init()
|
||||
{
|
||||
log_record_type_descriptor[LOGREC_FIXED_RECORD_0LSN_EXAMPLE]=
|
||||
INIT_LOGREC_FIXED_RECORD_0LSN_EXAMPLE;
|
||||
log_record_type_descriptor[LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE]=
|
||||
INIT_LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE;
|
||||
log_record_type_descriptor[LOGREC_FIXED_RECORD_1LSN_EXAMPLE]=
|
||||
INIT_LOGREC_FIXED_RECORD_1LSN_EXAMPLE;
|
||||
log_record_type_descriptor[LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE]=
|
||||
INIT_LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE;
|
||||
log_record_type_descriptor[LOGREC_FIXED_RECORD_2LSN_EXAMPLE]=
|
||||
INIT_LOGREC_FIXED_RECORD_2LSN_EXAMPLE;
|
||||
log_record_type_descriptor[LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE]=
|
||||
INIT_LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE;
|
||||
}
|
||||
|
||||
|
||||
static LOG_DESC INIT_LOGREC_RESERVED_FOR_CHUNKS23=
|
||||
{ LOGRECTYPE_NOT_ALLOWED, 0, 0, NULL, NULL, NULL, 0 };
|
||||
{LOGRECTYPE_NOT_ALLOWED, 0, 0, NULL, NULL, NULL, 0 };
|
||||
|
||||
static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_HEAD=
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0,
|
||||
|
@ -252,8 +291,7 @@ static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_HEAD=
|
|||
write_hook_for_redo, NULL, 0};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_TAIL=
|
||||
/* QQ shouldn't this 9 be 8? */
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 9, NULL, write_hook_for_redo, NULL, 0};
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 8, NULL, NULL, NULL, 0};
|
||||
|
||||
static LOG_DESC INIT_LOGREC_REDO_INSERT_ROW_BLOB=
|
||||
{LOGRECTYPE_VARIABLE_LENGTH, 0, 8, NULL, write_hook_for_redo, NULL, 0};
|
||||
|
@ -366,7 +404,7 @@ static LOG_DESC INIT_LOGREC_LONG_TRANSACTION_ID=
|
|||
{LOGRECTYPE_FIXEDLENGTH, 6, 6, NULL, NULL, NULL, 0};
|
||||
|
||||
|
||||
void loghandler_init()
|
||||
static void loghandler_init()
|
||||
{
|
||||
log_record_type_descriptor[LOGREC_RESERVED_FOR_CHUNKS23]=
|
||||
INIT_LOGREC_RESERVED_FOR_CHUNKS23;
|
||||
|
@ -1388,9 +1426,11 @@ static uint16 translog_get_total_chunk_length(byte *page, uint16 offset)
|
|||
{
|
||||
/* first 2 bits is length - 2 */
|
||||
uint len= ((((uint8) (*ptr)) & TRANSLOG_CLSN_LEN_BITS) >> 6) + 2;
|
||||
if (ptr[0] == 0 && ((uint8) ptr[1]) == 1)
|
||||
len+= LSN_STORE_SIZE; /* case of full LSN storing */
|
||||
ptr+= len;
|
||||
/* subtract economized bytes */
|
||||
length-= (TRANSLOG_CLSN_MAX_LEN - len);
|
||||
length-= (LSN_STORE_SIZE - len);
|
||||
}
|
||||
DBUG_PRINT("info", ("Pseudo-fixed length: %u", length));
|
||||
DBUG_RETURN(length);
|
||||
|
@ -3225,13 +3265,21 @@ static byte *translog_put_LSN_diff(LSN base_lsn, LSN lsn, byte *dst)
|
|||
offset_diff= base_offset - LSN_OFFSET(lsn);
|
||||
if (diff > 0x3f)
|
||||
{
|
||||
/*TODO: error - too long transaction - panic!!! */
|
||||
UNRECOVERABLE_ERROR(("Too big file diff: %lu", (ulong) diff));
|
||||
DBUG_RETURN(NULL);
|
||||
/*
|
||||
It is full LSN after special 1 diff (which is impossible
|
||||
in real life)
|
||||
*/
|
||||
dst-= 2 + LSN_STORE_SIZE;
|
||||
dst[0]= 0;
|
||||
dst[1]= 1;
|
||||
lsn_store(dst + 2, lsn);
|
||||
}
|
||||
else
|
||||
{
|
||||
dst-= 5;
|
||||
*dst= (0xC0 | diff);
|
||||
int4store(dst + 1, offset_diff);
|
||||
}
|
||||
dst-= 5;
|
||||
*dst= (0xC0 | diff);
|
||||
int4store(dst + 1, offset_diff);
|
||||
}
|
||||
DBUG_PRINT("info", ("new dst: 0x%lx", (ulong) dst));
|
||||
DBUG_RETURN(dst);
|
||||
|
@ -3285,6 +3333,17 @@ static byte *translog_get_LSN_from_diff(LSN base_lsn, byte *src, byte *dst)
|
|||
(uint) code, (ulong) first_byte));
|
||||
switch (code) {
|
||||
case 0:
|
||||
if (first_byte == 0 && *((uint8*)src) == 1)
|
||||
{
|
||||
/*
|
||||
It is full LSN after special 1 diff (which is impossible
|
||||
in real life)
|
||||
*/
|
||||
memcpy(dst, src + 1, LSN_STORE_SIZE);
|
||||
DBUG_PRINT("info", ("Special case of full LSN, new src: 0x%lx",
|
||||
(ulong) (src + 1 + LSN_STORE_SIZE)));
|
||||
DBUG_RETURN(src + 1 + LSN_STORE_SIZE);
|
||||
}
|
||||
rec_offset= LSN_OFFSET(base_lsn) - ((first_byte << 8) + *((uint8*)src));
|
||||
break;
|
||||
case 1:
|
||||
|
@ -3316,7 +3375,7 @@ static byte *translog_get_LSN_from_diff(LSN base_lsn, byte *src, byte *dst)
|
|||
lsn= MAKE_LSN(file_no, rec_offset);
|
||||
src+= code + 1;
|
||||
lsn_store(dst, lsn);
|
||||
DBUG_PRINT("info", ("new src: 0x%lx", (ulong) dst));
|
||||
DBUG_PRINT("info", ("new src: 0x%lx", (ulong) src));
|
||||
DBUG_RETURN(src);
|
||||
}
|
||||
|
||||
|
@ -3342,59 +3401,77 @@ static my_bool translog_relative_LSN_encode(struct st_translog_parts *parts,
|
|||
{
|
||||
LEX_STRING *part;
|
||||
uint lsns_len= lsns * LSN_STORE_SIZE;
|
||||
char buffer_src[MAX_NUMBER_OF_LSNS_PER_RECORD * LSN_STORE_SIZE];
|
||||
char *buffer= buffer_src;
|
||||
|
||||
DBUG_ENTER("translog_relative_LSN_encode");
|
||||
|
||||
DBUG_ASSERT(parts->current != 0);
|
||||
part= parts->parts + parts->current;
|
||||
|
||||
/* collect all LSN(s) in one chunk if it (they) is (are) divided */
|
||||
if (part->length < lsns_len)
|
||||
{
|
||||
uint copied= part->length;
|
||||
LEX_STRING *next_part;
|
||||
DBUG_PRINT("info", ("Using buffer: 0x%lx", (ulong) compressed_LSNs));
|
||||
memcpy(compressed_LSNs, (byte*)part->str, part->length);
|
||||
memcpy(buffer, (byte*)part->str, part->length);
|
||||
next_part= parts->parts + parts->current + 1;
|
||||
do
|
||||
{
|
||||
DBUG_ASSERT(next_part < parts->parts + parts->elements);
|
||||
if ((next_part->length + copied) < lsns_len)
|
||||
{
|
||||
memcpy(compressed_LSNs + copied, (byte*)next_part->str,
|
||||
memcpy(buffer + copied, (byte*)next_part->str,
|
||||
next_part->length);
|
||||
copied+= next_part->length;
|
||||
next_part->length= 0; next_part->str= 0;
|
||||
/* delete_dynamic_element(&parts->parts, parts->current + 1); */
|
||||
next_part++;
|
||||
parts->current++;
|
||||
part= parts->parts + parts->current;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint len= lsns_len - copied;
|
||||
memcpy(compressed_LSNs + copied, (byte*)next_part->str, len);
|
||||
memcpy(buffer + copied, (byte*)next_part->str, len);
|
||||
copied= lsns_len;
|
||||
next_part->str+= len;
|
||||
next_part->length-= len;
|
||||
}
|
||||
} while (copied < lsns_len);
|
||||
part->length= lsns_len;
|
||||
part->str= (char*)compressed_LSNs;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer= part->str;
|
||||
part->str+= lsns_len;
|
||||
part->length-= lsns_len;
|
||||
parts->current--;
|
||||
part= parts->parts + parts->current;
|
||||
}
|
||||
|
||||
{
|
||||
/* Compress */
|
||||
LSN ref;
|
||||
uint economy;
|
||||
byte *ref_ptr= (byte*)part->str + lsns_len - LSN_STORE_SIZE;
|
||||
byte *dst_ptr= (byte*)part->str + lsns_len;
|
||||
for (; ref_ptr >= (byte*)part->str ; ref_ptr-= LSN_STORE_SIZE)
|
||||
int economy;
|
||||
byte *src_ptr;
|
||||
byte *dst_ptr= compressed_LSNs + (MAX_NUMBER_OF_LSNS_PER_RECORD *
|
||||
COMPRESSED_LSN_MAX_STORE_SIZE);
|
||||
for (src_ptr= buffer + lsns_len - LSN_STORE_SIZE;
|
||||
src_ptr >= buffer;
|
||||
src_ptr-= LSN_STORE_SIZE)
|
||||
{
|
||||
ref= lsn_korr(ref_ptr);
|
||||
ref= lsn_korr(src_ptr);
|
||||
if ((dst_ptr= translog_put_LSN_diff(base_lsn, ref, dst_ptr)) == NULL)
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
/* Note that dst_ptr did grow downward ! */
|
||||
economy= (uint) (dst_ptr - (byte*)part->str);
|
||||
DBUG_PRINT("info", ("Economy: %u", economy));
|
||||
part->length-= economy;
|
||||
parts->record_length-= economy;
|
||||
part->length= (uint)((compressed_LSNs +
|
||||
(MAX_NUMBER_OF_LSNS_PER_RECORD *
|
||||
COMPRESSED_LSN_MAX_STORE_SIZE)) -
|
||||
dst_ptr);
|
||||
parts->record_length-= (economy= lsns_len - part->length);
|
||||
DBUG_PRINT("info", ("new length of LSNs: %u economy: %d",
|
||||
part->length, economy));
|
||||
parts->total_record_length-= economy;
|
||||
part->str= (char*)dst_ptr;
|
||||
}
|
||||
|
@ -3863,7 +3940,8 @@ static my_bool translog_write_variable_record(LSN *lsn,
|
|||
ulong buffer_rest;
|
||||
uint page_rest;
|
||||
/* Max number of such LSNs per record is 2 */
|
||||
byte compressed_LSNs[2 * LSN_STORE_SIZE];
|
||||
byte compressed_LSNs[MAX_NUMBER_OF_LSNS_PER_RECORD *
|
||||
COMPRESSED_LSN_MAX_STORE_SIZE];
|
||||
DBUG_ENTER("translog_write_variable_record");
|
||||
|
||||
translog_lock();
|
||||
|
@ -3976,7 +4054,8 @@ static my_bool translog_write_fixed_record(LSN *lsn,
|
|||
struct st_translog_buffer *buffer_to_flush= NULL;
|
||||
byte chunk1_header[1 + 2];
|
||||
/* Max number of such LSNs per record is 2 */
|
||||
byte compressed_LSNs[2 * LSN_STORE_SIZE];
|
||||
byte compressed_LSNs[MAX_NUMBER_OF_LSNS_PER_RECORD *
|
||||
COMPRESSED_LSN_MAX_STORE_SIZE];
|
||||
LEX_STRING *part;
|
||||
int rc;
|
||||
DBUG_ENTER("translog_write_fixed_record");
|
||||
|
@ -3986,8 +4065,7 @@ static my_bool translog_write_fixed_record(LSN *lsn,
|
|||
log_record_type_descriptor[type].fixed_length) ||
|
||||
(log_record_type_descriptor[type].class ==
|
||||
LOGRECTYPE_PSEUDOFIXEDLENGTH &&
|
||||
(parts->record_length -
|
||||
log_record_type_descriptor[type].compressed_LSN * 2) <=
|
||||
parts->record_length ==
|
||||
log_record_type_descriptor[type].fixed_length));
|
||||
|
||||
translog_lock();
|
||||
|
@ -3999,19 +4077,18 @@ static my_bool translog_write_fixed_record(LSN *lsn,
|
|||
DBUG_PRINT("info",
|
||||
("Page size: %u record: %u next cond: %d",
|
||||
log_descriptor.bc.current_page_fill,
|
||||
(parts->record_length -
|
||||
(parts->record_length +
|
||||
log_record_type_descriptor[type].compressed_LSN * 2 + 3),
|
||||
((((uint) log_descriptor.bc.current_page_fill) +
|
||||
(parts->record_length -
|
||||
(parts->record_length +
|
||||
log_record_type_descriptor[type].compressed_LSN * 2 + 3)) >
|
||||
TRANSLOG_PAGE_SIZE)));
|
||||
/*
|
||||
check that there is enough place on current page:
|
||||
(log_record_type_descriptor[type].fixed_length - economized on compressed
|
||||
LSNs) bytes
|
||||
check that there is enough place on current page.
|
||||
NOTE: compressing may increase page LSN size on two bytes for every LSN
|
||||
*/
|
||||
if ((((uint) log_descriptor.bc.current_page_fill) +
|
||||
(parts->record_length -
|
||||
(parts->record_length +
|
||||
log_record_type_descriptor[type].compressed_LSN * 2 + 3)) >
|
||||
TRANSLOG_PAGE_SIZE)
|
||||
{
|
||||
|
@ -4133,7 +4210,7 @@ my_bool translog_write_record(LSN *lsn,
|
|||
parts.current= TRANSLOG_INTERNAL_PARTS;
|
||||
|
||||
/* clear TRANSLOG_INTERNAL_PARTS */
|
||||
DBUG_ASSERT(TRANSLOG_INTERNAL_PARTS == 1);
|
||||
DBUG_ASSERT(TRANSLOG_INTERNAL_PARTS != 0);
|
||||
parts_data[0].str= 0;
|
||||
parts_data[0].length= 0;
|
||||
|
||||
|
@ -4253,7 +4330,7 @@ translog_size_t translog_fixed_length_header(byte *page,
|
|||
byte *dst= buff->header;
|
||||
byte *start= src;
|
||||
uint lsns= desc->compressed_LSN;
|
||||
uint length= desc->fixed_length + (lsns * 2);
|
||||
uint length= desc->fixed_length;
|
||||
|
||||
DBUG_ENTER("translog_fixed_length_header");
|
||||
|
||||
|
@ -4266,7 +4343,7 @@ translog_size_t translog_fixed_length_header(byte *page,
|
|||
lsns*= LSN_STORE_SIZE;
|
||||
dst+= lsns;
|
||||
length-= lsns;
|
||||
buff->compressed_LSN_economy= (uint16) (lsns - (src - start));
|
||||
buff->compressed_LSN_economy= (lsns - (src - start));
|
||||
}
|
||||
else
|
||||
buff->compressed_LSN_economy= 0;
|
||||
|
@ -4585,7 +4662,7 @@ translog_size_t translog_variable_length_header(byte *page,
|
|||
LSN base_lsn;
|
||||
uint lsns= desc->compressed_LSN;
|
||||
uint16 chunk_len;
|
||||
uint16 length= desc->read_header_len + (lsns * 2);
|
||||
uint16 length= desc->read_header_len;
|
||||
uint16 buffer_length= length;
|
||||
uint16 body_len;
|
||||
TRANSLOG_SCANNER_DATA internal_scanner;
|
||||
|
@ -4707,10 +4784,10 @@ translog_size_t translog_variable_length_header(byte *page,
|
|||
dst+= lsns;
|
||||
length-= lsns;
|
||||
buff->record_length+= (buff->compressed_LSN_economy=
|
||||
(uint16) (lsns - (src - start)));
|
||||
DBUG_PRINT("info", ("lsns: %u length: %u economy: %u new length: %lu",
|
||||
(lsns - (src - start)));
|
||||
DBUG_PRINT("info", ("lsns: %u length: %u economy: %d new length: %lu",
|
||||
lsns / LSN_STORE_SIZE, (uint) length,
|
||||
(uint) buff->compressed_LSN_economy,
|
||||
(int) buff->compressed_LSN_economy,
|
||||
(ulong) buff->record_length));
|
||||
body_len-= (src - start);
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ struct st_maria_share;
|
|||
#define LOG_INTERNAL_PARTS 1
|
||||
|
||||
/* position reserved in an array of parts of a log record */
|
||||
#define TRANSLOG_INTERNAL_PARTS 1
|
||||
#define TRANSLOG_INTERNAL_PARTS 2
|
||||
|
||||
/* types of records in the transaction log */
|
||||
/* Todo: Set numbers for these when we have all entries figured out */
|
||||
|
@ -140,7 +140,7 @@ typedef struct st_translog_header_buffer
|
|||
/*
|
||||
Real compressed LSN(s) size economy (<number of LSN(s)>*7 - <real_size>)
|
||||
*/
|
||||
uint16 compressed_LSN_economy;
|
||||
int16 compressed_LSN_economy;
|
||||
/* short transaction ID or 0 if it has no sense for the record */
|
||||
uint16 non_header_data_start_offset;
|
||||
/* non read body data length in this first chunk */
|
||||
|
@ -185,7 +185,16 @@ struct st_transaction;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void loghandler_init();
|
||||
/* Records types for unittests */
|
||||
#define LOGREC_FIXED_RECORD_0LSN_EXAMPLE 1
|
||||
#define LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE 2
|
||||
#define LOGREC_FIXED_RECORD_1LSN_EXAMPLE 3
|
||||
#define LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE 4
|
||||
#define LOGREC_FIXED_RECORD_2LSN_EXAMPLE 5
|
||||
#define LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE 6
|
||||
|
||||
extern void example_loghandler_init();
|
||||
|
||||
extern my_bool translog_init(const char *directory, uint32 log_file_max_size,
|
||||
uint32 server_version, uint32 server_id,
|
||||
PAGECACHE *pagecache, uint flags);
|
||||
|
|
|
@ -41,12 +41,15 @@ noinst_PROGRAMS = ma_control_file-t trnman-t lockman2-t \
|
|||
ma_test_loghandler-t \
|
||||
ma_test_loghandler_multigroup-t \
|
||||
ma_test_loghandler_multithread-t \
|
||||
ma_test_loghandler_pagecache-t
|
||||
ma_test_loghandler_pagecache-t \
|
||||
ma_test_loghandler_long-t-big
|
||||
|
||||
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
|
||||
ma_test_loghandler_multithread_t_SOURCES= ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c
|
||||
ma_test_loghandler_pagecache_t_SOURCES= ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c
|
||||
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
|
||||
ma_test_loghandler_multithread_t_SOURCES = ma_test_loghandler_multithread-t.c ma_maria_log_cleanup.c
|
||||
ma_test_loghandler_pagecache_t_SOURCES = ma_test_loghandler_pagecache-t.c ma_maria_log_cleanup.c
|
||||
ma_test_loghandler_long_t_big_SOURCES = ma_test_loghandler-t.c ma_maria_log_cleanup.c
|
||||
ma_test_loghandler_long_t_big_CPPFLAGS = -DLONG_LOG_TEST
|
||||
|
||||
ma_pagecache_single_src = ma_pagecache_single.c test_file.c
|
||||
ma_pagecache_consist_src = ma_pagecache_consist.c test_file.c
|
||||
|
|
|
@ -15,10 +15,15 @@ static TRN *trn= &dummy_transaction_object;
|
|||
|
||||
#define LONG_BUFFER_SIZE (100 * 1024)
|
||||
|
||||
|
||||
#ifdef LONG_LOG_TEST
|
||||
#define LOG_FLAGS 0
|
||||
#define LOG_FILE_SIZE (1024L*1024L)
|
||||
#define ITERATIONS (1600*4)
|
||||
#else
|
||||
#define LOG_FLAGS TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC
|
||||
#define LOG_FILE_SIZE 1024L*1024L*3L
|
||||
#define LOG_FILE_SIZE (1024L*1024L*3L)
|
||||
#define ITERATIONS 1600
|
||||
#endif
|
||||
|
||||
/*
|
||||
#define LOG_FLAGS 0
|
||||
|
@ -70,6 +75,23 @@ static my_bool check_content(byte *ptr, ulong length)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
Report OK for read operation
|
||||
|
||||
SYNOPSIS
|
||||
read_ok()
|
||||
rec the record header
|
||||
*/
|
||||
|
||||
void read_ok(TRANSLOG_HEADER_BUFFER *rec)
|
||||
{
|
||||
char buff[80];
|
||||
snprintf(buff, sizeof(buff), "read record type: %u LSN: (%lu,0x%lx)",
|
||||
rec->type, (ulong) LSN_FILE_NO(rec->lsn),
|
||||
(ulong) LSN_OFFSET(rec->lsn));
|
||||
ok(1, buff);
|
||||
}
|
||||
|
||||
/*
|
||||
Read whole record content, and check content (put with offset)
|
||||
|
||||
|
@ -94,6 +116,7 @@ static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
|
|||
return check_content(buffer + skip, rec->record_length - skip);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc __attribute__((unused)), char *argv[])
|
||||
{
|
||||
uint32 i;
|
||||
|
@ -158,6 +181,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
|
||||
plan(((ITERATIONS - 1) * 4 + 1)*2 + ITERATIONS - 1);
|
||||
|
||||
|
@ -170,16 +194,16 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
trn->short_id= 0;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL,
|
||||
6, TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
lsn_base= first_lsn= lsn;
|
||||
|
||||
for (i= 1; i < ITERATIONS; i++)
|
||||
|
@ -193,16 +217,17 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
/* check auto-count feature */
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 1].str= NULL;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= 0;
|
||||
if (translog_write_record(&lsn, LOGREC_CLR_END, trn,
|
||||
if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_1LSN_EXAMPLE,
|
||||
trn, NULL,
|
||||
NULL, LSN_STORE_SIZE, 0, parts))
|
||||
{
|
||||
fprintf(stderr, "1 Can't write reference defore record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_CLR_END");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_1LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_CLR_END");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_1LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 12)
|
||||
rec_len= 12;
|
||||
|
@ -212,17 +237,17 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
|
||||
/* check record length auto-counting */
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_KEY_INSERT,
|
||||
LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
|
||||
trn, NULL, 0, TRANSLOG_INTERNAL_PARTS + 2,
|
||||
parts))
|
||||
{
|
||||
fprintf(stderr, "1 Can't write var reference defore record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_KEY_INSERT");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_KEY_INSERT");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -231,17 +256,17 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 23;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_ROW_DELETE,
|
||||
LOGREC_FIXED_RECORD_2LSN_EXAMPLE,
|
||||
trn, NULL,
|
||||
23, TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
{
|
||||
fprintf(stderr, "0 Can't write reference defore record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_ROW_DELETE");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_2LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_ROW_DELETE");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_2LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
lsn_store(lsn_buff + LSN_STORE_SIZE, first_lsn);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 19)
|
||||
|
@ -251,33 +276,33 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 1].str= (char*)long_buffer;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_KEY_DELETE,
|
||||
LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE,
|
||||
trn, NULL, 14 + rec_len,
|
||||
TRANSLOG_INTERNAL_PARTS + 2, parts))
|
||||
{
|
||||
fprintf(stderr, "0 Can't write var reference defore record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_KEY_DELETE");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_KEY_DELETE");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE");
|
||||
}
|
||||
int4store(long_tr_id, i);
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL, 6,
|
||||
TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write record #%lu\n", (ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
|
||||
lsn_base= lsn;
|
||||
|
||||
|
@ -286,17 +311,17 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_buffer;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_REDO_INSERT_ROW_HEAD,
|
||||
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL, rec_len,
|
||||
TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_REDO_INSERT_ROW_HEAD");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_REDO_INSERT_ROW_HEAD");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE");
|
||||
if (translog_flush(lsn))
|
||||
{
|
||||
fprintf(stderr, "Can't flush #%lu\n", (ulong) i);
|
||||
|
@ -329,6 +354,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
srandom(122334817L);
|
||||
|
||||
|
||||
|
@ -341,12 +367,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
|
||||
goto err;
|
||||
}
|
||||
if (rec.type !=LOGREC_LONG_TRANSACTION_ID || rec.short_trid != 0 ||
|
||||
if (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE || rec.short_trid != 0 ||
|
||||
rec.record_length != 6 || uint4korr(rec.header) != 0 ||
|
||||
((uchar)rec.header[4]) != 0 || ((uchar)rec.header[5]) != 0xFF ||
|
||||
first_lsn != rec.lsn)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_LONG_TRANSACTION_ID data read(0)\n"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
||||
"data read(0)\n"
|
||||
"type %u, strid %u, len %u, i: %u, 4: %u 5: %u, "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
(uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length,
|
||||
|
@ -355,7 +382,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
goto err;
|
||||
}
|
||||
ok(1, "read record");
|
||||
read_ok(&rec);
|
||||
translog_free_record_header(&rec);
|
||||
lsn= first_lsn;
|
||||
if (translog_init_scanner(first_lsn, 1, &scanner))
|
||||
|
@ -386,10 +413,12 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
{
|
||||
LSN ref;
|
||||
ref= lsn_korr(rec.header);
|
||||
if (rec.type !=LOGREC_CLR_END || rec.short_trid != (i % 0xFFFF) ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_1LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != 7 || ref != lsn)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_CLR_END data read(%d) "
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_1LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type: %u strid: %u len: %u"
|
||||
"ref: (%lu,0x%lx) (%lu,0x%lx) "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
|
@ -406,7 +435,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
LSN ref1, ref2;
|
||||
ref1= lsn_korr(rec.header);
|
||||
ref2= lsn_korr(rec.header + LSN_STORE_SIZE);
|
||||
if (rec.type != LOGREC_UNDO_ROW_DELETE ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_2LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != 23 ||
|
||||
ref1 != lsn ||
|
||||
|
@ -421,7 +450,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
((uchar)rec.header[15]) != 0xAA ||
|
||||
((uchar)rec.header[14]) != 0x55)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_ROW_DELETE data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_2LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type %u, strid %u, len %u, ref1(%lu,0x%lx), "
|
||||
"ref2(%lu,0x%lx) %x%x%x%x%x%x%x%x%x "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
|
@ -438,7 +468,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
goto err;
|
||||
}
|
||||
}
|
||||
ok(1, "read record");
|
||||
read_ok(&rec);
|
||||
translog_free_record_header(&rec);
|
||||
|
||||
len= translog_read_next_record_header(&scanner, &rec);
|
||||
|
@ -460,18 +490,19 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
ref= lsn_korr(rec.header);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 12)
|
||||
rec_len= 12;
|
||||
if (rec.type !=LOGREC_UNDO_KEY_INSERT ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len + LSN_STORE_SIZE ||
|
||||
len != 12 || ref != lsn ||
|
||||
check_content(rec.header + LSN_STORE_SIZE, len - LSN_STORE_SIZE))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_KEY_INSERT data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
|
||||
"data read(%d)"
|
||||
"type %u (%d), strid %u (%d), len %lu, %lu + 7 (%d), "
|
||||
"hdr len: %u (%d), "
|
||||
"ref(%lu,0x%lx), lsn(%lu,0x%lx) (%d), content: %d\n",
|
||||
i, (uint) rec.type,
|
||||
rec.type !=LOGREC_UNDO_KEY_INSERT,
|
||||
rec.type != LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
|
||||
(uint) rec.short_trid,
|
||||
rec.short_trid != (i % 0xFFFF),
|
||||
(ulong) rec.record_length, (ulong) rec_len,
|
||||
|
@ -488,8 +519,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_INSERT in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
goto err;
|
||||
}
|
||||
|
@ -501,7 +532,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
ref2= lsn_korr(rec.header + LSN_STORE_SIZE);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 19)
|
||||
rec_len= 19;
|
||||
if (rec.type !=LOGREC_UNDO_KEY_DELETE ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len + LSN_STORE_SIZE * 2 ||
|
||||
len != 19 ||
|
||||
|
@ -510,7 +541,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
check_content(rec.header + LSN_STORE_SIZE * 2,
|
||||
len - LSN_STORE_SIZE * 2))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_KEY_DELETE data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type %u, strid %u, len %lu != %lu + 14, hdr len: %u, "
|
||||
"ref1(%lu,0x%lx), ref2(%lu,0x%lx), "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
|
@ -525,13 +557,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE * 2))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_DELETE in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ok(1, "read record");
|
||||
read_ok(&rec);
|
||||
translog_free_record_header(&rec);
|
||||
|
||||
len= translog_read_next_record_header(&scanner, &rec);
|
||||
|
@ -547,12 +579,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
"instead of beginning of %u\n", i, ITERATIONS);
|
||||
goto err;
|
||||
}
|
||||
if (rec.type !=LOGREC_LONG_TRANSACTION_ID ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_0LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != 6 || uint4korr(rec.header) != i ||
|
||||
((uchar)rec.header[4]) != 0 || ((uchar)rec.header[5]) != 0xFF)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_LONG_TRANSACTION_ID data read(%d)\n"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d)\n"
|
||||
"type %u, strid %u, len %u, i: %u, 4: %u 5: %u "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
i, (uint) rec.type, (uint) rec.short_trid,
|
||||
|
@ -563,18 +596,19 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
goto err;
|
||||
}
|
||||
lsn= rec.lsn;
|
||||
ok(1, "read record");
|
||||
read_ok(&rec);
|
||||
translog_free_record_header(&rec);
|
||||
|
||||
len= translog_read_next_record_header(&scanner, &rec);
|
||||
if ((rec_len= random() / (RAND_MAX / (LONG_BUFFER_SIZE + 1))) < 9)
|
||||
rec_len= 9;
|
||||
if (rec.type !=LOGREC_REDO_INSERT_ROW_HEAD ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len ||
|
||||
len != 9 || check_content(rec.header, len))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_REDO_INSERT_ROW_HEAD data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type %u, strid %u, len %lu != %lu, hdr len: %u, "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
i, (uint) rec.type, (uint) rec.short_trid,
|
||||
|
@ -586,12 +620,12 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, 0))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_DELETE in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
goto err;
|
||||
}
|
||||
ok(1, "read record");
|
||||
read_ok(&rec);
|
||||
translog_free_record_header(&rec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,6 +178,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
|
||||
plan(((ITERATIONS - 1) * 4 + 1) * 2);
|
||||
|
||||
|
@ -189,15 +190,16 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
trn->short_id= 0;
|
||||
if (translog_write_record(&lsn, LOGREC_LONG_TRANSACTION_ID, trn, NULL,
|
||||
if (translog_write_record(&lsn, LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL, NULL,
|
||||
6, TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
lsn_base= first_lsn= lsn;
|
||||
|
||||
for (i= 1; i < ITERATIONS; i++)
|
||||
|
@ -209,7 +211,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= LSN_STORE_SIZE;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_CLR_END,
|
||||
LOGREC_FIXED_RECORD_1LSN_EXAMPLE,
|
||||
trn, NULL,
|
||||
LSN_STORE_SIZE,
|
||||
TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
|
@ -217,10 +219,10 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
fprintf(stderr, "1 Can't write reference before record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_CLR_END");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_1LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_CLR_END");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_1LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
rec_len= get_len();
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)lsn_buff;
|
||||
|
@ -229,7 +231,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_KEY_INSERT,
|
||||
LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
|
||||
trn, NULL, LSN_STORE_SIZE + rec_len,
|
||||
TRANSLOG_INTERNAL_PARTS + 2,
|
||||
parts))
|
||||
|
@ -237,10 +239,10 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
fprintf(stderr, "1 Can't write var reference before record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_KEY_INSERT");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_KEY_INSERT");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -250,7 +252,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= 23;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_ROW_DELETE,
|
||||
LOGREC_FIXED_RECORD_2LSN_EXAMPLE,
|
||||
trn, NULL, 23,
|
||||
TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
|
@ -258,10 +260,10 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
fprintf(stderr, "0 Can't write reference before record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_ROW_DELETE");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_2LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_ROW_DELETE");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_2LSN_EXAMPLE");
|
||||
lsn_store(lsn_buff, lsn_base);
|
||||
lsn_store(lsn_buff + LSN_STORE_SIZE, first_lsn);
|
||||
rec_len= get_len();
|
||||
|
@ -271,7 +273,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 1].length= rec_len;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_UNDO_KEY_DELETE,
|
||||
LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE,
|
||||
trn, NULL, LSN_STORE_SIZE * 2 + rec_len,
|
||||
TRANSLOG_INTERNAL_PARTS + 2,
|
||||
parts))
|
||||
|
@ -279,26 +281,26 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
fprintf(stderr, "0 Can't write var reference before record #%lu\n",
|
||||
(ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_UNDO_KEY_DELETE");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_UNDO_KEY_DELETE");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE");
|
||||
}
|
||||
int4store(long_tr_id, i);
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL, 6,
|
||||
TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write record #%lu\n", (ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(0, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_LONG_TRANSACTION_ID");
|
||||
ok(1, "write LOGREC_FIXED_RECORD_0LSN_EXAMPLE");
|
||||
|
||||
lsn_base= lsn;
|
||||
|
||||
|
@ -307,16 +309,16 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= rec_len;
|
||||
trn->short_id= i % 0xFFFF;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_REDO_INSERT_ROW_HEAD,
|
||||
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
|
||||
trn, NULL, rec_len,
|
||||
TRANSLOG_INTERNAL_PARTS + 1, parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
|
||||
translog_destroy();
|
||||
ok(0, "write LOGREC_REDO_INSERT_ROW_HEAD");
|
||||
ok(0, "write LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE");
|
||||
exit(1);
|
||||
}
|
||||
ok(1, "write LOGREC_REDO_INSERT_ROW_HEAD");
|
||||
ok(1, "write LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE");
|
||||
}
|
||||
|
||||
translog_destroy();
|
||||
|
@ -340,6 +342,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
|
||||
srandom(122334817L);
|
||||
|
||||
|
@ -353,12 +356,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_free_record_header(&rec);
|
||||
goto err;
|
||||
}
|
||||
if (rec.type !=LOGREC_LONG_TRANSACTION_ID || rec.short_trid != 0 ||
|
||||
if (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE || rec.short_trid != 0 ||
|
||||
rec.record_length != 6 || uint4korr(rec.header) != 0 ||
|
||||
((uchar)rec.header[4]) != 0 || ((uchar)rec.header[5]) != 0xFF ||
|
||||
first_lsn != rec.lsn)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_LONG_TRANSACTION_ID data read(0)\n"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
||||
"data read(0)\n"
|
||||
"type %u, strid %u, len %u, i: %u, 4: %u 5: %u, "
|
||||
"lsn(0x%lu,0x%lx)\n",
|
||||
(uint) rec.type, (uint) rec.short_trid, (uint) rec.record_length,
|
||||
|
@ -402,10 +406,12 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
{
|
||||
LSN ref;
|
||||
ref= lsn_korr(rec.header);
|
||||
if (rec.type != LOGREC_CLR_END || rec.short_trid != (i % 0xFFFF) ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_1LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != LSN_STORE_SIZE || ref != lsn)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_CLR_END data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_1LSN_EXAMPLE "
|
||||
"data read(%d)"
|
||||
"type %u, strid %u, len %u, ref(%lu,0x%lx), lsn(%lu,0x%lx)\n",
|
||||
i, (uint) rec.type, (uint) rec.short_trid,
|
||||
(uint) rec.record_length,
|
||||
|
@ -420,7 +426,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
LSN ref1, ref2;
|
||||
ref1= lsn_korr(rec.header);
|
||||
ref2= lsn_korr(rec.header + LSN_STORE_SIZE);
|
||||
if (rec.type !=LOGREC_UNDO_ROW_DELETE ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_2LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != 23 ||
|
||||
ref1 != lsn ||
|
||||
|
@ -435,7 +441,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
((uchar)rec.header[15]) != 0xAA ||
|
||||
((uchar)rec.header[14]) != 0x55)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_ROW_DELETE data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_2LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type %u, strid %u, len %u, ref1(%lu,0x%lx), "
|
||||
"ref2(%lu,0x%lx) %x%x%x%x%x%x%x%x%x "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
|
@ -474,18 +481,19 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
LSN ref;
|
||||
ref= lsn_korr(rec.header);
|
||||
rec_len= get_len();
|
||||
if (rec.type !=LOGREC_UNDO_KEY_INSERT ||
|
||||
if (rec.type !=LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len + LSN_STORE_SIZE ||
|
||||
len != 12 || ref != lsn ||
|
||||
check_content(rec.header + LSN_STORE_SIZE, len - LSN_STORE_SIZE))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_KEY_INSERT data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
|
||||
"data read(%d)"
|
||||
"type %u (%d), strid %u (%d), len %lu, %lu + 7 (%d), "
|
||||
"hdr len: %u (%d), "
|
||||
"ref(%lu,0x%lx), lsn(%lu,0x%lx) (%d), content: %d\n",
|
||||
i, (uint) rec.type,
|
||||
rec.type !=LOGREC_UNDO_KEY_INSERT,
|
||||
rec.type !=LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE,
|
||||
(uint) rec.short_trid,
|
||||
rec.short_trid != (i % 0xFFFF),
|
||||
(ulong) rec.record_length, (ulong) rec_len,
|
||||
|
@ -503,8 +511,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_INSERT in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_1LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
translog_free_record_header(&rec);
|
||||
goto err;
|
||||
|
@ -516,7 +524,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
ref1= lsn_korr(rec.header);
|
||||
ref2= lsn_korr(rec.header + LSN_STORE_SIZE);
|
||||
rec_len= get_len();
|
||||
if (rec.type !=LOGREC_UNDO_KEY_DELETE ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len + LSN_STORE_SIZE * 2 ||
|
||||
len != 19 ||
|
||||
|
@ -525,7 +533,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
check_content(rec.header + LSN_STORE_SIZE * 2,
|
||||
len - LSN_STORE_SIZE * 2))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_UNDO_KEY_DELETE data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
" data read(%d) "
|
||||
"type %u, strid %u, len %lu != %lu + 14, hdr len: %u, "
|
||||
"ref1(%lu,0x%lx), ref2(%lu,0x%lx), "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
|
@ -541,8 +550,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, LSN_STORE_SIZE * 2))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_DELETE in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
translog_free_record_header(&rec);
|
||||
goto err;
|
||||
|
@ -566,12 +575,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_free_record_header(&rec);
|
||||
goto err;
|
||||
}
|
||||
if (rec.type !=LOGREC_LONG_TRANSACTION_ID ||
|
||||
if (rec.type != LOGREC_FIXED_RECORD_0LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != 6 || uint4korr(rec.header) != i ||
|
||||
((uchar)rec.header[4]) != 0 || ((uchar)rec.header[5]) != 0xFF)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_LONG_TRANSACTION_ID data read(%d)\n"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d)\n"
|
||||
"type %u, strid %u, len %u, i: %u, 4: %u 5: %u "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
i, (uint) rec.type, (uint) rec.short_trid,
|
||||
|
@ -589,12 +599,13 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
|
||||
len= translog_read_next_record_header(&scanner, &rec);
|
||||
rec_len= get_len();
|
||||
if (rec.type !=LOGREC_REDO_INSERT_ROW_HEAD ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
|
||||
rec.short_trid != (i % 0xFFFF) ||
|
||||
rec.record_length != rec_len ||
|
||||
len != 9 || check_content(rec.header, len))
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_REDO_INSERT_ROW_HEAD data read(%d)"
|
||||
fprintf(stderr, "Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"type %u, strid %u, len %lu != %lu, hdr len: %u, "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
i, (uint) rec.type, (uint) rec.short_trid,
|
||||
|
@ -607,8 +618,8 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
if (read_and_check_content(&rec, long_buffer, 0))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_UNDO_KEY_DELETE in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_2LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn), (ulong) LSN_OFFSET(rec.lsn));
|
||||
translog_free_record_header(&rec);
|
||||
goto err;
|
||||
|
|
|
@ -135,11 +135,11 @@ void writer(int num)
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
&trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
{
|
||||
fprintf(stderr, "Can't write LOGREC_LONG_TRANSACTION_ID record #%lu "
|
||||
fprintf(stderr, "Can't write LOGREC_FIXED_RECORD_0LSN_EXAMPLE record #%lu "
|
||||
"thread %i\n", (ulong) i, num);
|
||||
translog_destroy();
|
||||
pthread_mutex_lock(&LOCK_thread_count);
|
||||
|
@ -151,7 +151,7 @@ void writer(int num)
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_buffer;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= len;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_REDO_INSERT_ROW_HEAD,
|
||||
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
|
||||
&trn, NULL,
|
||||
len, TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
|
@ -287,6 +287,7 @@ int main(int argc __attribute__((unused)),
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
|
||||
srandom(122334817L);
|
||||
{
|
||||
|
@ -299,7 +300,7 @@ int main(int argc __attribute__((unused)),
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
if (translog_write_record(&first_lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
&dummy_transaction_object, NULL, 6,
|
||||
TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
|
@ -398,13 +399,14 @@ int main(int argc __attribute__((unused)),
|
|||
stage= indeces[rec.short_trid] % 2;
|
||||
if (stage == 0)
|
||||
{
|
||||
if (rec.type !=LOGREC_LONG_TRANSACTION_ID ||
|
||||
if (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE ||
|
||||
rec.record_length != 6 ||
|
||||
uint2korr(rec.header) != rec.short_trid ||
|
||||
index != uint4korr(rec.header + 2) ||
|
||||
cmp_translog_addr(lsns1[rec.short_trid][index], rec.lsn) != 0)
|
||||
{
|
||||
fprintf(stderr, "Incorrect LOGREC_LONG_TRANSACTION_ID data read(%d)\n"
|
||||
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d)\n"
|
||||
"type %u, strid %u %u, len %u, i: %u %u, "
|
||||
"lsn(%lu,0x%lx) (%lu,0x%lx)\n",
|
||||
i, (uint) rec.type,
|
||||
|
@ -421,19 +423,21 @@ int main(int argc __attribute__((unused)),
|
|||
}
|
||||
else
|
||||
{
|
||||
if (rec.type !=LOGREC_REDO_INSERT_ROW_HEAD ||
|
||||
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
|
||||
len != 9 ||
|
||||
rec.record_length != lens[rec.short_trid][index] ||
|
||||
cmp_translog_addr(lsns2[rec.short_trid][index], rec.lsn) != 0 ||
|
||||
check_content(rec.header, len))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_REDO_INSERT_ROW_HEAD data read(%d) "
|
||||
" thread: %d, iteration %d, stage %d\n"
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
||||
"data read(%d) "
|
||||
"thread: %d, iteration %d, stage %d\n"
|
||||
"type %u (%d), len %u, length %lu %lu (%d) "
|
||||
"lsn(%lu,0x%lx) (%lu,0x%lx)\n",
|
||||
i, (uint) rec.short_trid, index, stage,
|
||||
(uint) rec.type, (rec.type !=LOGREC_REDO_INSERT_ROW_HEAD),
|
||||
(uint) rec.type, (rec.type !=
|
||||
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE),
|
||||
(uint) len,
|
||||
(ulong) rec.record_length, lens[rec.short_trid][index],
|
||||
(rec.record_length != lens[rec.short_trid][index]),
|
||||
|
@ -447,8 +451,8 @@ int main(int argc __attribute__((unused)),
|
|||
if (read_and_check_content(&rec, long_buffer, 0))
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Incorrect LOGREC_REDO_INSERT_ROW_HEAD in whole rec read "
|
||||
"lsn(%lu,0x%lx)\n",
|
||||
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
||||
"in whole rec read lsn(%lu,0x%lx)\n",
|
||||
(ulong) LSN_FILE_NO(rec.lsn),
|
||||
(ulong) LSN_OFFSET(rec.lsn));
|
||||
translog_free_record_header(&rec);
|
||||
|
|
|
@ -73,6 +73,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
translog_destroy();
|
||||
exit(1);
|
||||
}
|
||||
example_loghandler_init();
|
||||
|
||||
if ((stat= my_stat(first_translog_file, &st, MYF(0))) == 0)
|
||||
{
|
||||
|
@ -90,7 +91,7 @@ int main(int argc __attribute__((unused)), char *argv[])
|
|||
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
||||
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
||||
if (translog_write_record(&lsn,
|
||||
LOGREC_LONG_TRANSACTION_ID,
|
||||
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
||||
&dummy_transaction_object, NULL, 6,
|
||||
TRANSLOG_INTERNAL_PARTS + 1,
|
||||
parts))
|
||||
|
|
Loading…
Reference in a new issue