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
|
|
|
|
2006-11-16 22:53:53 +01:00
|
|
|
/*
|
|
|
|
TODO: use pthread_join instead of wait_for_thread_count_to_be_zero, like in
|
|
|
|
my_atomic-t.c (see BUG#22320).
|
|
|
|
Use diag() instead of fprintf(stderr).
|
|
|
|
*/
|
|
|
|
#include <tap.h>
|
|
|
|
#include <my_sys.h>
|
|
|
|
#include <m_string.h>
|
2006-07-06 10:10:34 +02:00
|
|
|
#include "test_file.h"
|
2007-02-12 13:23:43 +01:00
|
|
|
#include <tap.h>
|
2006-07-06 10:10:34 +02:00
|
|
|
|
2008-02-13 20:27:12 +01:00
|
|
|
#define PCACHE_SIZE (TEST_PAGE_SIZE*1024*10)
|
2006-07-06 10:10:34 +02:00
|
|
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
static const char* default_dbug_option;
|
|
|
|
#endif
|
|
|
|
|
2008-01-29 18:15:38 +01:00
|
|
|
#ifndef BIG
|
|
|
|
#undef SKIP_BIG_TESTS
|
|
|
|
#define SKIP_BIG_TESTS(X) /* no-op */
|
|
|
|
#endif
|
|
|
|
|
2011-05-13 15:22:05 +02:00
|
|
|
static const char *base_file1_name= "page_cache_test_file_1";
|
|
|
|
static const char *base_file2_name= "page_cache_test_file_2";
|
|
|
|
static char file1_name[FN_REFLEN], file2_name[FN_REFLEN];
|
2006-07-06 10:10:34 +02:00
|
|
|
static PAGECACHE_FILE file1;
|
|
|
|
static pthread_cond_t COND_thread_count;
|
|
|
|
static pthread_mutex_t LOCK_thread_count;
|
|
|
|
static uint thread_count;
|
|
|
|
static PAGECACHE pagecache;
|
|
|
|
|
|
|
|
/*
|
|
|
|
File contance descriptors
|
|
|
|
*/
|
|
|
|
static struct file_desc simple_read_write_test_file[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\1'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
|
|
|
static struct file_desc simple_read_change_write_read_test_file[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE/2, '\65'},
|
|
|
|
{ TEST_PAGE_SIZE/2, '\1'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
|
|
|
static struct file_desc simple_pin_test_file1[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE*2, '\1'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
|
|
|
static struct file_desc simple_pin_test_file2[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE/2, '\1'},
|
|
|
|
{ TEST_PAGE_SIZE/2, (unsigned char)129},
|
|
|
|
{ TEST_PAGE_SIZE, '\1'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
2008-01-08 21:18:59 +01:00
|
|
|
static struct file_desc simple_pin_no_lock_test_file1[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\4'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
static struct file_desc simple_pin_no_lock_test_file2[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\5'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
static struct file_desc simple_pin_no_lock_test_file3[]=
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\6'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
static struct file_desc simple_delete_forget_test_file[]=
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\1'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
2008-01-08 21:18:59 +01:00
|
|
|
static struct file_desc simple_delete_flush_test_file[]=
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
{ TEST_PAGE_SIZE, '\2'},
|
2008-01-08 21:18:59 +01:00
|
|
|
{0, 0}
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
|
|
|
|
2007-12-20 11:24:03 +01:00
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
/*
|
|
|
|
Recreate and reopen a file for test
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
reset_file()
|
|
|
|
file File to reset
|
|
|
|
file_name Path (and name) of file which should be reset
|
|
|
|
*/
|
|
|
|
|
2007-12-04 22:23:42 +01:00
|
|
|
void reset_file(PAGECACHE_FILE *file, const char *file_name)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
2007-12-04 22:23:42 +01:00
|
|
|
flush_pagecache_blocks(&pagecache, file, FLUSH_RELEASE);
|
|
|
|
if (my_close(file->file, MYF(MY_WME)))
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
2007-12-04 22:23:42 +01:00
|
|
|
my_delete(file_name, MYF(MY_WME));
|
|
|
|
if ((file->file= my_open(file_name,
|
|
|
|
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
diag("Got error during %s creation from open() (errno: %d)\n",
|
2007-12-04 22:23:42 +01:00
|
|
|
file_name, my_errno);
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Write then read page, check file on disk
|
|
|
|
*/
|
|
|
|
|
|
|
|
int simple_read_write_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
|
|
|
unsigned char *buffr= malloc(TEST_PAGE_SIZE);
|
2006-07-06 10:10:34 +02:00
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_read_write_test");
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, 0, 3, buffr,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
0);
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(memcmp(buffr, buffw, TEST_PAGE_SIZE) == 0)),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple write-read page ");
|
2007-12-01 13:50:47 +01:00
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error during flushing pagecache\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res&= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_read_write_test_file))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple write-read page file");
|
|
|
|
if (res)
|
2007-12-04 22:23:42 +01:00
|
|
|
reset_file(&file1, file1_name);
|
2006-07-06 10:10:34 +02:00
|
|
|
free(buffw);
|
|
|
|
free(buffr);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Prepare page, then read (and lock), change (write new value and unlock),
|
|
|
|
then check the page in the cache and on the disk
|
|
|
|
*/
|
|
|
|
int simple_read_change_write_read_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
|
|
|
unsigned char *buffr= malloc(TEST_PAGE_SIZE);
|
2007-12-04 22:23:42 +01:00
|
|
|
int res, res2;
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_ENTER("simple_read_change_write_read_test");
|
2007-12-04 22:23:42 +01:00
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
/* prepare the file */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2007-12-01 13:50:47 +01:00
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error during flushing pagecache\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2006-07-06 10:10:34 +02:00
|
|
|
/* test */
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE,
|
|
|
|
0);
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE/2, '\65');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE_UNLOCK,
|
|
|
|
PAGECACHE_UNPIN,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, 0, 3, buffr,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
0);
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(memcmp(buffr, buffw, TEST_PAGE_SIZE) == 0)),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple read-change-write-read page ");
|
2007-12-04 22:23:42 +01:00
|
|
|
DBUG_ASSERT(pagecache.blocks_changed == 1);
|
2007-12-01 13:50:47 +01:00
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error during flushing pagecache\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-12-04 22:23:42 +01:00
|
|
|
DBUG_ASSERT(pagecache.blocks_changed == 0);
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res2= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_read_change_write_read_test_file))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple read-change-write-read page file");
|
2007-12-04 22:23:42 +01:00
|
|
|
if (res && res2)
|
|
|
|
reset_file(&file1, file1_name);
|
2006-07-06 10:10:34 +02:00
|
|
|
free(buffw);
|
|
|
|
free(buffr);
|
2007-12-04 22:23:42 +01:00
|
|
|
DBUG_RETURN(res && res2);
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Prepare page, read page 0 (and pin) then write page 1 and page 0.
|
2010-06-15 23:39:28 +02:00
|
|
|
Flush the file (should flush only page 1 and return 1 (page 0 is
|
2006-07-06 10:10:34 +02:00
|
|
|
still pinned).
|
|
|
|
Check file on the disk.
|
|
|
|
Unpin and flush.
|
|
|
|
Check file on the disk.
|
|
|
|
*/
|
|
|
|
int simple_pin_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
2006-07-06 10:10:34 +02:00
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_pin_test");
|
|
|
|
/* prepare the file */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
/* test */
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
2007-12-01 13:50:47 +01:00
|
|
|
diag("Got error during flushing pagecache\n");
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE,
|
|
|
|
0);
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 1, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw + TEST_PAGE_SIZE/2, TEST_PAGE_SIZE/2, ((unsigned char) 129));
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
2010-06-15 23:39:28 +02:00
|
|
|
PAGECACHE_LOCK_LEFT_WRITELOCKED,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PIN_LEFT_PINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
/*
|
|
|
|
We have to get error because one page of the file is pinned,
|
|
|
|
other page should be flushed
|
|
|
|
*/
|
|
|
|
if (!flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Did not get error in flush_pagecache_blocks\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE * 2,
|
|
|
|
TEST_PAGE_SIZE * 2, simple_pin_test_file1))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple pin page file with pin");
|
2007-04-12 10:35:05 +02:00
|
|
|
pagecache_unlock(&pagecache,
|
|
|
|
&file1,
|
|
|
|
0,
|
2010-06-15 23:39:28 +02:00
|
|
|
PAGECACHE_LOCK_WRITE_UNLOCK,
|
2007-04-12 10:35:05 +02:00
|
|
|
PAGECACHE_UNPIN,
|
First part of redo/undo for key pages
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
For transactional tables, shift record number in keys up with 1 bit to have place to indicate if transid follows
Checksum for MyISAM now ignores NULL and not used part of VARCHAR
Renamed some variables that caused shadow compiler warnings
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
Fixed crashing bugs when using Maria TEMPORARY tables with TRUNCATE. Removed 'hack' code in sql directory to go around this bug.
pagecache_unlock_by_ulink() now has extra argument to say if page was changed.
Give error message if we fail to open control file
Mark page cache variables as not flushable
include/maria.h:
Made min page cache larger (needed for pinning key page)
Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
Added write_comp_flag to move some runtime code to maria_open()
include/my_base.h:
Added new error message to be used when handler initialization failed
include/my_global.h:
Renamed dummy to swap_dummy to avoid conflicts with local 'dummy' variables
include/my_handler.h:
Added const to some parameters
mysys/array.c:
More DBUG
mysys/my_error.c:
Fixed indentation
mysys/my_handler.c:
Added const to some parameters
Added missing error messages
sql/field.h:
Renamed variables to avoid variable shadowing
sql/handler.h:
Renamed parameter to avoid variable name conflict
sql/item.h:
Renamed variables to avoid variable shadowing
sql/log_event_old.h:
Renamed variables to avoid variable shadowing
sql/set_var.h:
Renamed variables to avoid variable shadowing
sql/sql_delete.cc:
Removed maria hack for temporary tables
Fixed indentation
sql/sql_table.cc:
Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
This was needed to ensure we don't do a PREPARE_FOR_DROP or similar call while the table is still in use.
sql/table.cc:
Copy page_checksum from share
Removed Maria hack
storage/maria/Makefile.am:
Added new files
storage/maria/ha_maria.cc:
Renamed records -> record_count and info -> create_info to avoid variable name conflicts
Mark page cache variables as not flushable
storage/maria/ma_blockrec.c:
Moved _ma_unpin_all_pages() to ma_key_recover.c
Moved init of info->pinned_pages to ma_open.c
Moved _ma_finalize_row() to maria_key_recover.h
Renamed some variables to avoid variable name conflicts
Mark page_link.changed for blocks we change directly
Simplify handling of undo link when writing LOGREC_UNDO_ROW_INSERT (old code crashed when having redo for index)
storage/maria/ma_blockrec.h:
Removed extra empty line
storage/maria/ma_checkpoint.c:
Remove not needed trnman.h
storage/maria/ma_close.c:
Free pinned pages (which are now always allocated)
storage/maria/ma_control_file.c:
Give error message if we fail to open control file
storage/maria/ma_delete.c:
Changes for redo logging (first part, logging of underflow not yet done)
- Log undo-key-delete
- Log delete of key
- Updated arguments to _ma_fetch_keypage(), _ma_dispose(), _ma_write_keypage(), _ma_insert()
- Added new arguments to some functions to be able to write redo information
- Mark key pages as changed when we write with PAGECACHE_LOCK_LEFT_WRITELOCKED
Remove one not needed _ma_write_keypage() in d_search() when upper level will do the write anyway
Changed 2 bmove_upp() to bmove() as this made code easer to understand
More function comments
Indentation fixes
storage/maria/ma_ft_update.c:
New arguments to _ma_write_keypage()
storage/maria/ma_loghandler.c:
Fixed some DBUG_PRINT messages
Simplify code
Added new log entrys for key page redo
Renamed some variables to avoid variable name shadowing
storage/maria/ma_loghandler.h:
Moved some defines here
Added define for storing key number on key pages
Added new translog record types
Added enum for type of operations in LOGREC_REDO_INDEX
storage/maria/ma_open.c:
Always allocate info.pinned_pages (we need now also for normal key page usage)
Update keyinfo->key_nr
Added virtual functions to convert record position o number to be stored on key pages
Update keyinfo->write_comp_flag to value of search flag to be used when writing key
storage/maria/ma_page.c:
Added redo for key pages
- Extended _ma_fetch_keypage() with type of lock to put on page and address to used MARIA_PINNED_PAGE
- _ma_fetch_keypage() now pin's pages if needed
- Extended _ma_write_keypage() with type of locks to be used
- ma_dispose() now locks info->s->state.key_del from other threads
- ma_dispose() writes redo log record
- ma_new() locks info->s->state.key_del from other threads if it was used
- ma_new() now pins read page
Other things:
- Removed some not needed arguments from _ma_new() and _ma_dispose)
- Added some new variables to simplify code
- If EXTRA_DEBUG is used, do crc on full page to catch not unitialized bytes
storage/maria/ma_pagecache.h:
Applied patch from Sanja to add extra argument to pagecache_unlock_by_ulink() to mark if page was changed
Added some defines for pagecache priority levels that one can use
storage/maria/ma_range.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_recovery.c:
- Added hooks for new translog types:
REDO_INDEX, REDO_INDEX_NEW_PAGE, REDO_INDEX_FREE_PAGE, UNDO_KEY_INSERT, UNDO_KEY_DELETE and
UNDO_KEY_DELETE_WITH_ROOT.
- Moved variable declarations to start of function (portability fixes)
- Removed some not needed initializations
- Set only relevant state changes for each redo/undo entry
storage/maria/lockman.c:
Removed end space
storage/maria/ma_check.c:
Removed end space
storage/maria/ma_create.c:
Removed end space
storage/maria/ma_locking.c:
Removed end space
storage/maria/ma_packrec.c:
Removed end space
storage/maria/ma_pagecache.c:
Removed end space
storage/maria/ma_panic.c:
Removed end space
storage/maria/ma_rt_index.c:
Added new arguments for call to _ma_fetch_keypage(), _ma_write_keypage(), _ma_dispose() and _ma_new()
Fixed indentation
storage/maria/ma_rt_key.c:
Added new arguments for call to _ma_fetch_keypage()
storage/maria/ma_rt_split.c:
Added new arguments for call to _ma_new()
Use new keypage header
Added new arguments for call to _ma_write_keypage()
storage/maria/ma_search.c:
Updated comments & indentation
Added new arguments for call to _ma_fetch_keypage()
Made some variables and arguments const
Added virtual functions for converting row position to number to be stored in key
use MARIA_RECORD_POS of record position instead of my_off_t
Record in MARIA_KEY_PARAM how page was changed one key insert (needed for REDO)
storage/maria/ma_sort.c:
Removed end space
storage/maria/ma_statrec.c:
Updated arguments for call to _ma_rec_pos()
storage/maria/ma_test1.c:
Fixed too small buffer to init_pagecache()
Fixed bug when using insert_count and test_flag
storage/maria/ma_test2.c:
Use more resonable pagecache size
Remove not used code
Reset blob_length to fix wrong output message
storage/maria/ma_test_all.sh:
Fixed wrong test
storage/maria/ma_write.c:
Lots of new code to handle REDO of key pages
No logic changes because of REDO code, mostly adding new arguments and adding new code for logging
Added new arguments for calls to _ma_fetch_keypage(), _ma_write_keypage() and similar functions
Move setting of comp_flag in ma_ck_wrte_btree() from runtime to maria_open()
Zerofill new used pages for:
- To remove possible sensitive data left in buffer
- To get idenitical data on pages after running redo
- Better compression of pages if archived
storage/maria/maria_chk.c:
Added information if table is crash safe
storage/maria/maria_def.h:
New virtual function to convert between record position on key and normal record position
Aded mutex and extra variables to handle locking of share->state.key_del
Moved some structure variables to get things more aligned
Added extra arguments to MARIA_KEY_PARAM to be able to remember what was changed on key page on key insert
Added argument to MARIA_PINNED_PAGE to indicate if page was changed
Updated prototypes for functions
Added some structures for signaling changes in REDO handling
storage/maria/unittest/ma_pagecache_single.c:
Updated arguments for changed function calls
storage/myisam/mi_check.c:
Made calc_check_checksum virtual
storage/myisam/mi_checksum.c:
Update checksums to ignore null columns
storage/myisam/mi_create.c:
Mark if table has null column (to know when we have to use mi_checksum())
storage/myisam/mi_open.c:
Added virtual function for calculating checksum to be able to easily ignore NULL fields
storage/myisam/mi_test2.c:
Fixed bug
storage/myisam/myisamdef.h:
Added virtual function for calculating checksum during check table
Removed ha_key_cmp() as this is in handler.h
storage/maria/ma_key_recover.c:
New BitKeeper file ``storage/maria/ma_key_recover.c''
storage/maria/ma_key_recover.h:
New BitKeeper file ``storage/maria/ma_key_recover.h''
storage/maria/ma_key_redo.c:
New BitKeeper file ``storage/maria/ma_key_redo.c''
2007-11-14 18:08:06 +01:00
|
|
|
0, 0, 0);
|
2006-07-06 10:10:34 +02:00
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error in flush_pagecache_blocks\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res&= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE * 2,
|
|
|
|
TEST_PAGE_SIZE, simple_pin_test_file2))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple pin page result file");
|
|
|
|
if (res)
|
2007-12-04 22:23:42 +01:00
|
|
|
reset_file(&file1, file1_name);
|
2006-07-06 10:10:34 +02:00
|
|
|
err:
|
|
|
|
free(buffw);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
2010-06-15 23:39:28 +02:00
|
|
|
/*
|
|
|
|
Prepare page, read page 0 (and pin) then write page 1 and page 0.
|
|
|
|
Flush the file (should flush only page 1 and return 1 (page 0 is
|
|
|
|
still pinned).
|
|
|
|
Check file on the disk.
|
|
|
|
Unpin and flush.
|
|
|
|
Check file on the disk.
|
|
|
|
*/
|
|
|
|
int simple_pin_test2()
|
|
|
|
{
|
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_pin_test2");
|
|
|
|
/* prepare the file */
|
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
0, LSN_IMPOSSIBLE);
|
|
|
|
/* test */
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error during flushing pagecache\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
pagecache_read(&pagecache, &file1, 0, 3, buffw,
|
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE,
|
|
|
|
0);
|
|
|
|
pagecache_write(&pagecache, &file1, 1, 3, buffw,
|
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
0, LSN_IMPOSSIBLE);
|
|
|
|
bfill(buffw + TEST_PAGE_SIZE/2, TEST_PAGE_SIZE/2, ((unsigned char) 129));
|
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE_TO_READ,
|
|
|
|
PAGECACHE_PIN_LEFT_PINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
0, LSN_IMPOSSIBLE);
|
|
|
|
/*
|
|
|
|
We have to get error because one page of the file is pinned,
|
|
|
|
other page should be flushed
|
|
|
|
*/
|
|
|
|
if (!flush_pagecache_blocks(&pagecache, &file1, FLUSH_KEEP_LAZY))
|
|
|
|
{
|
|
|
|
diag("Did not get error in flush_pagecache_blocks 2\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE * 2,
|
|
|
|
TEST_PAGE_SIZE * 2, simple_pin_test_file1))),
|
2010-06-15 23:39:28 +02:00
|
|
|
"Simple pin page file with pin 2");
|
|
|
|
|
|
|
|
/* Test that a normal flush goes through */
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error in flush_pagecache_blocks 3\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
pagecache_unlock(&pagecache,
|
|
|
|
&file1,
|
|
|
|
0,
|
|
|
|
PAGECACHE_LOCK_READ_UNLOCK,
|
|
|
|
PAGECACHE_UNPIN,
|
|
|
|
0, 0, 0);
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error in flush_pagecache_blocks 4\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res&= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE * 2,
|
|
|
|
TEST_PAGE_SIZE, simple_pin_test_file2))),
|
2010-06-15 23:39:28 +02:00
|
|
|
"Simple pin page result file 2");
|
|
|
|
if (res)
|
|
|
|
reset_file(&file1, file1_name);
|
|
|
|
err:
|
|
|
|
free(buffw);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
2008-01-08 21:18:59 +01:00
|
|
|
/*
|
|
|
|
Checks pins without lock.
|
|
|
|
*/
|
|
|
|
int simple_pin_no_lock_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
2008-01-08 21:18:59 +01:00
|
|
|
PAGECACHE_BLOCK_LINK *link;
|
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_pin_no_lock_test");
|
|
|
|
/* prepare the file */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\4');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2008-01-08 21:18:59 +01:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
0, LSN_IMPOSSIBLE);
|
|
|
|
/* test */
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error during flushing pagecache 2\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\5');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2008-01-08 21:18:59 +01:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
0, LSN_IMPOSSIBLE);
|
|
|
|
/*
|
|
|
|
We have to get error because one page of the file is pinned,
|
|
|
|
other page should be flushed
|
|
|
|
*/
|
2010-06-15 23:39:28 +02:00
|
|
|
if (!flush_pagecache_blocks(&pagecache, &file1, FLUSH_KEEP_LAZY))
|
2008-01-08 21:18:59 +01:00
|
|
|
{
|
|
|
|
diag("Did not get error in flush_pagecache_blocks 2\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_pin_no_lock_test_file1))),
|
2008-01-08 21:18:59 +01:00
|
|
|
"Simple pin (no lock) page file with pin 2");
|
|
|
|
pagecache_unlock(&pagecache,
|
|
|
|
&file1,
|
|
|
|
0,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_UNPIN,
|
|
|
|
0, 0, 0);
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error in flush_pagecache_blocks 2\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res&= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_pin_no_lock_test_file2))),
|
2008-01-08 21:18:59 +01:00
|
|
|
"Simple pin (no lock) page result file 2");
|
|
|
|
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\6');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2008-01-08 21:18:59 +01:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE,
|
|
|
|
PAGECACHE_PIN,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
&link, LSN_IMPOSSIBLE);
|
|
|
|
pagecache_unlock_by_link(&pagecache, link,
|
|
|
|
PAGECACHE_LOCK_WRITE_UNLOCK,
|
2008-10-14 17:18:14 +02:00
|
|
|
PAGECACHE_PIN_LEFT_PINNED, 0, 0, 1, FALSE);
|
2010-06-15 23:39:28 +02:00
|
|
|
if (!flush_pagecache_blocks(&pagecache, &file1, FLUSH_KEEP_LAZY))
|
2008-01-08 21:18:59 +01:00
|
|
|
{
|
|
|
|
diag("Did not get error in flush_pagecache_blocks 3\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_pin_no_lock_test_file2))),
|
2008-01-08 21:18:59 +01:00
|
|
|
"Simple pin (no lock) page file with pin 3");
|
|
|
|
pagecache_unpin_by_link(&pagecache, link, 0);
|
|
|
|
if (flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE))
|
|
|
|
{
|
|
|
|
diag("Got error in flush_pagecache_blocks 3\n");
|
|
|
|
res= 0;
|
|
|
|
goto err;
|
|
|
|
}
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res&= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_pin_no_lock_test_file3))),
|
2008-01-08 21:18:59 +01:00
|
|
|
"Simple pin (no lock) page result file 3");
|
|
|
|
if (res)
|
|
|
|
reset_file(&file1, file1_name);
|
|
|
|
err:
|
|
|
|
free(buffw);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
2006-07-06 10:10:34 +02:00
|
|
|
/*
|
|
|
|
Prepare page, write new value, then delete page from cache without flush,
|
|
|
|
on the disk should be page with old content written during preparation
|
|
|
|
*/
|
|
|
|
|
|
|
|
int simple_delete_forget_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
|
|
|
unsigned char *buffr= malloc(TEST_PAGE_SIZE);
|
2006-07-06 10:10:34 +02:00
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_delete_forget_test");
|
|
|
|
/* prepare the file */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
|
|
|
/* test */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\2');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2007-04-12 10:35:05 +02:00
|
|
|
pagecache_delete(&pagecache, &file1, 0,
|
|
|
|
PAGECACHE_LOCK_WRITE, 0);
|
2006-07-06 10:10:34 +02:00
|
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_delete_forget_test_file))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple delete-forget page file");
|
|
|
|
if (res)
|
2007-12-04 22:23:42 +01:00
|
|
|
reset_file(&file1, file1_name);
|
2006-07-06 10:10:34 +02:00
|
|
|
free(buffw);
|
|
|
|
free(buffr);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Prepare page with locking, write new content to the page,
|
|
|
|
delete page with flush and on existing lock,
|
|
|
|
check that page on disk contain new value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int simple_delete_flush_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= malloc(TEST_PAGE_SIZE);
|
|
|
|
unsigned char *buffr= malloc(TEST_PAGE_SIZE);
|
2008-01-30 13:33:36 +01:00
|
|
|
PAGECACHE_BLOCK_LINK *link;
|
2006-07-06 10:10:34 +02:00
|
|
|
int res;
|
|
|
|
DBUG_ENTER("simple_delete_flush_test");
|
|
|
|
/* prepare the file */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\1');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_WRITE,
|
|
|
|
PAGECACHE_PIN,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2008-01-30 13:33:36 +01:00
|
|
|
&link, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
|
|
|
/* test */
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, '\2');
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, 0, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_WRITELOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_PINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2008-01-30 13:33:36 +01:00
|
|
|
if (pagecache_delete_by_link(&pagecache, link,
|
|
|
|
PAGECACHE_LOCK_LEFT_WRITELOCKED, 1))
|
|
|
|
{
|
|
|
|
diag("simple_delete_flush_test: error during delete");
|
|
|
|
exit(1);
|
|
|
|
}
|
2006-07-06 10:10:34 +02:00
|
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, TEST_PAGE_SIZE, TEST_PAGE_SIZE,
|
|
|
|
simple_delete_flush_test_file))),
|
2008-01-30 13:33:36 +01:00
|
|
|
"Simple delete flush (link) page file");
|
2006-07-06 10:10:34 +02:00
|
|
|
if (res)
|
2007-12-04 22:23:42 +01:00
|
|
|
reset_file(&file1, file1_name);
|
2006-07-06 10:10:34 +02:00
|
|
|
free(buffw);
|
|
|
|
free(buffr);
|
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
write then read file bigger then cache
|
|
|
|
*/
|
|
|
|
|
|
|
|
int simple_big_test()
|
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
unsigned char *buffw= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME));
|
|
|
|
unsigned char *buffr= (unsigned char *) my_malloc(TEST_PAGE_SIZE, MYF(MY_WME));
|
2007-12-04 22:23:42 +01:00
|
|
|
struct file_desc *desc= ((struct file_desc *)
|
2008-02-13 20:27:12 +01:00
|
|
|
my_malloc((PCACHE_SIZE/(TEST_PAGE_SIZE/2) + 1) *
|
2007-12-04 22:23:42 +01:00
|
|
|
sizeof(struct file_desc), MYF(MY_WME)));
|
2006-07-06 10:10:34 +02:00
|
|
|
int res, i;
|
|
|
|
DBUG_ENTER("simple_big_test");
|
2007-12-04 22:23:42 +01:00
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
/* prepare the file twice larger then cache */
|
2008-02-13 20:27:12 +01:00
|
|
|
for (i= 0; i < PCACHE_SIZE/(TEST_PAGE_SIZE/2); i++)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
2008-02-13 20:27:12 +01:00
|
|
|
bfill(buffw, TEST_PAGE_SIZE, (unsigned char) (i & 0xff));
|
|
|
|
desc[i].length= TEST_PAGE_SIZE;
|
2006-07-06 10:10:34 +02:00
|
|
|
desc[i].content= (i & 0xff);
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_write(&pagecache, &file1, i, 3, buffw,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
2007-11-05 14:07:50 +01:00
|
|
|
0, LSN_IMPOSSIBLE);
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
2007-02-02 08:41:32 +01:00
|
|
|
desc[i].length= 0;
|
2007-02-12 13:23:43 +01:00
|
|
|
desc[i].content= '\0';
|
2006-07-06 10:10:34 +02:00
|
|
|
ok(1, "Simple big file write");
|
|
|
|
/* check written pages sequentally read */
|
2008-02-13 20:27:12 +01:00
|
|
|
for (i= 0; i < PCACHE_SIZE/(TEST_PAGE_SIZE/2); i++)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
int j;
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, i, 3, buffr,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
0);
|
2008-02-13 20:27:12 +01:00
|
|
|
for(j= 0; j < TEST_PAGE_SIZE; j++)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
if (buffr[j] != (i & 0xff))
|
|
|
|
{
|
|
|
|
diag("simple_big_test seq: page %u byte %u mismatch\n", i, j);
|
2007-12-04 22:23:42 +01:00
|
|
|
res= 0;
|
|
|
|
goto err;
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
ok(1, "Simple big file sequential read");
|
2006-07-06 10:10:34 +02:00
|
|
|
/* chack random reads */
|
2008-02-13 20:27:12 +01:00
|
|
|
for (i= 0; i < PCACHE_SIZE/(TEST_PAGE_SIZE); i++)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
int j, page;
|
2008-02-13 20:27:12 +01:00
|
|
|
page= rand() % (PCACHE_SIZE/(TEST_PAGE_SIZE/2));
|
2008-02-07 21:46:32 +01:00
|
|
|
pagecache_read(&pagecache, &file1, page, 3, buffr,
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
|
|
0);
|
2008-02-13 20:27:12 +01:00
|
|
|
for(j= 0; j < TEST_PAGE_SIZE; j++)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
if (buffr[j] != (page & 0xff))
|
|
|
|
{
|
|
|
|
diag("simple_big_test rnd: page %u byte %u mismatch\n", page, j);
|
2007-12-04 22:23:42 +01:00
|
|
|
res= 0;
|
|
|
|
goto err;
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
ok(1, "Simple big file random read");
|
2006-07-06 10:10:34 +02:00
|
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
|
|
|
|
2014-02-19 11:05:15 +01:00
|
|
|
ok((res= MY_TEST(test_file(file1, file1_name, PCACHE_SIZE * 2, TEST_PAGE_SIZE,
|
|
|
|
desc))),
|
2006-07-06 10:10:34 +02:00
|
|
|
"Simple big file");
|
|
|
|
if (res)
|
2007-12-04 22:23:42 +01:00
|
|
|
reset_file(&file1, file1_name);
|
|
|
|
|
|
|
|
err:
|
2011-04-25 17:22:25 +02:00
|
|
|
my_free(buffw);
|
|
|
|
my_free(buffr);
|
|
|
|
my_free(desc);
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_RETURN(res);
|
|
|
|
}
|
2007-12-04 22:23:42 +01:00
|
|
|
|
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
/*
|
|
|
|
Thread function
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void *test_thread(void *arg)
|
|
|
|
{
|
2007-06-09 13:52:17 +02:00
|
|
|
#ifndef DBUG_OFF
|
|
|
|
int param= *((int*) arg);
|
|
|
|
#endif
|
2006-07-06 10:10:34 +02:00
|
|
|
|
|
|
|
my_thread_init();
|
2008-01-10 13:21:53 +01:00
|
|
|
{
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_ENTER("test_thread");
|
|
|
|
DBUG_PRINT("enter", ("param: %d", param));
|
|
|
|
|
|
|
|
if (!simple_read_write_test() ||
|
|
|
|
!simple_read_change_write_read_test() ||
|
|
|
|
!simple_pin_test() ||
|
2010-06-15 23:39:28 +02:00
|
|
|
!simple_pin_test2() ||
|
2008-01-08 21:18:59 +01:00
|
|
|
!simple_pin_no_lock_test() ||
|
2006-07-06 10:10:34 +02:00
|
|
|
!simple_delete_forget_test() ||
|
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
|
|
|
!simple_delete_flush_test())
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
|
|
|
|
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
|
|
|
SKIP_BIG_TESTS(4)
|
|
|
|
{
|
|
|
|
if (!simple_big_test())
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_PRINT("info", ("Thread %s ended\n", my_thread_name()));
|
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
|
|
|
thread_count--;
|
2011-04-25 17:22:25 +02:00
|
|
|
pthread_cond_signal(&COND_thread_count); /* Tell main we are ready */
|
2006-07-06 10:10:34 +02:00
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2007-07-02 19:45:15 +02:00
|
|
|
free((uchar*) arg);
|
2006-07-06 10:10:34 +02:00
|
|
|
my_thread_end();
|
|
|
|
DBUG_RETURN(0);
|
2008-01-10 13:21:53 +01:00
|
|
|
}
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-13 15:22:05 +02:00
|
|
|
static char *create_tmpdir(const char *progname)
|
|
|
|
{
|
|
|
|
static char test_dirname[FN_REFLEN];
|
|
|
|
char tmp_name[FN_REFLEN];
|
|
|
|
uint length;
|
|
|
|
|
|
|
|
/* Create a temporary directory of name TMP-'executable', but without the -t extension */
|
|
|
|
fn_format(tmp_name, progname, "", "", MY_REPLACE_DIR | MY_REPLACE_EXT);
|
|
|
|
length= strlen(tmp_name);
|
|
|
|
if (length > 2 && tmp_name[length-2] == '-' && tmp_name[length-1] == 't')
|
|
|
|
tmp_name[length-2]= 0;
|
|
|
|
strxmov(test_dirname, "TMP-", tmp_name, NullS);
|
|
|
|
|
|
|
|
/*
|
|
|
|
Don't give an error if we can't create dir, as it may already exist from a previously aborted
|
|
|
|
run
|
|
|
|
*/
|
|
|
|
(void) my_mkdir(test_dirname, 0777, MYF(0));
|
|
|
|
return test_dirname;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-09 13:52:17 +02:00
|
|
|
int main(int argc __attribute__((unused)),
|
|
|
|
char **argv __attribute__((unused)))
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
pthread_t tid;
|
|
|
|
pthread_attr_t thr_attr;
|
|
|
|
int *param, error, pagen;
|
2007-12-04 22:23:42 +01:00
|
|
|
File tmp_file;
|
2006-07-06 10:10:34 +02:00
|
|
|
MY_INIT(argv[0]);
|
|
|
|
|
|
|
|
#ifndef DBUG_OFF
|
|
|
|
#if defined(__WIN__)
|
|
|
|
default_dbug_option= "d:t:i:O,\\test_pagecache_single.trace";
|
|
|
|
#else
|
|
|
|
default_dbug_option= "d:t:i:o,/tmp/test_pagecache_single.trace";
|
|
|
|
#endif
|
|
|
|
if (argc > 1)
|
|
|
|
{
|
|
|
|
DBUG_SET(default_dbug_option);
|
|
|
|
DBUG_SET_INITIAL(default_dbug_option);
|
|
|
|
}
|
|
|
|
#endif
|
2008-01-10 13:21:53 +01:00
|
|
|
{
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_ENTER("main");
|
|
|
|
DBUG_PRINT("info", ("Main thread: %s\n", my_thread_name()));
|
2008-01-29 18:15:38 +01:00
|
|
|
|
2010-06-15 23:39:28 +02:00
|
|
|
plan(18);
|
|
|
|
SKIP_BIG_TESTS(18)
|
2008-01-29 18:15:38 +01:00
|
|
|
{
|
2011-05-13 15:22:05 +02:00
|
|
|
char *test_dirname= create_tmpdir(argv[0]);
|
|
|
|
fn_format(file1_name, base_file1_name, test_dirname, "", MYF(0));
|
|
|
|
fn_format(file2_name, base_file2_name, test_dirname, "", MYF(0));
|
2008-01-29 18:15:38 +01:00
|
|
|
|
2007-12-04 22:23:42 +01:00
|
|
|
if ((tmp_file= my_open(file2_name, O_CREAT | O_TRUNC | O_RDWR,
|
|
|
|
MYF(MY_WME))) < 0)
|
|
|
|
exit(1);
|
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
if ((file1.file= my_open(file1_name,
|
|
|
|
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error during file1 creation from open() (errno: %d)\n",
|
|
|
|
errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2014-12-22 15:53:17 +01:00
|
|
|
pagecache_file_set_null_hooks(&file1);
|
2007-12-04 22:23:42 +01:00
|
|
|
my_close(tmp_file, MYF(0));
|
|
|
|
my_delete(file2_name, MYF(0));
|
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_PRINT("info", ("file1: %d", file1.file));
|
2011-10-21 23:07:13 +02:00
|
|
|
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
2008-02-07 21:46:32 +01:00
|
|
|
my_pwrite(file1.file, (const uchar*)"test file", 9, 0, MYF(MY_WME));
|
2006-07-06 10:10:34 +02:00
|
|
|
|
|
|
|
if ((error= pthread_cond_init(&COND_thread_count, NULL)))
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: %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, "Got error: %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);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_THR_SETCONCURRENCY
|
2011-04-25 17:22:25 +02:00
|
|
|
thr_setconcurrency(2);
|
2006-07-06 10:10:34 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
|
2014-07-19 16:46:08 +02:00
|
|
|
TEST_PAGE_SIZE, 0, MYF(MY_WME))) == 0)
|
2006-07-06 10:10:34 +02:00
|
|
|
{
|
|
|
|
fprintf(stderr,"Got error: init_pagecache() (errno: %d)\n",
|
|
|
|
errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
DBUG_PRINT("info", ("Page cache %d pages", pagen));
|
|
|
|
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
2006-07-06 10:10:34 +02:00
|
|
|
param=(int*) malloc(sizeof(int));
|
|
|
|
*param= 1;
|
|
|
|
if ((error= pthread_create(&tid, &thr_attr, test_thread, (void*) param)))
|
|
|
|
{
|
|
|
|
fprintf(stderr,"Got error: %d from pthread_create (errno: %d)\n",
|
|
|
|
error,errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
thread_count++;
|
|
|
|
DBUG_PRINT("info", ("Thread started"));
|
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
|
|
|
|
|
|
|
pthread_attr_destroy(&thr_attr);
|
|
|
|
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_lock(&LOCK_thread_count);
|
2006-07-06 10:10:34 +02:00
|
|
|
while (thread_count)
|
|
|
|
{
|
|
|
|
if ((error= pthread_cond_wait(&COND_thread_count,&LOCK_thread_count)))
|
|
|
|
fprintf(stderr,"Got error: %d from pthread_cond_wait\n",error);
|
|
|
|
}
|
2008-01-03 08:45:46 +01:00
|
|
|
pthread_mutex_unlock(&LOCK_thread_count);
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_PRINT("info", ("thread ended"));
|
|
|
|
|
|
|
|
end_pagecache(&pagecache, 1);
|
|
|
|
DBUG_PRINT("info", ("Page cache ended"));
|
|
|
|
|
2007-12-04 22:23:42 +01:00
|
|
|
if (my_close(file1.file, MYF(MY_WME)))
|
2006-07-06 10:10:34 +02:00
|
|
|
exit(1);
|
2007-12-04 22:23:42 +01:00
|
|
|
|
2008-01-07 17:54:41 +01:00
|
|
|
my_delete(file1_name, MYF(0));
|
2011-05-13 15:22:05 +02:00
|
|
|
rmdir(test_dirname);
|
2006-07-06 10:10:34 +02:00
|
|
|
|
2008-01-29 18:15:38 +01:00
|
|
|
} /* SKIP_BIG_TESTS */
|
2006-07-06 10:10:34 +02:00
|
|
|
DBUG_PRINT("info", ("file1 (%d) closed", file1.file));
|
|
|
|
DBUG_PRINT("info", ("Program end"));
|
|
|
|
|
2008-01-29 18:15:38 +01:00
|
|
|
my_end(0);
|
2008-01-10 13:21:53 +01:00
|
|
|
}
|
2008-01-29 18:15:38 +01:00
|
|
|
return exit_status();
|
2006-07-06 10:10:34 +02:00
|
|
|
}
|
2011-04-25 17:22:25 +02:00
|
|
|
|
|
|
|
#include "../ma_check_standalone.h"
|