2006-07-06 10:10:34 +02:00
|
|
|
/* Copyright (C) 2006 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; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
/* Page cache variable structures */
|
|
|
|
|
2007-06-11 16:29:53 +02:00
|
|
|
#ifndef _ma_pagecache_h
|
|
|
|
#define _ma_pagecache_h
|
2006-07-06 10:10:34 +02:00
|
|
|
C_MODE_START
|
|
|
|
|
2007-06-11 16:29:53 +02:00
|
|
|
#include "ma_loghandler_lsn.h"
|
2007-02-12 13:23:43 +01:00
|
|
|
#include <m_string.h>
|
2007-02-02 08:41:32 +01:00
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
/* Type of the page */
|
|
|
|
enum pagecache_page_type
|
|
|
|
{
|
2007-06-04 13:07:18 +02:00
|
|
|
/*
|
|
|
|
Used only for control page type changing during debugging. This define
|
|
|
|
should only be using when using DBUG.
|
|
|
|
*/
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_EMPTY_PAGE,
|
|
|
|
/* the page does not contain LSN */
|
|
|
|
PAGECACHE_PLAIN_PAGE,
|
|
|
|
/* the page contain LSN (maria tablespace page) */
|
2007-07-01 15:20:57 +02:00
|
|
|
PAGECACHE_LSN_PAGE,
|
|
|
|
/* Page type used when scanning file and we don't care about the type */
|
|
|
|
PAGECACHE_READ_UNKNOWN_PAGE
|
2006-07-06 10:10:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2007-02-02 08:41:32 +01:00
|
|
|
This enum describe lock status changing. every type of page cache will
|
2006-07-06 10:10:34 +02:00
|
|
|
interpret WRITE/READ lock as it need.
|
|
|
|
*/
|
|
|
|
enum pagecache_page_lock
|
|
|
|
{
|
|
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED, /* free -> free */
|
|
|
|
PAGECACHE_LOCK_LEFT_READLOCKED, /* read -> read */
|
|
|
|
PAGECACHE_LOCK_LEFT_WRITELOCKED, /* write -> write */
|
|
|
|
PAGECACHE_LOCK_READ, /* free -> read */
|
|
|
|
PAGECACHE_LOCK_WRITE, /* free -> write */
|
|
|
|
PAGECACHE_LOCK_READ_UNLOCK, /* read -> free */
|
|
|
|
PAGECACHE_LOCK_WRITE_UNLOCK, /* write -> free */
|
|
|
|
PAGECACHE_LOCK_WRITE_TO_READ /* write -> read */
|
|
|
|
};
|
|
|
|
/*
|
|
|
|
This enum describe pin status changing
|
|
|
|
*/
|
|
|
|
enum pagecache_page_pin
|
|
|
|
{
|
|
|
|
PAGECACHE_PIN_LEFT_PINNED, /* pinned -> pinned */
|
|
|
|
PAGECACHE_PIN_LEFT_UNPINNED, /* unpinned -> unpinned */
|
|
|
|
PAGECACHE_PIN, /* unpinned -> pinned */
|
|
|
|
PAGECACHE_UNPIN /* pinned -> unpinned */
|
|
|
|
};
|
|
|
|
/* How to write the page */
|
|
|
|
enum pagecache_write_mode
|
|
|
|
{
|
|
|
|
/* do not write immediately, i.e. it will be dirty page */
|
|
|
|
PAGECACHE_WRITE_DELAY,
|
|
|
|
/* page already is in the file. (key cache insert analogue) */
|
|
|
|
PAGECACHE_WRITE_DONE
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void *PAGECACHE_PAGE_LINK;
|
|
|
|
|
|
|
|
/* file descriptor for Maria */
|
|
|
|
typedef struct st_pagecache_file
|
|
|
|
{
|
2007-04-19 17:48:36 +02:00
|
|
|
File file;
|
2006-07-06 10:10:34 +02:00
|
|
|
} PAGECACHE_FILE;
|
|
|
|
|
|
|
|
/* page number for maria */
|
2007-02-02 08:41:32 +01:00
|
|
|
typedef uint32 pgcache_page_no_t;
|
2006-07-06 10:10:34 +02:00
|
|
|
|
|
|
|
/* declare structures that is used by st_pagecache */
|
|
|
|
|
|
|
|
struct st_pagecache_block_link;
|
|
|
|
typedef struct st_pagecache_block_link PAGECACHE_BLOCK_LINK;
|
|
|
|
struct st_pagecache_page;
|
|
|
|
typedef struct st_pagecache_page PAGECACHE_PAGE;
|
|
|
|
struct st_pagecache_hash_link;
|
|
|
|
typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
|
|
|
|
|
2007-02-02 08:41:32 +01:00
|
|
|
#include <wqueue.h>
|
|
|
|
|
2007-07-26 17:51:49 +02:00
|
|
|
typedef my_bool (*pagecache_disk_read_validator)(uchar *page, uchar *data);
|
2006-07-06 10:10:34 +02:00
|
|
|
|
|
|
|
#define PAGECACHE_CHANGED_BLOCKS_HASH 128 /* must be power of 2 */
|
|
|
|
|
|
|
|
/*
|
|
|
|
The page cache structure
|
|
|
|
It also contains read-only statistics parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct st_pagecache
|
|
|
|
{
|
|
|
|
my_bool inited;
|
|
|
|
my_bool resize_in_flush; /* true during flush of resize operation */
|
|
|
|
my_bool can_be_used; /* usage of cache for read/write is allowed */
|
|
|
|
uint shift; /* block size = 2 ^ shift */
|
2007-07-02 19:45:15 +02:00
|
|
|
size_t mem_size; /* specified size of the cache memory */
|
2006-07-06 10:10:34 +02:00
|
|
|
uint32 block_size; /* size of the page buffer of a cache block */
|
|
|
|
ulong min_warm_blocks; /* min number of warm blocks; */
|
|
|
|
ulong age_threshold; /* age threshold for hot blocks */
|
|
|
|
ulonglong time; /* total number of block link operations */
|
|
|
|
uint hash_entries; /* max number of entries in the hash table */
|
|
|
|
int hash_links; /* max number of hash links */
|
2006-11-12 23:26:29 +01:00
|
|
|
int hash_links_used; /* number of hash links taken from free links pool */
|
2006-07-06 10:10:34 +02:00
|
|
|
int disk_blocks; /* max number of blocks in the cache */
|
|
|
|
ulong blocks_used; /* maximum number of concurrently used blocks */
|
|
|
|
ulong blocks_unused; /* number of currently unused blocks */
|
|
|
|
ulong blocks_changed; /* number of currently dirty blocks */
|
|
|
|
ulong warm_blocks; /* number of blocks in warm sub-chain */
|
|
|
|
ulong cnt_for_resize_op; /* counter to block resize operation */
|
2006-11-12 23:26:29 +01:00
|
|
|
ulong blocks_available; /* number of blocks available in the LRU chain */
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */
|
|
|
|
PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */
|
|
|
|
PAGECACHE_HASH_LINK *free_hash_list;/* list of free hash links */
|
|
|
|
PAGECACHE_BLOCK_LINK *free_block_list;/* list of free blocks */
|
|
|
|
PAGECACHE_BLOCK_LINK *block_root;/* memory for block links */
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar HUGE_PTR *block_mem; /* memory for block buffers */
|
2006-07-06 10:10:34 +02:00
|
|
|
PAGECACHE_BLOCK_LINK *used_last;/* ptr to the last block of the LRU chain */
|
|
|
|
PAGECACHE_BLOCK_LINK *used_ins;/* ptr to the insertion block in LRU chain */
|
|
|
|
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
|
2007-02-02 08:41:32 +01:00
|
|
|
WQUEUE resize_queue; /* threads waiting during resize operation */
|
|
|
|
WQUEUE waiting_for_hash_link;/* waiting for a free hash link */
|
|
|
|
WQUEUE waiting_for_block; /* requests waiting for a free block */
|
2006-07-06 10:10:34 +02:00
|
|
|
/* hash for dirty file bl.*/
|
|
|
|
PAGECACHE_BLOCK_LINK *changed_blocks[PAGECACHE_CHANGED_BLOCKS_HASH];
|
|
|
|
/* hash for other file bl.*/
|
|
|
|
PAGECACHE_BLOCK_LINK *file_blocks[PAGECACHE_CHANGED_BLOCKS_HASH];
|
|
|
|
|
|
|
|
/*
|
|
|
|
The following variables are and variables used to hold parameters for
|
|
|
|
initializing the key cache.
|
|
|
|
*/
|
|
|
|
|
|
|
|
ulonglong param_buff_size; /* size the memory allocated for the cache */
|
|
|
|
ulong param_block_size; /* size of the blocks in the key cache */
|
|
|
|
ulong param_division_limit; /* min. percentage of warm blocks */
|
|
|
|
ulong param_age_threshold; /* determines when hot block is downgraded */
|
|
|
|
|
2007-02-12 13:23:43 +01:00
|
|
|
/* Statistics variables. These are reset in reset_pagecache_counters(). */
|
|
|
|
ulong global_blocks_changed; /* number of currently dirty blocks */
|
2006-07-06 10:10:34 +02:00
|
|
|
ulonglong global_cache_w_requests;/* number of write requests (write hits) */
|
|
|
|
ulonglong global_cache_write; /* number of writes from cache to files */
|
|
|
|
ulonglong global_cache_r_requests;/* number of read requests (read hits) */
|
|
|
|
ulonglong global_cache_read; /* number of reads from files to cache */
|
|
|
|
|
|
|
|
int blocks; /* max number of blocks in the cache */
|
|
|
|
my_bool in_init; /* Set to 1 in MySQL during init/resize */
|
|
|
|
} PAGECACHE;
|
|
|
|
|
2007-04-04 22:37:09 +02:00
|
|
|
/* The default key cache */
|
|
|
|
extern PAGECACHE dflt_pagecache_var, *dflt_pagecache;
|
|
|
|
|
2007-07-02 19:45:15 +02:00
|
|
|
extern int init_pagecache(PAGECACHE *pagecache, size_t use_mem,
|
2006-07-06 10:10:34 +02:00
|
|
|
uint division_limit, uint age_threshold,
|
2007-02-02 08:41:32 +01:00
|
|
|
uint block_size);
|
2006-07-06 10:10:34 +02:00
|
|
|
extern int resize_pagecache(PAGECACHE *pagecache,
|
2007-07-02 19:45:15 +02:00
|
|
|
size_t use_mem, uint division_limit,
|
2006-07-06 10:10:34 +02:00
|
|
|
uint age_threshold);
|
|
|
|
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,
|
|
|
|
uint age_threshold);
|
2007-02-02 08:41:32 +01:00
|
|
|
|
|
|
|
#define pagecache_read(P,F,N,L,B,T,K,I) \
|
|
|
|
pagecache_valid_read(P,F,N,L,B,T,K,I,0,0)
|
|
|
|
|
2007-07-02 19:45:15 +02:00
|
|
|
extern uchar *pagecache_valid_read(PAGECACHE *pagecache,
|
2007-02-02 08:41:32 +01:00
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
pgcache_page_no_t pageno,
|
|
|
|
uint level,
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *buff,
|
2007-02-02 08:41:32 +01:00
|
|
|
enum pagecache_page_type type,
|
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
PAGECACHE_PAGE_LINK *link,
|
|
|
|
pagecache_disk_read_validator validator,
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar* validator_data);
|
2007-04-04 22:37:09 +02:00
|
|
|
|
|
|
|
#define pagecache_write(P,F,N,L,B,T,O,I,M,K) \
|
2007-08-13 14:17:49 +02:00
|
|
|
pagecache_write_part(P,F,N,L,B,T,O,I,M,K,0,(P)->block_size,0,0)
|
|
|
|
|
|
|
|
#define pagecache_inject(P,F,N,L,B,T,O,I,K,V,D) \
|
|
|
|
pagecache_write_part(P,F,N,L,B,T,O,I,PAGECACHE_WRITE_DONE, \
|
|
|
|
K,0,(P)->block_size,V,D)
|
2007-04-04 22:37:09 +02:00
|
|
|
|
|
|
|
extern my_bool pagecache_write_part(PAGECACHE *pagecache,
|
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
pgcache_page_no_t pageno,
|
|
|
|
uint level,
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *buff,
|
2007-04-04 22:37:09 +02:00
|
|
|
enum pagecache_page_type type,
|
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
enum pagecache_page_pin pin,
|
|
|
|
enum pagecache_write_mode write_mode,
|
|
|
|
PAGECACHE_PAGE_LINK *link,
|
|
|
|
uint offset,
|
2007-08-13 14:17:49 +02:00
|
|
|
uint size,
|
|
|
|
pagecache_disk_read_validator validator,
|
|
|
|
uchar* validator_data);
|
2006-11-12 23:26:29 +01:00
|
|
|
extern void pagecache_unlock(PAGECACHE *pagecache,
|
2007-04-12 10:35:05 +02:00
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
pgcache_page_no_t pageno,
|
2006-11-12 23:26:29 +01:00
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
enum pagecache_page_pin pin,
|
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
|
|
|
LSN first_REDO_LSN_for_page,
|
|
|
|
LSN lsn);
|
2007-04-12 10:35:05 +02:00
|
|
|
extern void pagecache_unlock_by_link(PAGECACHE *pagecache,
|
|
|
|
PAGECACHE_PAGE_LINK *link,
|
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
enum pagecache_page_pin pin,
|
2007-06-05 11:14:05 +02:00
|
|
|
LSN first_REDO_LSN_for_page,
|
2007-06-05 09:57:04 +02:00
|
|
|
LSN lsn);
|
2006-11-12 23:26:29 +01:00
|
|
|
extern void pagecache_unpin(PAGECACHE *pagecache,
|
2007-04-12 10:35:05 +02:00
|
|
|
PAGECACHE_FILE *file,
|
2007-06-05 09:57:04 +02:00
|
|
|
pgcache_page_no_t pageno,
|
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
|
|
|
LSN lsn);
|
2007-04-12 10:35:05 +02:00
|
|
|
extern void pagecache_unpin_by_link(PAGECACHE *pagecache,
|
2007-06-05 09:57:04 +02:00
|
|
|
PAGECACHE_PAGE_LINK *link,
|
|
|
|
LSN lsn);
|
2006-07-06 10:10:34 +02:00
|
|
|
extern int flush_pagecache_blocks(PAGECACHE *keycache,
|
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
enum flush_type type);
|
2007-06-05 11:14:05 +02:00
|
|
|
extern my_bool pagecache_delete(PAGECACHE *pagecache,
|
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
pgcache_page_no_t pageno,
|
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
my_bool flush);
|
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
|
|
|
extern my_bool pagecache_delete_pages(PAGECACHE *pagecache,
|
|
|
|
PAGECACHE_FILE *file,
|
|
|
|
pgcache_page_no_t pageno,
|
|
|
|
uint page_count,
|
|
|
|
enum pagecache_page_lock lock,
|
|
|
|
my_bool flush);
|
2006-07-06 10:10:34 +02:00
|
|
|
extern void end_pagecache(PAGECACHE *keycache, my_bool cleanup);
|
2006-12-20 18:58:35 +01:00
|
|
|
extern my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
|
2006-12-18 17:24:02 +01:00
|
|
|
LEX_STRING *str,
|
- WL#3239 "log CREATE TABLE in Maria"
- WL#3240 "log DROP TABLE in Maria"
- similarly, log RENAME TABLE, REPAIR/OPTIMIZE TABLE, and
DELETE no_WHERE_clause (== the DELETE which just truncates the files)
- create_rename_lsn added to MARIA_SHARE's state
- all these operations (except DROP TABLE) also update the table's
create_rename_lsn, which is needed for the correctness of
Recovery (see function comment of _ma_repair_write_log_record()
in ma_check.c)
- write a COMMIT record when transaction commits.
- don't log REDOs/UNDOs if this is an internal temporary table
like inside ALTER TABLE (I expect this to be a big win). There was
already no logging for user-created "CREATE TEMPORARY" tables.
- don't fsync files/directories if the table is not transactional
- in translog_write_record(), autogenerate a 2-byte-id for the table
and log the "id->name" pair (LOGREC_FILE_ID); log
LOGREC_LONG_TRANSACTION_ID; automatically store
the table's 2-byte-id in any log record.
- preparations for Checkpoint: translog_get_horizon(); pausing Checkpoint
when some dirty pages are unknown; capturing trn->rec_lsn,
trn->first_undo_lsn for Checkpoint and log's low-water-mark computing.
- assertions, comments.
storage/maria/Makefile.am:
more files to build
storage/maria/ha_maria.cc:
- logging a REPAIR log record if REPAIR/OPTIMIZE was successful.
- ha_maria::data_file_type does not have to be set in every info()
call, just do it once in open().
- if caller said that transactionality can be disabled (like if
caller is ALTER TABLE) i.e. thd->transaction.on==FALSE, then we
temporarily disable transactionality of the table in external_lock();
that will ensure that no REDOs/UNDOs are logged for this possibly
massive write operation (they are not needed, as if any write fails,
the table will be dropped). We re-enable in external_lock(F_UNLCK),
which in ALTER TABLE happens before the tmp table replaces the original
one (which is good, as thus the final table will have a REDO RENAME
and a correct create_rename_lsn).
- when we commit we also have to write a log record, so
trnman_commit_trn() calls become ma_commit() calls
- at end of engine's initialization, we are potentially entering a
multi-threaded dangerous world (clients are going to be accepted)
and so some assertions of mutex-owning become enforceable, for that
we set maria_multi_threaded=TRUE (see ma_control_file.c)
storage/maria/ha_maria.h:
new member ha_maria::save_transactional (see also ha_maria.cc)
storage/maria/ma_blockrec.c:
- fixing comments according to discussion with Monty
- if a table is transactional but temporarily non-transactional
(like in ALTER TABLE), we need to give a sensible LSN to the pages
(and, if we give 0, pagecache asserts).
- translog_write_record() now takes care of storing the share's
2-byte-id in the log record
storage/maria/ma_blockrec.h:
fixing comment according to discussion with Monty
storage/maria/ma_check.c:
When REPAIR/OPTIMIZE modify the data/index file, if this is a
transactional table, they must sync it; if they remove files or rename
files, they must sync the directory, so that everything is durable.
This is just applying to REPAIR/OPTIMIZE the logic already implemented
in CREATE/DROP/RENAME a few months ago.
Adding a function to write a LOGREC_REPAIR_TABLE at end of
REPAIR/OPTIMIZE (called only by ha_maria, not by maria_chk), and
to update the table's create_rename_lsn.
storage/maria/ma_close.c:
fix for a future bug
storage/maria/ma_control_file.c:
ensuring that if Maria is running in multi-threaded mode, anybody
wanting to write to the control file and update
last_checkpoint_lsn/last_logno owns the log's lock.
storage/maria/ma_control_file.h:
see ma_control_file.c
storage/maria/ma_create.c:
when creating a table:
- sync it and its directory only if this is a transactional table
and there is a log (no point in syncing in maria_chk)
- decouple the two uses of linkname/linkname_ptr (for index file and
for data file) into more variables, as we need to know all links
until the moment we write the LOGREC_CREATE_TABLE.
- set share.data_file_type early so that _ma_initialize_data_file()
knows it (Monty's bugfix so that a table always has at least a bitmap
page when it is created; so data-file is not 0 bytes anymore).
- log a LOGREC_CREATE_TABLE; it contains the bytes which we have
just written to the index file's header. Update table's
create_rename_lsn.
- syncing of kfile had been bugified in a previous merge, correcting
- syncing of dfile is now needed as it's not empty anymore
- in _ma_initialize_data_file(), use share's block_size and not the
global one. This is a gratuitous change, both variables are equal,
just that I find it more future-proof to use share-bound variable
rather than global one.
storage/maria/ma_delete_all.c:
log a LOGREC_DELETE_ALL record when doing ma_delete_all_rows();
update create_rename_lsn then.
storage/maria/ma_delete_table.c:
- logging LOGREC_DROP_TABLE; knowing if this is needed, requires
knowing if the table is transactional, which requires opening the
table.
- we need to sync directories only if the table is transactional
storage/maria/ma_extra.c:
questions
storage/maria/ma_init.c:
when maria_end() is called, engine is not multithreaded
storage/maria/ma_loghandler.c:
- translog_inited has to be visible to ma_create() (see how it is used
in ma_create())
- checkpoint record will be a single record, not three
- no REDO for TRUNCATE (TRUNCATE calls ma_create() internally so will
log a REDO_CREATE)
- adding REDO for DELETE no_WHERE_clause (fast DELETE of all rows by
truncating the files), REPAIR.
- MY_WAIT_IF_FULL to wait&retry if a log write hits a full disk
- in translog_write_record(), if MARIA_SHARE does not yet have a
2-byte-id, generate one for it and log LOGREC_FILE_ID; automatically
store this short id into log records.
- in translog_write_record(), if transaction has not logged its
long trid, log LOGREC_LONG_TRANSACTION_ID.
- For Checkpoint, we need to know the current end-of-log: adding
translog_get_horizon().
- For Control File, adding an assertion that the thread owns the
log's lock (control file is protected by this lock)
storage/maria/ma_loghandler.h:
Changes in log records (see ma_loghandler.c).
new prototypes, new functions.
storage/maria/ma_loghandler_lsn.h:
adding a type LSN_WITH_FLAGS especially for TRN::first_undo_lsn,
where the most significant byte is used for flags.
storage/maria/ma_open.c:
storing the create_rename_lsn in the index file's header (in the
state, precisely) and retrieving it from there.
storage/maria/ma_pagecache.c:
- my set_if_bigger was wrong, correcting it
- if the first_in_switch list is not empty, it means that
changed_blocks misses some dirty pages, so Checkpoint cannot run and
needs to wait. A variable missing_blocks_in_changed_list is added to
tell that (should it be named missing_blocks_in_changed_blocks?)
- pagecache_collect_changed_blocks_with_lsn() now also tells the
minimum rec_lsn (needed for low-water mark computation).
storage/maria/ma_pagecache.h:
see ma_pagecache.c
storage/maria/ma_panic.c:
comment
storage/maria/ma_range.c:
comment
storage/maria/ma_rename.c:
- logging LOGREC_RENAME_TABLE; knowing if this is needed, requires
knowing if the table is transactional, which requires opening the
table.
- update create_rename_lsn
- we need to sync directories only if the table is transactional
storage/maria/ma_static.c:
comment
storage/maria/ma_test_all.sh:
- tip for Valgrind-ing ma_test_all
- do "export maria_path=somepath" before calling ma_test_all,
if you want to run ma_test_all out of storage/maria (useful
to have parallel runs, like one normal and one Valgrind, they
must not use the same tables so need to run in different directories)
storage/maria/maria_def.h:
- state now contains, in memory and on disk, the create_rename_lsn
- share now contains a 2-byte-id
storage/maria/trnman.c:
preparations for Checkpoint: capture trn->rec_lsn, trn->first_undo_lsn;
minimum first_undo_lsn needed to know log's low-water-mark
storage/maria/trnman.h:
using most significant byte of first_undo_lsn to hold miscellaneous
flags, for now TRANSACTION_LOGGED_LONG_ID.
dummy_transaction_object is already declared in ma_static.c.
storage/maria/trnman_public.h:
dummy_transaction_object was declared in all files including
trnman_public.h, while in fact it's a single object.
new prototype
storage/maria/unittest/ma_test_loghandler-t.c:
update for new prototype
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
update for new prototype
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
update for new prototype
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
update for new prototype
storage/maria/ma_commit.c:
function which wraps:
- writing a LOGREC_COMMIT record (==commit on disk)
- calling trnman_commit_trn() (=commit in memory)
storage/maria/ma_commit.h:
new header file
.tree-is-private:
this file is now needed to keep our tree private (don't push it
to public trees). When 5.1 is merged into mysql-maria, we can abandon
our maria-specific post-commit trigger; .tree_is_private will take
care of keeping commit mails private. Don't push this file to public
trees.
2007-06-22 14:49:37 +02:00
|
|
|
LSN *min_lsn,
|
2006-12-18 17:24:02 +01:00
|
|
|
LSN *max_lsn);
|
2007-02-12 13:23:43 +01:00
|
|
|
extern int reset_pagecache_counters(const char *name, PAGECACHE *pagecache);
|
2006-07-06 10:10:34 +02:00
|
|
|
|
2007-04-04 22:37:09 +02:00
|
|
|
|
|
|
|
/* Functions to handle multiple key caches */
|
|
|
|
extern my_bool multi_pagecache_init(void);
|
|
|
|
extern void multi_pagecache_free(void);
|
2007-07-02 19:45:15 +02:00
|
|
|
extern PAGECACHE *multi_pagecache_search(uchar *key, uint length,
|
2007-04-04 22:37:09 +02:00
|
|
|
PAGECACHE *def);
|
2007-07-02 19:45:15 +02:00
|
|
|
extern my_bool multi_pagecache_set(const uchar *key, uint length,
|
2007-04-04 22:37:09 +02:00
|
|
|
PAGECACHE *pagecache);
|
|
|
|
extern void multi_pagecache_change(PAGECACHE *old_data,
|
|
|
|
PAGECACHE *new_data);
|
|
|
|
extern int reset_pagecache_counters(const char *name,
|
|
|
|
PAGECACHE *pagecache);
|
|
|
|
|
2006-07-06 10:10:34 +02:00
|
|
|
C_MODE_END
|
|
|
|
#endif /* _keycache_h */
|