mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
e27890cab0
* create page cache before initializing engine and not after, because Maria's recovery needs a page cache * make the creation of a bitmap page more crash-resistent * bugfix (see ma_blockrec.c) * back to old way: create an 8k bitmap page when creating table * preparations for the UNDO phase: recreate TRNs * preparations for Checkpoint: list of dirty pages, testing of rec_lsn to know if page should be skipped during Recovery (unused in this patch as no Checkpoint module pushed yet) * maria_chk tags repaired table with a special LSN * reworking all around in ma_recovery.c (less duplication) mysys/my_realloc.c: noted an issue in my_realloc() sql/mysqld.cc: page cache needs to be created before engines are initialized, because Maria's initialization may do a recovery which needs the page cache. storage/maria/ha_maria.cc: update to new prototype storage/maria/ma_bitmap.c: when creating the first bitmap page we used chsize to 8192 bytes then pwrite (overwrite) the last 2 bytes (8191-8192). If crash between the two operations, this leaves a bitmap page full without its end marker. A later recovery may try to read this page and find it exists and misses a marker and conclude it's corrupted and fail. Changing the chsize to only 8190 bytes: recovery will then find the page is too short and recreate it entirely. storage/maria/ma_blockrec.c: Fix for a bug: when executing a REDO, if the data page is created, data_file_length was increased before _ma_bitmap_set(): _ma_bitmap_set() called _ma_read_bitmap_page() which, due to the increased data_file_length, expected to find a bitmap page on disk with a correct end marker; if the bitmap page didn't exist already in fact, this failed. Fixed by increasing data_file_length only after _ma_read_bitmap_page() has created the new bitmap page correctly. This bug could happen every time a REDO is about creating a new bitmap page. storage/maria/ma_check.c: empty data file has a bitmap page storage/maria/ma_control_file.c: useless parameter to ma_control_file_create_or_open(), just test if this is recovery. storage/maria/ma_control_file.h: new prototype storage/maria/ma_create.c: Back to how it was before: maria_create() creates an 8k bitmap page. Thus (bugfix) data_file_length needs to reflect this instead of being 0. storage/maria/ma_loghandler.c: as ma_test1 and ma_test2 now use real transactions and not dummy_transaction_object, REDO for INSERT/UPDATE/DELETE are always about real transactions, can assert this. A function for Recovery to assign a short id to a table. storage/maria/ma_loghandler.h: new function storage/maria/ma_loghandler_lsn.h: maria_chk tags repaired tables with this LSN storage/maria/ma_open.c: * enforce that DMLs on transactional tables use real transactions and not dummy_transaction_object. * test if table was repaired with maria_chk (which has to been seen as an import of an external table into the server), test validity of create_rename_lsn (header corruption detection) * comments. storage/maria/ma_recovery.c: * preparations for the UNDO phase: recreate TRNs * preparations for Checkpoint: list of dirty pages, testing of rec_lsn to know if page should be skipped during Recovery (unused in this patch as no Checkpoint module pushed yet) * reworking all around (less duplication) storage/maria/ma_recovery.h: a parameter to say if the UNDO phase should be skipped storage/maria/maria_chk.c: tag repaired tables with a special LSN storage/maria/maria_read_log.c: * update to new prototype * no UNDO phase in maria_read_log for now storage/maria/trnman.c: * a function for Recovery to create a transaction (TRN), needed in the UNDO phase * a function for Recovery to grab an existing transaction, needed in the UNDO phase (rollback all existing transactions) storage/maria/trnman_public.h: new functions
80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult 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
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/*
|
|
WL#3234 Maria control file
|
|
First version written by Guilhem Bichot on 2006-04-27.
|
|
*/
|
|
|
|
#ifndef _ma_control_file_h
|
|
#define _ma_control_file_h
|
|
|
|
#define CONTROL_FILE_BASE_NAME "maria_log_control"
|
|
|
|
/* Here is the interface of this module */
|
|
|
|
/*
|
|
LSN of the last checkoint
|
|
(if last_checkpoint_lsn == LSN_IMPOSSIBLE then there was never a checkpoint)
|
|
*/
|
|
extern LSN last_checkpoint_lsn;
|
|
/*
|
|
Last log number (if last_logno == FILENO_IMPOSSIBLE then there is no log
|
|
file yet)
|
|
*/
|
|
extern uint32 last_logno;
|
|
|
|
extern my_bool maria_multi_threaded, maria_in_recovery;
|
|
|
|
typedef enum enum_control_file_error {
|
|
CONTROL_FILE_OK= 0,
|
|
CONTROL_FILE_TOO_SMALL,
|
|
CONTROL_FILE_TOO_BIG,
|
|
CONTROL_FILE_BAD_MAGIC_STRING,
|
|
CONTROL_FILE_BAD_CHECKSUM,
|
|
CONTROL_FILE_MISSING,
|
|
CONTROL_FILE_UNKNOWN_ERROR /* any other error */
|
|
} CONTROL_FILE_ERROR;
|
|
|
|
#define CONTROL_FILE_UPDATE_ALL 0
|
|
#define CONTROL_FILE_UPDATE_ONLY_LSN 1
|
|
#define CONTROL_FILE_UPDATE_ONLY_LOGNO 2
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
Looks for the control file. If none and creation was requested, creates file.
|
|
If present, reads it to find out last checkpoint's LSN and last log.
|
|
Called at engine's start.
|
|
*/
|
|
CONTROL_FILE_ERROR ma_control_file_create_or_open();
|
|
/*
|
|
Write information durably to the control file.
|
|
Called when we have created a new log (after syncing this log's creation)
|
|
and when we have written a checkpoint (after syncing this log record).
|
|
*/
|
|
int ma_control_file_write_and_force(const LSN checkpoint_lsn, uint32 logno,
|
|
uint objs_to_write);
|
|
|
|
|
|
/* Free resources taken by control file subsystem */
|
|
int ma_control_file_end();
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|