2008-03-04 12:58:21 +01:00
|
|
|
/* Copyright (C) 2006-2008 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2017-02-10 12:26:55 +01:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
|
2008-03-04 12:58:21 +01:00
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
#include "../maria_def.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2007-02-12 13:23:43 +01:00
|
|
|
#include <tap.h>
|
2007-06-11 16:29:53 +02:00
|
|
|
#include "../trnman.h"
|
|
|
|
|
2011-05-13 15:22:05 +02:00
|
|
|
extern my_bool maria_log_remove(const char *testdir);
|
|
|
|
extern char *create_tmpdir(const char *progname);
|
2007-02-02 08:41:32 +01:00
|
|
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
static const char *default_dbug_option;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PCACHE_SIZE (1024*1024*10)
|
|
|
|
|
2008-06-09 23:54:30 +02:00
|
|
|
#define LOG_FILE_SIZE (1024L*1024L*1024L + 1024L*1024L*512)
|
2007-02-02 08:41:32 +01:00
|
|
|
/*#define LOG_FLAGS TRANSLOG_SECTOR_PROTECTION | TRANSLOG_PAGE_CRC */
|
|
|
|
#define LOG_FLAGS 0
|
|
|
|
/*#define LONG_BUFFER_SIZE (1024L*1024L*1024L + 1024L*1024L*512)*/
|
2008-06-09 23:54:30 +02:00
|
|
|
|
|
|
|
#ifdef MULTIFLUSH_TEST
|
|
|
|
|
2012-01-27 09:58:59 +01:00
|
|
|
#define LONG_BUFFER_SZ (16384L)
|
2008-06-09 23:54:30 +02:00
|
|
|
#define MIN_REC_LENGTH 10
|
|
|
|
#define SHOW_DIVIDER 20
|
|
|
|
#define ITERATIONS 10000
|
|
|
|
#define FLUSH_ITERATIONS 1000
|
|
|
|
#define WRITERS 2
|
|
|
|
#define FLUSHERS 10
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2012-01-27 09:58:59 +01:00
|
|
|
#define LONG_BUFFER_SZ (512L*1024L*1024L)
|
2007-02-02 08:41:32 +01:00
|
|
|
#define MIN_REC_LENGTH 30
|
|
|
|
#define SHOW_DIVIDER 10
|
|
|
|
#define ITERATIONS 3
|
2008-06-09 23:54:30 +02:00
|
|
|
#define FLUSH_ITERATIONS 0
|
2007-02-02 08:41:32 +01:00
|
|
|
#define WRITERS 3
|
2008-06-09 23:54:30 +02:00
|
|
|
#define FLUSHERS 0
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-01-27 09:58:59 +01:00
|
|
|
#define LONG_BUFFER_SIZE (LONG_BUFFER_SZ >> (skip_big_tests ? 4 : 0))
|
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
static uint number_of_writers= WRITERS;
|
2008-06-09 23:54:30 +02:00
|
|
|
static uint number_of_flushers= FLUSHERS;
|
2007-02-02 08:41:32 +01:00
|
|
|
|
|
|
|
static pthread_cond_t COND_thread_count;
|
|
|
|
static pthread_mutex_t LOCK_thread_count;
|
|
|
|
static uint thread_count;
|
|
|
|
|
|
|
|
static ulong lens[WRITERS][ITERATIONS];
|
|
|
|
static LSN lsns1[WRITERS][ITERATIONS];
|
|
|
|
static LSN lsns2[WRITERS][ITERATIONS];
|
2007-07-02 19:45:15 +02:00
|
|
|
static uchar *long_buffer;
|
2007-02-02 08:41:32 +01:00
|
|
|
|
2008-06-09 23:54:30 +02:00
|
|
|
|
|
|
|
static LSN last_lsn; /* For test purposes the variable allow dirty read/write */
|
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
/*
|
|
|
|
Get pseudo-random length of the field in
|
|
|
|
limits [MIN_REC_LENGTH..LONG_BUFFER_SIZE]
|
|
|
|
|
2007-02-21 14:54:08 +01:00
|
|
|
SYNOPSIS
|
2007-02-02 08:41:32 +01:00
|
|
|
get_len()
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
length - length >= 0 length <= LONG_BUFFER_SIZE
|
|
|
|
*/
|
|
|
|
|
|
|
|
static uint32 get_len()
|
|
|
|
{
|
2008-01-10 13:21:53 +01:00
|
|
|
return MIN_REC_LENGTH +
|
|
|
|
(uint32)(((ulonglong)rand())*
|
|
|
|
(LONG_BUFFER_SIZE - MIN_REC_LENGTH - 1)/RAND_MAX);
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Check that the buffer filled correctly
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
check_content()
|
|
|
|
ptr Pointer to the buffer
|
|
|
|
length length of the buffer
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
0 - OK
|
|
|
|
1 - Error
|
|
|
|
*/
|
|
|
|
|
2007-07-02 19:45:15 +02:00
|
|
|
static my_bool check_content(uchar *ptr, ulong length)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
ulong i;
|
|
|
|
for (i= 0; i < length; i++)
|
|
|
|
{
|
2007-02-19 22:01:27 +01:00
|
|
|
if (((uchar)ptr[i]) != (i & 0xFF))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Byte # %lu is %x instead of %x",
|
|
|
|
i, (uint) ptr[i], (uint) (i & 0xFF));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Read whole record content, and check content (put with offset)
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
read_and_check_content()
|
|
|
|
rec The record header buffer
|
|
|
|
buffer The buffer to read the record in
|
|
|
|
skip Skip this number of bytes ot the record content
|
|
|
|
|
|
|
|
RETURN
|
|
|
|
0 - OK
|
|
|
|
1 - Error
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static my_bool read_and_check_content(TRANSLOG_HEADER_BUFFER *rec,
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *buffer, uint skip)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
int res= 0;
|
|
|
|
translog_size_t len;
|
2007-02-21 14:54:08 +01:00
|
|
|
|
2007-02-12 13:23:43 +01:00
|
|
|
if ((len= translog_read_record(rec->lsn, 0, rec->record_length,
|
2007-02-02 08:41:32 +01:00
|
|
|
buffer, NULL)) != rec->record_length)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Requested %lu byte, read %lu\n",
|
|
|
|
(ulong) rec->record_length, (ulong) len);
|
|
|
|
res= 1;
|
|
|
|
}
|
|
|
|
res|= check_content(buffer + skip, rec->record_length - skip);
|
2007-02-21 14:54:08 +01:00
|
|
|
return(res);
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void writer(int num)
|
|
|
|
{
|
|
|
|
LSN lsn;
|
2007-06-11 16:29:53 +02:00
|
|
|
TRN trn;
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar long_tr_id[6];
|
2007-02-02 08:41:32 +01:00
|
|
|
uint i;
|
|
|
|
|
2007-06-11 16:29:53 +02:00
|
|
|
trn.short_id= num;
|
2007-08-03 15:58:50 +02:00
|
|
|
trn.first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
|
2007-02-02 08:41:32 +01:00
|
|
|
for (i= 0; i < ITERATIONS; i++)
|
|
|
|
{
|
|
|
|
uint len= get_len();
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
2008-01-10 13:21:53 +01:00
|
|
|
lens[num][i]= len;
|
2007-02-02 08:41:32 +01:00
|
|
|
|
|
|
|
int2store(long_tr_id, num);
|
|
|
|
int4store(long_tr_id + 2, i);
|
2008-08-04 18:57:41 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= long_tr_id;
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 19:13:56 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
2007-02-02 08:41:32 +01:00
|
|
|
if (translog_write_record(&lsn,
|
2007-06-15 00:45:55 +02:00
|
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
2007-06-11 16:29:53 +02:00
|
|
|
&trn, NULL, 6, TRANSLOG_INTERNAL_PARTS + 1,
|
WL#3072 - Maria recovery.
* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.
storage/maria/ha_maria.cc:
question for Monty
storage/maria/ma_blockrec.c:
* log in-write hooks (write_hook_for_redo() etc) move from
ma_loghandler.c to here; this is natural: the hooks are coupled
to their callers (functions in ma_blockrec.c).
* translog_write_record() now has a new argument "hook_arg";
using it to pass down to write_hook_for_clr_end() the transaction's
previous_undo_lsn and the type of the being undone record, and also
to pass down to all UNDOs the live checksum variation caused by the
operation.
* If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
and in CLR_END the checksum variation ("delta") caused by the
operation. For example if a DELETE caused the table's live checksum
to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
the value 333 (456-123).
* Instead of hard-coded "1" as length of the place where we store
the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
use macros clr_type_store and clr_type_korr.
* write_block_record() has a new parameter 'old_record_checksum'
which is the pre-computed checksum of old_record; that value is used
to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
* In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
the row's checksum is already computed.
* _ma_update_block_record2() now expect the new row's checksum into
cur_row.checksum (was already true) and the old row's checksum into
new_row.checksum (that's new). Its two callers, maria_update() and
_ma_apply_undo_row_update(), honour this.
* When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
up the checksum delta from the log record. It is then used to update
the table's live checksum when writing CLR_END, and saves us a
computation of record.
storage/maria/ma_blockrec.h:
in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
more straightforward size of buffer
storage/maria/ma_checkpoint.c:
<= is enough
storage/maria/ma_commit.c:
new prototype of translog_write_record()
storage/maria/ma_create.c:
new prototype of translog_write_record()
storage/maria/ma_delete.c:
The row's checksum must be computed before calling(*delete_record)(),
not after, because it must be known inside _ma_delete_block_record()
(to update the table's live checksum when writing UNDO_ROW_DELETE).
If deleting from a transactional table, live checksum was already updated
when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
@todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
* in-write hooks move to ma_blockrec.c.
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
* fix for compiler warning (unused buffer_start when compiling without
debug support)
* Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
and CLR_END, but only if the table has live checksum, these records
are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
length is X if no live checksum and X+4 otherwise).
* add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
DELETE and REDO_DELETE_ALL and CLR_END.
* Bugfix: when reading a record in translog_read_record(), it happened
that "length" became negative, because the function assumed that
the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
* Instead of hard-coded "1" and "4", use symbols and macros
to store/retrieve the type of record which the CLR_END corresponds
to, and the checksum variation caused by the operation which logs the
record
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
storage/maria/ma_open.c:
fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
<= is enough
storage/maria/ma_recovery.c:
* print the time that each recovery phase (REDO/UNDO/flush) took;
this is enabled only when recovering from ha_maria. Is it printed
n seconds with a fractional part of one digit (like 123.4 seconds).
* In the REDO phase, update the table's live checksum by using
the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
Update it too when seeing REDO_DELETE_ALL.
* In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
not have live checksum then reading the record's header (as done by
the master loop of run_undo_phase()) is enough; otherwise we
do a translog_read_record() to have the checksum delta ready
for _ma_apply_undo_row_insert().
* When at the end of the REDO phase we notice that there is an unfinished
group of REDOs, don't assert in debug binaries, as I verified that it
can happen in real life (with kill -9)
* removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
Change in output of ma_test_recovery: now all live checksums of
original tables equal those of tables recreated by the REDO phase
and those of tables fixed by the UNDO phase. I.e. recovery of
the live checksum looks like working (which was after all the only
goal of this changeset).
I checked by hand that it's not just all live checksums which are
now 0 and that's why they match. They are the old values like
3757530372. maria.test has hard-coded checksum values in its result
file so checks this too.
storage/maria/ma_update.c:
* It's useless to put up HA_STATE_CHANGED in 'key_changed',
as we put up HA_STATE_CHANGED in info->update anyway.
* We need to compute the old and new rows' checksum before calling
(*update_record)(), as checksum delta must be known when logging
UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
some functions change the 'newrec' record (at least _ma_check_unique()
does) so we cannot move the checksum computation too early in the
function.
storage/maria/ma_write.c:
If inserting into a transactional table, live's checksum was
already updated when writing UNDO_ROW_INSERT. The multiplication
is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
new prototype of translog_write_record()
storage/myisam/sort.c:
fix for compiler warnings in pushbuild (write_merge_key* functions
didn't have their declaration match MARIA_HA::write_key).
2007-10-02 18:02:09 +02:00
|
|
|
parts, NULL, NULL))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
2007-06-15 00:45:55 +02:00
|
|
|
fprintf(stderr, "Can't write LOGREC_FIXED_RECORD_0LSN_EXAMPLE record #%lu "
|
2007-02-02 08:41:32 +01:00
|
|
|
"thread %i\n", (ulong) i, num);
|
|
|
|
translog_destroy();
|
2007-02-21 14:54:08 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
ok(0, "write records");
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-02-02 08:41:32 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
lsns1[num][i]= lsn;
|
2008-08-04 18:57:41 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= long_buffer;
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 19:13:56 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= len;
|
2007-02-02 08:41:32 +01:00
|
|
|
if (translog_write_record(&lsn,
|
2007-06-15 00:45:55 +02:00
|
|
|
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE,
|
2007-06-11 16:29:53 +02:00
|
|
|
&trn, NULL,
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 19:13:56 +02:00
|
|
|
len, TRANSLOG_INTERNAL_PARTS + 1,
|
WL#3072 - Maria recovery.
* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.
storage/maria/ha_maria.cc:
question for Monty
storage/maria/ma_blockrec.c:
* log in-write hooks (write_hook_for_redo() etc) move from
ma_loghandler.c to here; this is natural: the hooks are coupled
to their callers (functions in ma_blockrec.c).
* translog_write_record() now has a new argument "hook_arg";
using it to pass down to write_hook_for_clr_end() the transaction's
previous_undo_lsn and the type of the being undone record, and also
to pass down to all UNDOs the live checksum variation caused by the
operation.
* If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
and in CLR_END the checksum variation ("delta") caused by the
operation. For example if a DELETE caused the table's live checksum
to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
the value 333 (456-123).
* Instead of hard-coded "1" as length of the place where we store
the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
use macros clr_type_store and clr_type_korr.
* write_block_record() has a new parameter 'old_record_checksum'
which is the pre-computed checksum of old_record; that value is used
to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
* In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
the row's checksum is already computed.
* _ma_update_block_record2() now expect the new row's checksum into
cur_row.checksum (was already true) and the old row's checksum into
new_row.checksum (that's new). Its two callers, maria_update() and
_ma_apply_undo_row_update(), honour this.
* When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
up the checksum delta from the log record. It is then used to update
the table's live checksum when writing CLR_END, and saves us a
computation of record.
storage/maria/ma_blockrec.h:
in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
more straightforward size of buffer
storage/maria/ma_checkpoint.c:
<= is enough
storage/maria/ma_commit.c:
new prototype of translog_write_record()
storage/maria/ma_create.c:
new prototype of translog_write_record()
storage/maria/ma_delete.c:
The row's checksum must be computed before calling(*delete_record)(),
not after, because it must be known inside _ma_delete_block_record()
(to update the table's live checksum when writing UNDO_ROW_DELETE).
If deleting from a transactional table, live checksum was already updated
when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
@todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
* in-write hooks move to ma_blockrec.c.
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
* fix for compiler warning (unused buffer_start when compiling without
debug support)
* Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
and CLR_END, but only if the table has live checksum, these records
are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
length is X if no live checksum and X+4 otherwise).
* add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
DELETE and REDO_DELETE_ALL and CLR_END.
* Bugfix: when reading a record in translog_read_record(), it happened
that "length" became negative, because the function assumed that
the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
* Instead of hard-coded "1" and "4", use symbols and macros
to store/retrieve the type of record which the CLR_END corresponds
to, and the checksum variation caused by the operation which logs the
record
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
storage/maria/ma_open.c:
fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
<= is enough
storage/maria/ma_recovery.c:
* print the time that each recovery phase (REDO/UNDO/flush) took;
this is enabled only when recovering from ha_maria. Is it printed
n seconds with a fractional part of one digit (like 123.4 seconds).
* In the REDO phase, update the table's live checksum by using
the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
Update it too when seeing REDO_DELETE_ALL.
* In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
not have live checksum then reading the record's header (as done by
the master loop of run_undo_phase()) is enough; otherwise we
do a translog_read_record() to have the checksum delta ready
for _ma_apply_undo_row_insert().
* When at the end of the REDO phase we notice that there is an unfinished
group of REDOs, don't assert in debug binaries, as I verified that it
can happen in real life (with kill -9)
* removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
Change in output of ma_test_recovery: now all live checksums of
original tables equal those of tables recreated by the REDO phase
and those of tables fixed by the UNDO phase. I.e. recovery of
the live checksum looks like working (which was after all the only
goal of this changeset).
I checked by hand that it's not just all live checksums which are
now 0 and that's why they match. They are the old values like
3757530372. maria.test has hard-coded checksum values in its result
file so checks this too.
storage/maria/ma_update.c:
* It's useless to put up HA_STATE_CHANGED in 'key_changed',
as we put up HA_STATE_CHANGED in info->update anyway.
* We need to compute the old and new rows' checksum before calling
(*update_record)(), as checksum delta must be known when logging
UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
some functions change the 'newrec' record (at least _ma_check_unique()
does) so we cannot move the checksum computation too early in the
function.
storage/maria/ma_write.c:
If inserting into a transactional table, live's checksum was
already updated when writing UNDO_ROW_INSERT. The multiplication
is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
new prototype of translog_write_record()
storage/myisam/sort.c:
fix for compiler warnings in pushbuild (write_merge_key* functions
didn't have their declaration match MARIA_HA::write_key).
2007-10-02 18:02:09 +02:00
|
|
|
parts, NULL, NULL))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't write variable record #%lu\n", (ulong) i);
|
|
|
|
translog_destroy();
|
2007-02-21 14:54:08 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
ok(0, "write records");
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-02-02 08:41:32 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
lsns2[num][i]= lsn;
|
2008-06-09 23:54:30 +02:00
|
|
|
last_lsn= lsn;
|
2007-02-21 14:54:08 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
ok(1, "write records");
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
2007-02-21 14:54:08 +01:00
|
|
|
return;
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *test_thread_writer(void *arg)
|
|
|
|
{
|
|
|
|
int param= *((int*) arg);
|
|
|
|
|
|
|
|
my_thread_init();
|
|
|
|
|
|
|
|
writer(param);
|
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
thread_count--;
|
2007-02-21 14:54:08 +01:00
|
|
|
ok(1, "writer finished"); /* just to show progress */
|
2011-04-25 17:22:25 +02:00
|
|
|
pthread_cond_signal(&COND_thread_count); /* Tell main we are
|
2007-02-02 08:41:32 +01:00
|
|
|
ready */
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-07-02 19:45:15 +02:00
|
|
|
free((uchar*) arg);
|
2007-02-02 08:41:32 +01:00
|
|
|
my_thread_end();
|
2007-02-21 14:54:08 +01:00
|
|
|
return(0);
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-09 23:54:30 +02:00
|
|
|
static void *test_thread_flusher(void *arg)
|
|
|
|
{
|
|
|
|
int param= *((int*) arg);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
my_thread_init();
|
|
|
|
|
|
|
|
for(i= 0; i < FLUSH_ITERATIONS; i++)
|
|
|
|
{
|
|
|
|
translog_flush(last_lsn);
|
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
ok(1, "-- flush %d", param);
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
thread_count--;
|
|
|
|
ok(1, "flusher finished"); /* just to show progress */
|
2011-04-25 17:22:25 +02:00
|
|
|
pthread_cond_signal(&COND_thread_count); /* Tell main we are
|
2008-06-09 23:54:30 +02:00
|
|
|
ready */
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
|
|
|
free((uchar*) arg);
|
|
|
|
my_thread_end();
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-09 13:52:17 +02:00
|
|
|
int main(int argc __attribute__((unused)),
|
|
|
|
char **argv __attribute__ ((unused)))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
uint32 i;
|
|
|
|
PAGECACHE pagecache;
|
2007-02-19 22:01:27 +01:00
|
|
|
LSN first_lsn;
|
2007-02-02 08:41:32 +01:00
|
|
|
TRANSLOG_HEADER_BUFFER rec;
|
|
|
|
struct st_translog_scanner_data scanner;
|
|
|
|
pthread_t tid;
|
|
|
|
pthread_attr_t thr_attr;
|
|
|
|
int *param, error;
|
|
|
|
int rc;
|
2011-05-13 15:22:05 +02:00
|
|
|
MY_INIT(argv[0]);
|
2008-06-30 11:13:08 +02:00
|
|
|
|
2012-01-27 09:58:59 +01:00
|
|
|
// plan read MYTAP_CONFIG so skip_big_tests will be set before using
|
2008-06-09 23:54:30 +02:00
|
|
|
plan(WRITERS + FLUSHERS +
|
|
|
|
ITERATIONS * WRITERS * 3 + FLUSH_ITERATIONS * FLUSHERS );
|
2011-05-05 13:51:01 +02:00
|
|
|
/* We don't need to do physical syncs in this test */
|
|
|
|
my_disable_sync= 1;
|
2007-02-21 14:54:08 +01:00
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
bzero(&pagecache, sizeof(pagecache));
|
2011-05-13 15:22:05 +02:00
|
|
|
maria_data_root= create_tmpdir(argv[0]);
|
|
|
|
if (maria_log_remove(0))
|
|
|
|
exit(1);
|
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
long_buffer= malloc(LONG_BUFFER_SIZE + 7 * 2 + 2);
|
|
|
|
if (long_buffer == 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "End of memory\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2012-04-13 19:44:22 +02:00
|
|
|
for (i= 0; i < (uint32)(LONG_BUFFER_SIZE + 7 * 2 + 2); i++)
|
2007-02-02 08:41:32 +01:00
|
|
|
long_buffer[i]= (i & 0xFF);
|
|
|
|
|
|
|
|
#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 ((error= pthread_cond_init(&COND_thread_count, NULL)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "COND_thread_count: %d from pthread_cond_init "
|
|
|
|
"(errno: %d)\n", error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if ((error= pthread_mutex_init(&LOCK_thread_count, MY_MUTEX_INIT_FAST)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "LOCK_thread_count: %d from pthread_cond_init "
|
|
|
|
"(errno: %d)\n", error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if ((error= pthread_attr_init(&thr_attr)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: %d from pthread_attr_init "
|
|
|
|
"(errno: %d)\n", error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if ((error= pthread_attr_setdetachstate(&thr_attr, PTHREAD_CREATE_DETACHED)))
|
|
|
|
{
|
|
|
|
fprintf(stderr,
|
|
|
|
"Got error: %d from pthread_attr_setdetachstate (errno: %d)\n",
|
|
|
|
error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-02-22 09:19:52 +01:00
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
#ifdef HAVE_THR_SETCONCURRENCY
|
2011-04-25 17:22:25 +02:00
|
|
|
thr_setconcurrency(2);
|
2007-02-02 08:41:32 +01:00
|
|
|
#endif
|
|
|
|
|
Added versioning of row data
Will in future changeset (soon) av versioning of status variables (number of rows) and index
Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings
Removed some not needed variables (as noticed by Guilhem)
include/maria.h:
Added prototypes for maria_chk_init_for_check(), maria_versioning() and maria_ignore_trids()
include/my_base.h:
Add new error HA_ERR_ROW_NOT_VISIBLE
include/myisamchk.h:
Added variables for checking visibility of rows during maria_chk
include/thr_lock.h:
Changed argument type from int to my_bool for get_status
Added variable allow_multiple_concurrent_insert, to signal if table supports multiple concurrent inserts
mysql-test/r/maria-page-checksum.result:
Added missing drop table
mysql-test/t/maria-page-checksum.test:
Added missing drop table
mysys/my_handler.c:
Added new error messages
mysys/thr_lock.c:
Added support for multiple concurrent inserts, if table handler supports it
sql/sql_yacc.yy:
Added LOCK TABLE table_name WRITE CONCURRENT
This was added (temporarly?) to be able to check versioning with Maria
storage/csv/ha_tina.cc:
Updated parameter for get_status
storage/maria/ha_maria.cc:
Added calls to maria_chk_init_status()
Fixed call to ma_control_file_open()
storage/maria/ma_blockrec.c:
Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings
Changed back some 'header' parameters to const char*
Removed some casts
Added support for versioning:
- If info->row_flag & ROW_FLAG_TRANSID is set, store transaction id together with the row
- When reading rows, check if rows are visible. Give error if not
- When scanning table, ignore not visible rows
- Added function parameters to some functions, to be able to call _ma_compact_block_page() with different parameters depending of if the page is a HEAD or TAIL page
- _ma_compact_block_page() deletes transaction id's that are visible by all running transactions
- Added functions for thr_lock() to enable multiple concurrent inserts
- Added helper function 'mysql_versioning()' to enable/disable versioning
- Added helper function maria_ignore_trids(), used by maria_chk and maria_pack to see all rows.
storage/maria/ma_blockrec.h:
Updated parameters for some functions.
Added new functions to read/store state with thr_lock
storage/maria/ma_check.c:
Enable handling of transaction id's in rows
Give a readable error if a table contains a transation id that makes rows not visible
storage/maria/ma_control_file.c:
Added option to not give warning if control file doesn't exists.
storage/maria/ma_control_file.h:
Updated parameter lists for ma_control_file_open()
storage/maria/ma_delete.c:
Removed not used variable (suggestion by Guilhem)
storage/maria/ma_locking.c:
Changed type of argument from int -> my_bool
storage/maria/ma_open.c:
Removed not used variables 'key_write_undo_lsn' and 'key_delete_undo_lsn'
Added new thr_lock interface functions for BLOCK_RECORD to enable multiple concurrent insert
storage/maria/ma_test1.c:
Added option --versioning (-C) to check versioning
storage/maria/ma_test2.c:
Added option -C to check versioning
storage/maria/ma_test_recovery:
Forward argumetns to ma_test_recovery.pl
storage/maria/ma_write.c:
Removed not used variable key_write_undo_lsn
storage/maria/maria_chk.c:
Always read control file (if exist) at start
Initialize checking of tables by calling maria_chk_init_for_check()
In verbose mode and in case of error, print max found transaction id
storage/maria/maria_def.h:
Added Trid to MARIA_ROW to be able to check transaction id for found row
Moved 'base_length' from MARIA_ROW to MARIA_HA to be able to handle different base length (with and without TRANSID) without if's
Added default row_flag to MARIA_HA for the same reason
Changed LEX_STRING -> LEX_CUSTRING to avoid casts in ma_blockrec.c
Removed not needed variables key_write_undo_lsn and key_delete_undo_lsn
Added prototypes for new functions and fixed those that had changed
storage/maria/maria_pack.c:
Ensure we can read all rows from the file, independent of the used transaction id
storage/maria/maria_read_log.c:
Updated arguments to ma_control_file_open()
storage/maria/trnman.c:
If we have only one transaction, fixed that min_read_from contains current transaction
Fixed that trnman_can_read_from() returns that row is readable if it was written by current transaction
storage/maria/unittest/ma_control_file-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_all-t:
Added test of versioning
Removed printing of one extra space
storage/maria/unittest/ma_test_loghandler-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Updated arguments to ma_control_file_open()
storage/maria/unittest/ma_test_recovery.expected:
Updated file with result from new tests
storage/maria/unittest/ma_test_recovery.pl:
Added options --abort-on-error and --verbose
In case of --verbose, print all excuted shell commands
Added test of versioning
storage/myisam/mi_locking.c:
Updated type of parameter
storage/myisam/myisamdef.h:
Updated type of parameter
mysql-test/r/maria-mvcc.result:
New BitKeeper file ``mysql-test/r/maria-mvcc.result''
mysql-test/t/maria-mvcc.test:
New BitKeeper file ``mysql-test/t/maria-mvcc.test''
2008-04-10 04:26:36 +02:00
|
|
|
if (ma_control_file_open(TRUE, TRUE))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't init control file (%d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2014-07-19 16:46:08 +02:00
|
|
|
if (init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
|
|
|
|
TRANSLOG_PAGE_SIZE, 0, 0) == 0)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2011-05-13 15:22:05 +02:00
|
|
|
if (translog_init_with_table(maria_data_root, LOG_FILE_SIZE, 50112, 0, &pagecache,
|
2007-12-21 14:25:30 +01:00
|
|
|
LOG_FLAGS, 0, &translog_example_table_init,
|
|
|
|
0))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-09-04 21:52:32 +02:00
|
|
|
/* Suppressing of automatic record writing */
|
|
|
|
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
|
2007-02-02 08:41:32 +01:00
|
|
|
|
2008-01-10 13:21:53 +01:00
|
|
|
srand(122334817L);
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar long_tr_id[6]=
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
0x11, 0x22, 0x33, 0x44, 0x55, 0x66
|
|
|
|
};
|
|
|
|
|
2008-08-04 18:57:41 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= long_tr_id;
|
This patch is a collection of patches from from Sanja, Sergei and Monty.
Added logging and pinning of pages to block format.
Integration of transaction manager, log handler.
Better page cache intergration
Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs.
Renaming of structures, more comments, more debugging etc.
Fixed problem with small head block + long varchar.
Added extra argument to delete_record() and update_record() (needed for UNDO logging)
Small changes to interface of pagecache and log handler.
Change initialization of log_record_type_descriptors to not be depending on enum order.
Use array of LEX_STRING's to send data to log handler
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
include/lf.h:
Interface fixes
Rename of structures
(Patch from Sergei via Sanja)
include/my_atomic.h:
More comments
include/my_global.h:
Added MY_ERRPTR
include/pagecache.h:
Added undo LSN when unlocking pages
mysql-test/r/maria.result:
Updated results
mysql-test/t/maria.test:
Added autocommit around lock tables
(Patch from Sanja)
mysys/lf_alloc-pin.c:
Post-review fixes, simple optimizations
More comments
Struct slot renames
Check amount of memory on stack
(Patch from Sergei)
mysys/lf_dynarray.c:
More comments
mysys/lf_hash.c:
More comments
After review fixes
(Patch from Sergei)
storage/maria/ha_maria.cc:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
Move out all deferencing of the transaction structure.
Transaction manager integrated (Patch from Sergei)
storage/maria/ha_maria.h:
Added prototype for start_stmt()
storage/maria/lockman.c:
Function call rename
storage/maria/ma_bitmap.c:
Mark deleted pages free from page cache
storage/maria/ma_blockrec.c:
Offset -> rownr
More debugging
Fixed problem with small head block + long varchar
Added logging of changed pages
Added logging of undo (Including only loggging of changed fields in case of update)
Added pinning/unpinning of all changed pages
More comments
Added free_full_pages() as the same code was used in several places.
fill_rows_parts() renamed as fill_insert_undo_parts()
offset -> rownr
Added some optimization of not transactional tables
_ma_update_block_record() has new parameter, as we need original row to do efficent undo for update
storage/maria/ma_blockrec.h:
Added ROW_EXTENTS_ON_STACK
Changed prototype for update and delete of row
storage/maria/ma_check.c:
Added original row to delete_record() call
storage/maria/ma_control_file.h:
Added ifdefs for C++
storage/maria/ma_delete.c:
Added original row to delete_record() call
(Needed for efficent undo logging)
storage/maria/ma_dynrec.c:
Added extra argument to delete_record() and update_record()
Removed not used variable
storage/maria/ma_init.c:
Initialize log handler
storage/maria/ma_loghandler.c:
Removed not used variable
Change initialization of log_record_type_descriptors to not be depending on enum order
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_loghandler.h:
New defines
Use array of LEX_STRING's to send data to log handler
storage/maria/ma_open.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
storage/maria/ma_pagecache.c:
Don't decrease number of readers when using pagecache_write()/pagecache_read()
In pagecache_write() decrement request count if page was left pinned
Added pagecache_delete_pages()
Removed some casts
Make trace output consistent with rest of code
Simplify calling of DBUG_ASSERT(0)
Only update LSN if the LSN is bigger than what's already on the page
Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock()
(Part of patch from Sanja)
storage/maria/ma_static.c:
Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists.
Added default page cache
storage/maria/ma_statrec.c:
Added extra argument to delete_record() and update_record()
storage/maria/ma_test1.c:
Added option -T for transactions
storage/maria/ma_test2.c:
Added option -T for transactions
storage/maria/ma_test_all.sh:
Test with transactions
storage/maria/ma_update.c:
Changed prototype for update of row
storage/maria/maria_def.h:
Changed prototype for update & delete of row as block records need to access the old row
Store in MARIA_SHARE->page_type if pages will have up to date LSN's
Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need.
Removed not used 'empty_bits_buffer'
Added pointer to transaction object
Added array for pinned pages
Added log_row_parts array for logging of field data.
Added MARIA_PINNED_PAGE to store pinned pages
storage/maria/trnman.c:
Added accessor functions to transaction object
Added missing DBUG_RETURN()
More debugging
More comments
Changed // comment of code to #ifdef NOT_USED
Transaction manager integrated.
Post review fixes
Part of patch originally from Sergei
storage/maria/trnman.h:
Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program.
(Temporary fix to avoid bug in gcc)
storage/maria/unittest/ma_pagecache_single.c:
Added missing argument
Added SKIP_BIG_TESTS
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Test logging with new LEX_STRING parameter
(Patch from Sanja)
storage/maria/unittest/trnman-t.c:
Stack overflow detection
(Patch from Sergei)
unittest/unit.pl:
Command-line options --big and --verbose
(Patch from Sergei)
unittest/mytap/tap.c:
Detect --big
(Patch from Sergei)
unittest/mytap/tap.h:
Skip_big_tests and SKIP_BIG_TESTS
(Patch from Sergei)
storage/maria/trnman_public.h:
New BitKeeper file ``storage/maria/trnman_public.h''
2007-05-29 19:13:56 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
2007-08-03 15:58:50 +02:00
|
|
|
dummy_transaction_object.first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
|
2007-02-02 08:41:32 +01:00
|
|
|
if (translog_write_record(&first_lsn,
|
2007-06-15 00:45:55 +02:00
|
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
2007-06-11 16:29:53 +02:00
|
|
|
&dummy_transaction_object, NULL, 6,
|
|
|
|
TRANSLOG_INTERNAL_PARTS + 1,
|
WL#3072 - Maria recovery.
* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.
storage/maria/ha_maria.cc:
question for Monty
storage/maria/ma_blockrec.c:
* log in-write hooks (write_hook_for_redo() etc) move from
ma_loghandler.c to here; this is natural: the hooks are coupled
to their callers (functions in ma_blockrec.c).
* translog_write_record() now has a new argument "hook_arg";
using it to pass down to write_hook_for_clr_end() the transaction's
previous_undo_lsn and the type of the being undone record, and also
to pass down to all UNDOs the live checksum variation caused by the
operation.
* If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
and in CLR_END the checksum variation ("delta") caused by the
operation. For example if a DELETE caused the table's live checksum
to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
the value 333 (456-123).
* Instead of hard-coded "1" as length of the place where we store
the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
use macros clr_type_store and clr_type_korr.
* write_block_record() has a new parameter 'old_record_checksum'
which is the pre-computed checksum of old_record; that value is used
to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
* In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
the row's checksum is already computed.
* _ma_update_block_record2() now expect the new row's checksum into
cur_row.checksum (was already true) and the old row's checksum into
new_row.checksum (that's new). Its two callers, maria_update() and
_ma_apply_undo_row_update(), honour this.
* When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
up the checksum delta from the log record. It is then used to update
the table's live checksum when writing CLR_END, and saves us a
computation of record.
storage/maria/ma_blockrec.h:
in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
more straightforward size of buffer
storage/maria/ma_checkpoint.c:
<= is enough
storage/maria/ma_commit.c:
new prototype of translog_write_record()
storage/maria/ma_create.c:
new prototype of translog_write_record()
storage/maria/ma_delete.c:
The row's checksum must be computed before calling(*delete_record)(),
not after, because it must be known inside _ma_delete_block_record()
(to update the table's live checksum when writing UNDO_ROW_DELETE).
If deleting from a transactional table, live checksum was already updated
when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
@todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
* in-write hooks move to ma_blockrec.c.
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
* fix for compiler warning (unused buffer_start when compiling without
debug support)
* Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
and CLR_END, but only if the table has live checksum, these records
are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
length is X if no live checksum and X+4 otherwise).
* add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
DELETE and REDO_DELETE_ALL and CLR_END.
* Bugfix: when reading a record in translog_read_record(), it happened
that "length" became negative, because the function assumed that
the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
* Instead of hard-coded "1" and "4", use symbols and macros
to store/retrieve the type of record which the CLR_END corresponds
to, and the checksum variation caused by the operation which logs the
record
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
storage/maria/ma_open.c:
fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
<= is enough
storage/maria/ma_recovery.c:
* print the time that each recovery phase (REDO/UNDO/flush) took;
this is enabled only when recovering from ha_maria. Is it printed
n seconds with a fractional part of one digit (like 123.4 seconds).
* In the REDO phase, update the table's live checksum by using
the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
Update it too when seeing REDO_DELETE_ALL.
* In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
not have live checksum then reading the record's header (as done by
the master loop of run_undo_phase()) is enough; otherwise we
do a translog_read_record() to have the checksum delta ready
for _ma_apply_undo_row_insert().
* When at the end of the REDO phase we notice that there is an unfinished
group of REDOs, don't assert in debug binaries, as I verified that it
can happen in real life (with kill -9)
* removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
Change in output of ma_test_recovery: now all live checksums of
original tables equal those of tables recreated by the REDO phase
and those of tables fixed by the UNDO phase. I.e. recovery of
the live checksum looks like working (which was after all the only
goal of this changeset).
I checked by hand that it's not just all live checksums which are
now 0 and that's why they match. They are the old values like
3757530372. maria.test has hard-coded checksum values in its result
file so checks this too.
storage/maria/ma_update.c:
* It's useless to put up HA_STATE_CHANGED in 'key_changed',
as we put up HA_STATE_CHANGED in info->update anyway.
* We need to compute the old and new rows' checksum before calling
(*update_record)(), as checksum delta must be known when logging
UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
some functions change the 'newrec' record (at least _ma_check_unique()
does) so we cannot move the checksum computation too early in the
function.
storage/maria/ma_write.c:
If inserting into a transactional table, live's checksum was
already updated when writing UNDO_ROW_INSERT. The multiplication
is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
new prototype of translog_write_record()
storage/myisam/sort.c:
fix for compiler warnings in pushbuild (write_merge_key* functions
didn't have their declaration match MARIA_HA::write_key).
2007-10-02 18:02:09 +02:00
|
|
|
parts, NULL, NULL))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't write the first record\n");
|
|
|
|
translog_destroy();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
2008-06-09 23:54:30 +02:00
|
|
|
while (number_of_writers != 0 || number_of_flushers != 0)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
2008-06-09 23:54:30 +02:00
|
|
|
if (number_of_writers)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
2008-06-09 23:54:30 +02:00
|
|
|
param= (int*) malloc(sizeof(int));
|
|
|
|
*param= number_of_writers - 1;
|
|
|
|
if ((error= pthread_create(&tid, &thr_attr, test_thread_writer,
|
|
|
|
(void*) param)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
|
|
|
|
error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
thread_count++;
|
|
|
|
number_of_writers--;
|
|
|
|
}
|
|
|
|
if (number_of_flushers)
|
|
|
|
{
|
|
|
|
param= (int*) malloc(sizeof(int));
|
|
|
|
*param= number_of_flushers - 1;
|
|
|
|
if ((error= pthread_create(&tid, &thr_attr, test_thread_flusher,
|
|
|
|
(void*) param)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: %d from pthread_create (errno: %d)\n",
|
|
|
|
error, errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
thread_count++;
|
|
|
|
number_of_flushers--;
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
|
|
|
|
|
|
|
pthread_attr_destroy(&thr_attr);
|
|
|
|
|
|
|
|
/* wait finishing */
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
2007-02-02 08:41:32 +01:00
|
|
|
while (thread_count)
|
|
|
|
{
|
|
|
|
if ((error= pthread_cond_wait(&COND_thread_count, &LOCK_thread_count)))
|
|
|
|
fprintf(stderr, "COND_thread_count: %d from pthread_cond_wait\n", error);
|
|
|
|
}
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-02-02 08:41:32 +01:00
|
|
|
|
|
|
|
/* Find last LSN and flush up to it (all our log) */
|
|
|
|
{
|
2007-02-12 13:23:43 +01:00
|
|
|
LSN max= 0;
|
2007-02-02 08:41:32 +01:00
|
|
|
for (i= 0; i < WRITERS; i++)
|
|
|
|
{
|
|
|
|
if (cmp_translog_addr(lsns2[i][ITERATIONS - 1], max) > 0)
|
|
|
|
max= lsns2[i][ITERATIONS - 1];
|
|
|
|
}
|
2007-02-12 13:23:43 +01:00
|
|
|
translog_flush(max);
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
rc= 1;
|
|
|
|
|
|
|
|
{
|
|
|
|
uint indeces[WRITERS];
|
2007-07-30 15:05:43 +02:00
|
|
|
uint index, stage;
|
|
|
|
int len;
|
2007-02-02 08:41:32 +01:00
|
|
|
bzero(indeces, sizeof(uint) * WRITERS);
|
|
|
|
|
|
|
|
bzero(indeces, sizeof(indeces));
|
|
|
|
|
2007-12-06 12:32:16 +01:00
|
|
|
if (translog_scanner_init(first_lsn, 1, &scanner, 0))
|
2007-02-19 22:01:27 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "scanner init failed\n");
|
|
|
|
goto err;
|
|
|
|
}
|
2007-02-02 08:41:32 +01:00
|
|
|
for (i= 0;; i++)
|
|
|
|
{
|
2007-02-19 22:01:27 +01:00
|
|
|
len= translog_read_next_record_header(&scanner, &rec);
|
2007-02-02 08:41:32 +01:00
|
|
|
|
2007-07-30 15:05:43 +02:00
|
|
|
if (len == RECHEADER_READ_ERROR)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr, "1-%d translog_read_next_record_header failed (%d)\n",
|
|
|
|
i, errno);
|
|
|
|
translog_free_record_header(&rec);
|
|
|
|
goto err;
|
|
|
|
}
|
2007-07-30 15:05:43 +02:00
|
|
|
if (len == RECHEADER_READ_EOF)
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
if (i != WRITERS * ITERATIONS * 2)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "EOL met at iteration %u instead of %u\n",
|
|
|
|
i, ITERATIONS * WRITERS * 2);
|
|
|
|
translog_free_record_header(&rec);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
index= indeces[rec.short_trid] / 2;
|
|
|
|
stage= indeces[rec.short_trid] % 2;
|
|
|
|
if (stage == 0)
|
|
|
|
{
|
2007-06-15 00:45:55 +02:00
|
|
|
if (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE ||
|
2007-02-02 08:41:32 +01:00
|
|
|
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)
|
|
|
|
{
|
2007-06-15 00:45:55 +02:00
|
|
|
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
|
|
|
"data read(%d)\n"
|
2007-02-02 08:41:32 +01:00
|
|
|
"type %u, strid %u %u, len %u, i: %u %u, "
|
2017-09-19 19:45:17 +02:00
|
|
|
"lsn" LSN_FMT " " LSN_FMT "\n",
|
2007-02-02 08:41:32 +01:00
|
|
|
i, (uint) rec.type,
|
|
|
|
(uint) rec.short_trid, (uint) uint2korr(rec.header),
|
|
|
|
(uint) rec.record_length,
|
|
|
|
(uint) index, (uint) uint4korr(rec.header + 2),
|
2007-09-13 09:37:51 +02:00
|
|
|
LSN_IN_PARTS(rec.lsn),
|
|
|
|
LSN_IN_PARTS(lsns1[rec.short_trid][index]));
|
2007-02-02 08:41:32 +01:00
|
|
|
translog_free_record_header(&rec);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-15 00:45:55 +02:00
|
|
|
if (rec.type != LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE ||
|
2007-02-02 08:41:32 +01:00
|
|
|
len != 9 ||
|
|
|
|
rec.record_length != lens[rec.short_trid][index] ||
|
|
|
|
cmp_translog_addr(lsns2[rec.short_trid][index], rec.lsn) != 0 ||
|
2007-07-30 15:05:43 +02:00
|
|
|
check_content(rec.header, (uint)len))
|
2007-02-02 08:41:32 +01:00
|
|
|
{
|
|
|
|
fprintf(stderr,
|
2007-06-15 00:45:55 +02:00
|
|
|
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
|
|
|
"data read(%d) "
|
|
|
|
"thread: %d, iteration %d, stage %d\n"
|
2007-07-30 15:05:43 +02:00
|
|
|
"type %u (%d), len %d, length %lu %lu (%d) "
|
2017-09-19 19:45:17 +02:00
|
|
|
"lsn" LSN_FMT " " LSN_FMT "\n",
|
2007-02-02 08:41:32 +01:00
|
|
|
i, (uint) rec.short_trid, index, stage,
|
2007-06-15 00:45:55 +02:00
|
|
|
(uint) rec.type, (rec.type !=
|
|
|
|
LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE),
|
2007-07-30 15:05:43 +02:00
|
|
|
len,
|
2007-02-02 08:41:32 +01:00
|
|
|
(ulong) rec.record_length, lens[rec.short_trid][index],
|
|
|
|
(rec.record_length != lens[rec.short_trid][index]),
|
2007-09-13 09:37:51 +02:00
|
|
|
LSN_IN_PARTS(rec.lsn),
|
|
|
|
LSN_IN_PARTS(lsns2[rec.short_trid][index]));
|
2007-02-02 08:41:32 +01:00
|
|
|
translog_free_record_header(&rec);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (read_and_check_content(&rec, long_buffer, 0))
|
|
|
|
{
|
|
|
|
fprintf(stderr,
|
2007-06-15 00:45:55 +02:00
|
|
|
"Incorrect LOGREC_VARIABLE_RECORD_0LSN_EXAMPLE "
|
2017-09-19 19:45:17 +02:00
|
|
|
"in whole rec read lsn" LSN_FMT "\n",
|
2007-09-13 09:37:51 +02:00
|
|
|
LSN_IN_PARTS(rec.lsn));
|
2007-02-02 08:41:32 +01:00
|
|
|
translog_free_record_header(&rec);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
2007-02-21 14:54:08 +01:00
|
|
|
ok(1, "record read");
|
2007-02-02 08:41:32 +01:00
|
|
|
translog_free_record_header(&rec);
|
|
|
|
indeces[rec.short_trid]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rc= 0;
|
|
|
|
err:
|
2007-02-21 14:54:08 +01:00
|
|
|
if (rc)
|
|
|
|
ok(0, "record read");
|
2007-02-02 08:41:32 +01:00
|
|
|
translog_destroy();
|
|
|
|
end_pagecache(&pagecache, 1);
|
|
|
|
ma_control_file_end();
|
2011-05-13 15:22:05 +02:00
|
|
|
if (maria_log_remove(maria_data_root))
|
2007-02-21 14:54:08 +01:00
|
|
|
exit(1);
|
2007-02-02 08:41:32 +01:00
|
|
|
|
2015-11-29 16:51:23 +01:00
|
|
|
my_uuid_end();
|
|
|
|
my_free_open_file_info();
|
2012-03-13 13:29:44 +01:00
|
|
|
my_end(0);
|
2007-02-21 14:54:08 +01:00
|
|
|
return(exit_status());
|
2007-02-02 08:41:32 +01:00
|
|
|
}
|
2011-04-25 17:22:25 +02:00
|
|
|
|
|
|
|
#include "../ma_check_standalone.h"
|