mirror of
https://github.com/MariaDB/server.git
synced 2025-12-15 08:21:24 +03:00
* 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
76 lines
2.3 KiB
C
76 lines
2.3 KiB
C
/* Copyright (C) 2000 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
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifdef SAFEMALLOC /* We don't need SAFEMALLOC here */
|
|
#undef SAFEMALLOC
|
|
#endif
|
|
|
|
#include "mysys_priv.h"
|
|
#include "mysys_err.h"
|
|
|
|
/* My memory re allocator */
|
|
|
|
/**
|
|
@brief wrapper around realloc()
|
|
|
|
@param oldpoint pointer to currently allocated area
|
|
@param size new size requested, must be >0
|
|
@param my_flags flags
|
|
|
|
@note if size==0 realloc() may return NULL; my_realloc() treats this as an
|
|
error which is not the intention of realloc()
|
|
*/
|
|
void* my_realloc(void* oldpoint, size_t size, myf my_flags)
|
|
{
|
|
void *point;
|
|
DBUG_ENTER("my_realloc");
|
|
DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint,
|
|
(ulong) size, my_flags));
|
|
|
|
DBUG_ASSERT(size > 0);
|
|
if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR))
|
|
DBUG_RETURN(my_malloc(size,my_flags));
|
|
#ifdef USE_HALLOC
|
|
if (!(point = malloc(size)))
|
|
{
|
|
if (my_flags & MY_FREE_ON_ERROR)
|
|
my_free(oldpoint,my_flags);
|
|
if (my_flags & MY_HOLD_ON_ERROR)
|
|
DBUG_RETURN(oldpoint);
|
|
my_errno=errno;
|
|
if (my_flags & MY_FAE+MY_WME)
|
|
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size);
|
|
}
|
|
else
|
|
{
|
|
memcpy(point,oldpoint,size);
|
|
free(oldpoint);
|
|
}
|
|
#else
|
|
if ((point= (uchar*) realloc(oldpoint,size)) == NULL)
|
|
{
|
|
if (my_flags & MY_FREE_ON_ERROR)
|
|
my_free(oldpoint, my_flags);
|
|
if (my_flags & MY_HOLD_ON_ERROR)
|
|
DBUG_RETURN(oldpoint);
|
|
my_errno=errno;
|
|
if (my_flags & (MY_FAE+MY_WME))
|
|
my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size);
|
|
}
|
|
#endif
|
|
DBUG_PRINT("exit",("ptr: 0x%lx", (long) point));
|
|
DBUG_RETURN(point);
|
|
} /* my_realloc */
|