2007-10-04 19:33:42 +02:00
|
|
|
# Copyright (C) 2007 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
|
|
|
|
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
|
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
|
|
|
|
${CMAKE_SOURCE_DIR}/sql
|
|
|
|
${CMAKE_SOURCE_DIR}/regex
|
|
|
|
${CMAKE_SOURCE_DIR}/extra/yassl/include)
|
2008-01-10 13:21:53 +01:00
|
|
|
SET(MARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
|
|
|
|
ma_rnext.c ma_rnext_same.c
|
|
|
|
ma_search.c ma_page.c ma_key_recover.c ma_key.c
|
|
|
|
ma_locking.c
|
|
|
|
ma_rrnd.c ma_scan.c ma_cache.c
|
|
|
|
ma_statrec.c ma_packrec.c ma_dynrec.c
|
|
|
|
ma_blockrec.c ma_bitmap.c
|
|
|
|
ma_update.c ma_write.c ma_unique.c
|
|
|
|
ma_delete.c
|
|
|
|
ma_rprev.c ma_rfirst.c ma_rlast.c ma_rsame.c
|
|
|
|
ma_rsamepos.c ma_panic.c ma_close.c ma_create.c
|
|
|
|
ma_range.c ma_dbug.c ma_checksum.c
|
|
|
|
ma_changed.c ma_static.c ma_delete_all.c
|
|
|
|
ma_delete_table.c ma_rename.c ma_check.c
|
|
|
|
ma_keycache.c ma_preload.c ma_ft_parser.c
|
|
|
|
ma_ft_update.c ma_ft_boolean_search.c
|
|
|
|
ma_ft_nlq_search.c ft_maria.c ma_sort.c
|
|
|
|
ha_maria.cc trnman.c lockman.c tablockman.c
|
|
|
|
ma_rt_index.c ma_rt_key.c ma_rt_mbr.c ma_rt_split.c
|
|
|
|
ma_sp_key.c ma_control_file.c ma_loghandler.c
|
|
|
|
ma_pagecache.c ma_pagecaches.c
|
|
|
|
ma_checkpoint.c ma_recovery.c ma_commit.c ma_pagecrc.c
|
WL#3072 - Maria Recovery
Bulk insert: don't log REDO/UNDO for rows, log one UNDO which will
truncate files; this is an optimization and a bugfix (table was left
half-repaired by crash).
Repair: mark table crashed-on-repair at start, bump skip_redo_lsn at start,
this is easier for recovery (tells it to skip old REDOs or even UNDO
phase) and user (tells it to repair) in case of crash, sync files
in the end.
Recovery skips missing or corrupted table and moves to next record
(in REDO or UNDO phase) to be more robust; warns if happens in UNDO phase.
Bugfix for UNDO_KEY_DELETE_WITH_ROOT (tested in ma_test_recovery)
and maria_enable_indexes().
Create missing bitmaps when needed (there can be more than one to create,
in rare cases), log a record for this.
include/myisamchk.h:
new flag: bulk insert repair mustn't bump create_rename_lsn
mysql-test/lib/mtr_report.pl:
skip normal warning in maria-recovery.test
mysql-test/r/maria-recovery.result:
result: crash before bulk insert is committed, causes proper rollback,
and crash right after OPTIMIZE replaces index file with new index file
leads to table marked corrupted and recovery not failing.
mysql-test/t/maria-recovery.test:
- can't check the table or it would commit the transaction,
but check is made after recovery.
- test of crash before bulk-insert-with-repair is committed
(to see if it is rolled back), and of crash after OPTIMIZE has replaced
index file but not finished all operations (to see if recovery fails -
it used to assert when trying to execute an old REDO on the new
index).
storage/maria/CMakeLists.txt:
new file
storage/maria/Makefile.am:
new file
storage/maria/ha_maria.cc:
- If bulk insert on a transactional table using an index repair:
table is initially empty, so don't log REDO/UNDO for data rows
(optimization), just log an UNDO_BULK_INSERT_WITH_REPAIR
which will, if executed, empty the data and index file. Re-enable
logging in end_bulk_insert().
- write log record for repair operation only after it's fully done,
index sort including (maria_repair*() used to write the log record).
- Adding back file->trn=NULL which was removed by mistake earlier.
storage/maria/ha_maria.h:
new member (see ha_maria.cc)
storage/maria/ma_bitmap.c:
Functions to create missing bitmaps:
- one function which creates missing bitmaps in page cache, except
the missing one with max offset which it does not put into page cache
as it will be modified very soon.
- one function which the one above calls, and creates bitmaps in page
cache
- one function to execute REDO_BITMAP_NEW_PAGE which uses the second
one above.
storage/maria/ma_blockrec.c:
- when logging REDO_DELETE_ALL, not only 'records' and 'checksum'
has to be reset under log's mutex.
- execution of REDO_INSERT_ROW_BLOBS now checks the dirty pages' list
- execution of UNDO_BULK_INSERT_WITH_REPAIR
storage/maria/ma_blockrec.h:
new functions
storage/maria/ma_check.c:
- table-flush-before-repair is moved to a separate function reused
by maria_sort_index(); syncing is added
- maria_repair() is allowed to re-enable logging only if it is the one
which disabled it.
- "_ma_flush_table_files_after_repair" was a bad name, it's not after
repair now, and it should not sync as we do more changes to the files
shortly after (sync is postponed to when writing the log record)
- REDO_REPAIR record should be written only after all repair
operations (in particular after sorting index in ha_mara::repair())
- close to the end of repair by sort, flushing of pages must happen
also in the non-quick case, to prepare for the sync at end.
- in parallel repair, some page flushes are not needed as done
by initialize_variables_for_repair().
storage/maria/ma_create.c:
Update skip_redo_lsn, create_rename_lsn optionally.
storage/maria/ma_delete_all.c:
Need to sync files at end of maria_delete_all_rows(), if transactional.
storage/maria/ma_extra.c:
During repair, we sometimes call _ma_flush_table_files() (via
_ma_flush_table_files_before_swap()) while there is a WRITE_CACHE.
storage/maria/ma_key_recover.c:
- when we see CLR_END for UNDO_BULK_INSERT_WITH_REPAIR, re-enable
indices.
- fixing bug: _ma_apply_undo_key_delete() parsed UNDO_KEY_DELETE_WITH_ROOT
wrongly, leading to recovery failure
storage/maria/ma_key_recover.h:
new prototype
storage/maria/ma_locking.c:
DBUG_VOID_RETURN missing
storage/maria/ma_loghandler.c:
UNDO for bulk insert with repair, and REDO for creating bitmaps.
LOGREC_FIRST_FREE to not have to change the for() every time we
add a new record type.
storage/maria/ma_loghandler.h:
new UNDO and REDO
storage/maria/ma_open.c:
Move share.kfile.file=kfile up a bit, so that _ma_update_state_lsns()
can get its value, this fixes a bug where LSN_REPAIRED_BY_MARIA_CHK
was not corrected on disk by maria_open().
Store skip_redo_lsn in index' header.
maria_enable_indexes() had a bug for BLOCK_RECORD, where an empty
file has one page, not 0 bytes.
storage/maria/ma_recovery.c:
- Skip a corrupted, missing, or repaired-with-maria_chk, table in
recovery: don't fail, just go to next REDO or UNDO; but if an UNDO
is skipped in UNDO phase we issue warnings.
- Skip REDO|UNDO in REDO phase if <skip_redo_lsn.
- If UNDO phase fails, delete transactions to not make trnman
assert.
- Update skip_redo_lsn when playing REDO_CREATE_TABLE
- Don't record UNDOs for old transactions which we don't know (long_trid==0)
- Bugfix for UNDO_KEY_DELETE_WITH_ROOT (see ma_key_recover.c)
- Execution of UNDO_BULK_INSERT_WITH_REPAIR
- Don't try to find a page number in REDO_DELETE_ALL
- Pieces moved to ma_recovery_util.c
storage/maria/ma_rename.c:
name change
storage/maria/ma_static.c:
I modified layout of the index' header (inserted skip_redo_lsn in its middle)
storage/maria/ma_test2.c:
allow breaking the test towards the end, tests execution of
UNDO_KEY_DELETE_WITH_ROOT
storage/maria/ma_test_recovery.expected:
6 as testflag instead of 4
storage/maria/ma_test_recovery:
Increase the amount of rollback work to do when testing recovery
with ma_test2; this reproduces the UNDO_KEY_DELETE_WITH_ROOT bug.
storage/maria/maria_chk.c:
skip_redo_lsn should be updated too, for consistency.
Write a REDO_REPAIR after all operations (including sort-records)
have been done.
No reason to flush blocks after maria_chk_data_link() and
maria_sort_records(), there is maria_close() in the end.
write_log_record() is a function, to not clutter maria_chk().
storage/maria/maria_def.h:
New member skip_redo_lsn in the state, and comments
storage/maria/maria_pack.c:
skip_redo_lsn should be updated too, for consistency
storage/maria/ma_recovery_util.c:
_ma_redo_not_needed_for_page(), defined in ma_recovery.c, is needed
by ma_blockrec.c; this causes link issues, resolved by putting
_ma_redo_not_needed_for_page() into a new file (so that it is not
in the same file as repair-related objects of ma_recovery.c).
storage/maria/ma_recovery_util.h:
new file
2008-01-17 23:59:32 +01:00
|
|
|
ha_maria.h maria_def.h ma_recovery_util.c
|
2008-01-10 13:21:53 +01:00
|
|
|
)
|
2007-10-04 19:33:42 +02:00
|
|
|
|
|
|
|
IF(NOT SOURCE_SUBLIBS)
|
|
|
|
|
|
|
|
ADD_LIBRARY(maria ${MARIA_SOURCES})
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(maria_ftdump maria_ftdump.c)
|
2008-01-10 13:21:53 +01:00
|
|
|
TARGET_LINK_LIBRARIES(maria_ftdump maria myisam mysys dbug strings zlib wsock32)
|
2007-10-04 19:33:42 +02:00
|
|
|
|
|
|
|
ADD_EXECUTABLE(maria_chk maria_chk.c)
|
2008-01-10 13:21:53 +01:00
|
|
|
TARGET_LINK_LIBRARIES(maria_chk maria myisam mysys dbug strings zlib wsock32)
|
2007-10-04 19:33:42 +02:00
|
|
|
|
|
|
|
ADD_EXECUTABLE(maria_read_log maria_read_log.c)
|
2008-01-10 13:21:53 +01:00
|
|
|
TARGET_LINK_LIBRARIES(maria_read_log maria myisam mysys dbug strings zlib wsock32)
|
2007-10-04 19:33:42 +02:00
|
|
|
|
|
|
|
ADD_EXECUTABLE(maria_pack maria_pack.c)
|
2008-01-10 13:21:53 +01:00
|
|
|
TARGET_LINK_LIBRARIES(maria_pack maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
|
2008-02-25 17:31:55 +01:00
|
|
|
ADD_EXECUTABLE(maria_dump_log ma_loghandler.c)
|
|
|
|
TARGET_LINK_LIBRARIES(maria_dump_log maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
SET_TARGET_PROPERTIES(maria_dump_log PROPERTIES COMPILE_FLAGS "-DMARIA_DUMP_LOG")
|
|
|
|
|
2008-01-10 13:21:53 +01:00
|
|
|
ADD_EXECUTABLE(ma_test1 ma_test1.c)
|
|
|
|
TARGET_LINK_LIBRARIES(ma_test1 maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(ma_test2 ma_test2.c)
|
|
|
|
TARGET_LINK_LIBRARIES(ma_test2 maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(ma_test3 ma_test3.c)
|
|
|
|
TARGET_LINK_LIBRARIES(ma_test3 maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(ma_rt_test ma_rt_test.c)
|
|
|
|
TARGET_LINK_LIBRARIES(ma_rt_test maria myisam mysys dbug strings zlib wsock32)
|
|
|
|
|
|
|
|
ADD_EXECUTABLE(ma_sp_test ma_sp_test.c)
|
|
|
|
TARGET_LINK_LIBRARIES(ma_sp_test maria myisam mysys dbug strings zlib wsock32)
|
2007-10-04 19:33:42 +02:00
|
|
|
|
|
|
|
IF(EMBED_MANIFESTS)
|
|
|
|
MYSQL_EMBED_MANIFEST("maria_ftdump" "asInvoker")
|
|
|
|
MYSQL_EMBED_MANIFEST("maria_chk" "asInvoker")
|
|
|
|
MYSQL_EMBED_MANIFEST("maria_read_log" "asInvoker")
|
|
|
|
MYSQL_EMBED_MANIFEST("maria_pack" "asInvoker")
|
|
|
|
ENDIF(EMBED_MANIFESTS)
|
|
|
|
|
|
|
|
ENDIF(NOT SOURCE_SUBLIBS)
|