Commit graph

142 commits

Author SHA1 Message Date
unknown
de3178fde8 Checking that the very last record is fully written
on the loghandler start.
Variable definition moved because it is C programm.


storage/maria/ma_loghandler.c:
  Checking that the very last record is fully written
    on the loghandler start.
storage/maria/ma_recovery.c:
  Variable definition moved because it is C programm.
2007-10-17 17:02:14 +03:00
unknown
f2a675b3dd WL#3072 Maria recovery, cleanups, removing some out-of-date @todos
storage/maria/ma_delete_all.c:
  comment (@todo gone, nothing we can do)
storage/maria/ma_recovery.c:
  - fail if LOGREC_CREATE_TABLE contains some symlink info (that
  will be handled in a future version)
  - don't do buffer overrun when parsing a REDO record
  - out-of-date @todo
2007-10-16 16:22:13 +02:00
unknown
08b7152893 WL#3072 Maria recovery
- fixes (in recovery, checkpoint, log handler) of bugs found
during testing.
- new option --check for maria_read_log: with --only-display (which only
reads the header) it reads the full record, for debugging.


storage/maria/ma_loghandler.c:
  importing patch from Sanja for bug of translog_next_LSN() found
  during recovery
storage/maria/ma_loghandler_lsn.h:
  better types (0L is 4 bytes on some platforms, it causes problems
  when used into lsn_store(): right shift >= width of type.
storage/maria/ma_pagecache.c:
  work around infamous "PAGECACHE_PLAIN_PAGE used for transactional
  tables in specialm case"; REDO phase disables logging and this causes
  pages to be PAGECACHE_PLAIN_PAGE, thus ignored wrongly by the
  checkpoint taken at the end of the REDO phase.
storage/maria/ma_recovery.c:
  - a #ifdef which broke maria_read_log in non-debug builds (no output!)
  - support for maria_read_log --check
  - detect record corruption before opening the table
  - updating is_of_horizon requires writing the state
  - fix for wrong parsing of checkpoint record by recovery
storage/maria/ma_recovery.h:
  support for maria_read_log --check
storage/maria/maria_read_log.c:
  Option --check: --only-display only looks at the header;
  adding --check tries a translog_read_record() to see if record can
  be fully read (this is to find bugs).
2007-10-16 14:56:38 +02:00
unknown
ea388ba2c4 WL#3072 Maria recovery. Bugfix (segfault of maria_read_log)
storage/maria/ma_recovery.c:
  bugfix ("count" is meaningul only if printing messages)
2007-10-11 10:57:27 +02:00
unknown
9a57cc3f32 WL#3072 Maria recovery. Improving the progress message (small fixes
plus printing a downcount of tables to flush).


storage/maria/ma_recovery.c:
  improving the progress message of recovery; it used to assume that
  if there is a non-zero UNDO phase then there was a non-REDO phase,
  and if there are tables to flush there was an UNDO phase,
  which is not always true. We now print a downcount of tables to flush
  (4 3 2 1 0).
2007-10-10 11:30:36 +02:00
unknown
791b0aa081 WL#3071 - Maria checkpoint
* Preparation for having a background checkpoint thread:
frequency of checkpoint taken by that thread is now configurable
by the user: global variable maria_checkpoint_frequency, in seconds,
default 30 (checkpoint every 30th second); 0 means no checkpoints
(and thus no background thread, thus no background flushing, that
will probably only be used for testing).
* Don't take checkpoints in Recovery if it didn't do anything
significant; thus no checkpoint after a clean shutdown/restart. The
only checkpoint which is never skipped is the one at shutdown.
* fix for a test failure (after-merge fix)


include/maria.h:
  new variable
mysql-test/suite/rpl/r/rpl_row_flsh_tbls.result:
  result update
mysql-test/suite/rpl/t/rpl_row_flsh_tbls.test:
  position update (=after merge fix, as this position was already changed
  into 5.1 and not merged here, causing test to fail)
storage/maria/ha_maria.cc:
  Checkpoint's frequency is now configurable by the user:
  global variable maria_checkpoint_frequency. Changing it on the fly
  requires us to shutdown/restart the background checkpoint thread,
  as the loop done in that thread assumes a constant checkpoint
  interval. Default value is 30: a checkpoint every 30 seconds (yes, I
  know, physicists will remind that it should be named "period" then).
  ha_maria now asks for a background checkpoint thread when it starts,
  but this is still overruled (disabled) in ma_checkpoint_init().
storage/maria/ma_checkpoint.c:
  Checkpoint's frequency is now configurable by the user: background thread
  takes a checkpoint every maria_checkpoint_interval-th second.
  If that variable is 0, no checkpoints are taken.
  Note, I will enable the background thread only in a later changeset.
storage/maria/ma_recovery.c:
  Don't take checkpoints at the end of the REDO phase and at the end of
  Recovery if Recovery didn't make anything significant (didn't open
  any tables, didn't rollback any transactions).
  With this, after a clean shutdown, Recovery shouldn't take any
  checkpoint, which makes starting faster (we save a few fsync()s of
  the log and control file).
2007-10-09 10:38:31 +02:00
unknown
63ff9877a5 WL#3072 Maria recovery
Misc changes:
- fix for benign Valgrind error, compiler warnings
- fix for a segfault in execution of maria_delete_all_rows() and one
when taking multiple checkpoints
- fix for too paranoid assertion
- adding ability to take checkpoints at the end of the REDO phase
and at the end of recovery.
- other minor changes


storage/maria/ha_maria.cc:
  The checkpoint done after Recovery is finished, is moved to
  maria_recover().
storage/maria/ma_bitmap.c:
  fix for Valgrind error: the "shadow debug copy" of the bitmap page
  started unitialized and so ma_print_bitmap() would use it uninitialized
storage/maria/ma_checkpoint.c:
  * reset pointers to NULL after freeing them, or we segfault at
  next checkpoint in my_realloc().
  * fix for compiler warnings.
storage/maria/ma_delete_all.c:
  info->trn is NULL for non-transactional tables
storage/maria/ma_locking.c:
  correct assertion (it fired wrongly in execution of REDO_DROP_TABLE
  due to the maria_extra(HA_PREPARE_FOR_DROP)->_ma_decrement_open_count()
  ->maria_lock_database(F_UNLCK); another solution would have been to
  not call _ma_decrement_open_count() (it's ok to have a wrong open
  count in a table which we are dropping), but the same problem
  would still exist for REDO_RENAME_TABLE.
storage/maria/ma_loghandler.c:
  fail early if UNRECOVERABLE_ERROR
storage/maria/ma_recovery.c:
  * new argument to maria_apply_log(): should it take checkpoints
  (at end of REDO phase and at the very end) or no.
  * moving the call to translog_next_LSN() into
  parse_checkpoint_record() ("hide the details").
  * Refining an error detection for something which could happen
  if there is a checkpoint record in the log.
  * Using close_one_table() instead of maria_extra(HA_EXTRA_PREPARE_FOR_DROP|RENAME),
  as it looks safer, and also changing how close_one_table() works:
  it now limits itself to scanning all_tables[], thus having one loopp
  instead of two, which should be faster (as a result, it does not
  close tables not registered in this array, which is ok as there
  should not be any).
storage/maria/ma_recovery.h:
  new parameter
storage/maria/maria_read_log.c:
  update to new prototype
2007-10-08 19:08:25 +02:00
unknown
24db7ed7e1 WL#3072 Maria recovery.
* Thanks to Serg's tip, we fix here the compilation issue of
REDO_REPAIR_TABLE's execution, by defining versions of
_ma_killed_ptr() and _ma_check_print_info|warning|error()
in maria_read_log.c (we move those of maria_chk.c into an include
file and include it in maria_chk.c and maria_read_log.c).
Execution of such record looks like working from my tests (it only
happens in maria_read_log; recovery-from-mysqld skips DDLs and
REPAIR is considered DDL here as it bypasses logging): tested
ALTER TABLE ENABLE KEYS and then remove table, apply log: that
did a repair.
* Recent changes broke maria_read_log a bit: -a became default
and -o caused error; fixing this.


storage/maria/Makefile.am:
  addind new file
storage/maria/ma_recovery.c:
  enable execution of REDO_REPAIR_TABLE by maria_read_log now that
  it compiles. Now reason to keep only T_QUICK from testflag.
storage/maria/maria_chk.c:
  moving these functions to ma_check_standalone.h for reusability
storage/maria/maria_def.h:
  comment
storage/maria/maria_read_log.c:
  ma_check_standalone.h needs my_progname_short.
  Fixing bug where "maria_read_log" would default to -a and
  "maria_read_log -o" would throw an error. Implemented behaviour is:
  - no options: usage()
  - -a : applys, applys UNDOs by default unless --disable-undo
  - -o : only prints
storage/maria/ma_check_standalone.h:
  All standalone programs which need to use functions from ma_check.c
  (like maria_repair()) must define their version of _ma_killed_ptr()
  and _ma_check_print_info|warning|error(). Indeed, linking with ma_check.o
  brings in the dependencies of ma_check.o which are definitions of the above
  functions; if the program does not define them then the ones of
  ha_maria.o are used i.e. ha_maria.o is linked into the program, and this
  brings dependencies of ha_maria.o on mysqld.o into the program's linking
  which thus fails, as the program is not linked with mysqld.o.
  We put in this file the functions which maria_chk.c uses, so that
  they can be reused by maria_read_log (when it replays REDO_REPAIR_TABLE)
  as they are good enough (they just print to stdout/stderr like
  maria_read_log already does).
2007-10-03 18:10:32 +02:00
unknown
e814261700 Fix for pushbuild failure (noticable only on 64-bit)
storage/maria/ma_pagecache.c:
  pagecache->blocks is now long, takes 8 bytes on some platforms.
  The cast to ulonglong in int8store is for those platforms where
  ulong is 32-bit and int8store uses some << shifts, if there are
  (x<<40 is undefined if x is 32-bit).
storage/maria/ma_recovery.c:
  this change corresponds to the one done in ma_pagecache.c: number
  of dirty pages is stored in 8 bytes.
2007-10-02 19:16:20 +02:00
unknown
d0b9387b88 WL#3072 - Maria recovery.
* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.


storage/maria/ha_maria.cc:
  question for Monty
storage/maria/ma_blockrec.c:
  * log in-write hooks (write_hook_for_redo() etc) move from
  ma_loghandler.c to here; this is natural: the hooks are coupled
  to their callers (functions in ma_blockrec.c).
  * translog_write_record() now has a new argument "hook_arg";
  using it to pass down to write_hook_for_clr_end() the transaction's
  previous_undo_lsn and the type of the being undone record, and also
  to pass down to all UNDOs the live checksum variation caused by the
  operation.
  * If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
  and in CLR_END the checksum variation ("delta") caused by the
  operation. For example if a DELETE caused the table's live checksum
  to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
  the value 333 (456-123).
  * Instead of hard-coded "1" as length of the place where we store
  the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
  use macros clr_type_store and clr_type_korr.
  * write_block_record() has a new parameter 'old_record_checksum'
  which is the pre-computed checksum of old_record; that value is used
  to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
  * In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
  the row's checksum is already computed.
  * _ma_update_block_record2() now expect the new row's checksum into
  cur_row.checksum (was already true) and the old row's checksum into
  new_row.checksum (that's new). Its two callers, maria_update() and
  _ma_apply_undo_row_update(), honour this.
  * When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
  up the checksum delta from the log record. It is then used to update
  the table's live checksum when writing CLR_END, and saves us a
  computation of record.
storage/maria/ma_blockrec.h:
  in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
  more straightforward size of buffer
storage/maria/ma_checkpoint.c:
  <= is enough
storage/maria/ma_commit.c:
  new prototype of translog_write_record()
storage/maria/ma_create.c:
  new prototype of translog_write_record()
storage/maria/ma_delete.c:
  The row's checksum must be computed before calling(*delete_record)(),
  not after, because it must be known inside _ma_delete_block_record()
  (to update the table's live checksum when writing UNDO_ROW_DELETE).
  If deleting from a transactional table, live checksum was already updated
  when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
  @todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
  new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
  * in-write hooks move to ma_blockrec.c.
  * translog_write_record() gets a new argument 'hook_arg' which is
  passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
  for those hooks, because when those hooks are called, 'parts' has
  possibly been mangled (like with LSN compression) and is so
  unpredictable.
  * fix for compiler warning (unused buffer_start when compiling without
  debug support)
  * Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
  and CLR_END, but only if the table has live checksum, these records
  are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
  length is X if no live checksum and X+4 otherwise).
  * add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
  table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
  DELETE and REDO_DELETE_ALL and CLR_END.
  * Bugfix: when reading a record in translog_read_record(), it happened
  that "length" became negative, because the function assumed that
  the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
  * Instead of hard-coded "1" and "4", use symbols and macros
  to store/retrieve the type of record which the CLR_END corresponds
  to, and the checksum variation caused by the operation which logs the
  record
  * translog_write_record() gets a new argument 'hook_arg' which is
  passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
  for those hooks, because when those hooks are called, 'parts' has
  possibly been mangled (like with LSN compression) and is so
  unpredictable.
storage/maria/ma_open.c:
  fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
  <= is enough
storage/maria/ma_recovery.c:
  * print the time that each recovery phase (REDO/UNDO/flush) took;
  this is enabled only when recovering from ha_maria. Is it printed
  n seconds with a fractional part of one digit (like 123.4 seconds).
  * In the REDO phase, update the table's live checksum by using
  the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
  Update it too when seeing REDO_DELETE_ALL.
  * In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
  not have live checksum then reading the record's header (as done by
  the master loop of run_undo_phase()) is enough; otherwise we
  do a translog_read_record() to have the checksum delta ready
  for _ma_apply_undo_row_insert().
  * When at the end of the REDO phase we notice that there is an unfinished
  group of REDOs, don't assert in debug binaries, as I verified that it
  can happen in real life (with kill -9)
  * removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
  new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
  Change in output of ma_test_recovery: now all live checksums of
  original tables equal those of tables recreated by the REDO phase
  and those of tables fixed by the UNDO phase. I.e. recovery of
  the live checksum looks like working (which was after all the only
  goal of this changeset).
  I checked by hand that it's not just all live checksums which are
  now 0 and that's why they match. They are the old values like
  3757530372. maria.test has hard-coded checksum values in its result
  file so checks this too.
storage/maria/ma_update.c:
  * It's useless to put up HA_STATE_CHANGED in 'key_changed',
  as we put up HA_STATE_CHANGED in info->update anyway.
  * We need to compute the old and new rows' checksum before calling
  (*update_record)(), as checksum delta must be known when logging
  UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
  some functions change the 'newrec' record (at least _ma_check_unique()
  does) so we cannot move the checksum computation too early in the
  function.
storage/maria/ma_write.c:
  If inserting into a transactional table, live's checksum was
  already updated when writing UNDO_ROW_INSERT. The multiplication
  is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
  new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
  new prototype of translog_write_record()
storage/myisam/sort.c:
  fix for compiler warnings in pushbuild (write_merge_key* functions
  didn't have their declaration match MARIA_HA::write_key).
2007-10-02 18:02:09 +02:00
unknown
69c18ca576 ma_recovery.c:
SCCS merged


storage/maria/ma_recovery.c:
  SCCS merged
2007-10-01 17:31:46 +02:00
unknown
e71e5893ee Incorrect function call fixed. 2007-10-01 09:59:05 +03:00
unknown
7492e2ca8e Use direct memory access for the log scan
BUILD/SETUP.sh:
  compile maria by default
2007-09-27 17:36:03 +03:00
unknown
c9c58163a9 Remove SAFE_MODE for opt_range as it disables UPDATE to use keys
REDO optimization (Bascily avoid moving blocks from/to pagecache)
More command line arguments to maria_read_log
Fixed recovery bug when recreating table


sql/opt_range.cc:
  Remove SAFE_MODE for opt_range as it disables UPDATE to use keys
storage/maria/ma_blockrec.c:
  REDO optimization
  Use new interface for pagecache_reads to avoid copying page buffers
storage/maria/ma_loghandler.c:
  Patch from Sanja:
  - Added new parameter to translog_get_page to use direct links to pagecache
  - Changed scanner to be able to use direct links
  
  This avoids a lot of calls to bmove512() in page cache.
storage/maria/ma_loghandler.h:
  Added direct link to pagecache objects
storage/maria/ma_open.c:
  Added const to parameter
  Added missing braces
storage/maria/ma_pagecache.c:
  From Sanja:
  - Added direct links to pagecache (from pagecache_read())
    Dirrect link means that on pagecache_read we get back a pointer to the pagecache buffer
  
  
  From Monty:
  - Fixed arguments to init_page_cache to handle big page caches
  - Fixed compiler warnings
  - Replaced PAGECACHE_PAGE_LINK with PAGECACHE_BLOCK_LINK * to catch errors
storage/maria/ma_pagecache.h:
  Changed block numbers from int to long to be able to handle big page caches
  Changed some PAGECACHE_PAGE_LINK to PAGECACHE_BLOCK_LINK
storage/maria/ma_recovery.c:
  Fixed recovery bug when recreating table (table was kept open)
  Moved some variables to function start (portability)
  Added space to some print messages
storage/maria/maria_chk.c:
  key_buffer_size -> page_buffer_size
storage/maria/maria_def.h:
  Changed default page_buffer_size to 10M
storage/maria/maria_read_log.c:
  Added more startup options:
  --version
  --undo (apply undo)
  --page_cache_size (to run with big cache sizes)
  --silent (to not get any output from --apply)
storage/maria/unittest/ma_control_file-t.c:
  Fixed compiler warning
storage/maria/unittest/ma_test_loghandler-t.c:
  Added new argument to translog_init_scanner()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  Added new argument to translog_init_scanner()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  Added new argument to translog_init_scanner()
2007-09-27 14:18:28 +03:00
unknown
301a31fddf WL#3072 Maria recovery
Minor change: decouple the writing of a recovery trace from
compilation with --with-debug; that writing happens if and only
if EXTRA_DEBUG. So one can enable (by defining EXTRA_DEBUG) a recovery trace
in a non-debug build.


storage/maria/ma_recovery.c:
  Small optimization. Decouple recovery trace from --with-debug.
2007-09-25 15:52:01 +02:00
unknown
8b5dddbc00 WL#3072 Maria recovery
Progress reports on stderr if doing recovery from ha_maria;
don't do checkpoints if activity since last checkpoint < 2MB
(no change in fact as background thread is disabled for now);
recovery trace is only if EXTRA_DEBUG now (better for benchmarks).


storage/maria/ma_checkpoint.c:
  don't do checkpoints if activity (log writes plus page flushes)
  since last checkpoint was < 2MB.
storage/maria/ma_recovery.c:
  progress reports in recovery (10%, transactions left to rollback etc);
  that is only if from ha_maria and is displayed on stderr.
  Recovery trace is now created only if EXTRA_DEBUG.
storage/maria/ma_test_recovery.expected:
  update (--debug gone)
storage/maria/ma_test_recovery:
  don't use --debug, as it can absent from binary
2007-09-25 11:54:35 +02:00
unknown
95420b947e fix for non-debug compilation errors.
Note that non-debug build fails in log handler functions, mail sent.


storage/maria/ma_blockrec.c:
  fix for compiler warning
storage/maria/ma_checkpoint.c:
  Debug build does not catch this situation
  static int f();
  ...
  f(2);
  ...
  static int f(int a, int b);
  Maybe this is because it believes the declaration is K&R. Non-debug
  build catches it. Adding (void) as an habit to avoid such errors.
storage/maria/ma_checkpoint.h:
  adding (void)
storage/maria/ma_recovery.c:
  adding (void)
storage/maria/ma_recovery.h:
  adding (void)
2007-09-20 16:11:46 +02:00
unknown
be382b4220 Fix for segmentation fault when updating a record having a small
BLOB whose size didn't change. Fix for probably impossible problem
in Recovery.


mysql-test/r/maria.result:
  result for new test
mysql-test/t/maria.test:
  testcase for a bug (used to segfault)
storage/maria/ma_blockrec.c:
  When writing a record, we put BLOBs into the head part if there is
  room for them. "Is there room" was first decided by
  !(tmp_data + length > end_of_data) (line 1894)
  but then was tested again as
  *blob_lengths < (ulong)(end_of_data - data). We see that in case of
  equality, the first condition was true but the second was not,
  so it was inconsistent and crashed later.
storage/maria/ma_recovery.c:
  When wondering if recovery should update the state (like state.records):
  if table was closed, its is_of_horizon was set to X, then
  table was reopened and a REDO was written. If this REDO had LSN
  X (as horizon is just a lower bound of the LSN of the next record),
  we have to apply it. In practice this equality probably could not
  happen because of LOGREC_FILE_ID would be written before the REDO.
2007-09-20 10:31:25 +02:00
unknown
9c2ff270fa WL#3072 Maria Recovery
* recovery from ha_maria now skips replaying DDLs (too dangerous)
* maria_read_log still replays DDLs, print warning about issues
* fixes to replaying of REDO_RENAME
* don't replay DDLs on corrupted tables (safer)
* print a one-line message when really doing a recovery (applies to
ha_maria, not maria_read_log) i.e. some REDOs or UNDOs are read.


storage/maria/ma_checkpoint.c:
  fix for assertion failure
storage/maria/ma_recovery.c:
  * Recovery from ha_maria now skips replaying DDLs (as the initial
  plan said) as this is unsafe in case of crashes during the DDL;
  applying the records may do harm (destroy important files)
  so we prefer to leave the "mess" of files untouched. A proper
  recovery of DDLs requires very careful thinking, probably testing
  separately the existence of the data and index file instead of
  using maria_open() which tests the existence of both, and maybe
  storing create_rename_lsn in the data file too.
  * maria_read_log still replays DDLs, we print a warning about dangers
  (due to ALTER TABLE not logging insertions into the tmp table; we
  will maybe need an option to have logging of those insertions).
  * fixes to replaying of REDO_RENAME (test create_rename_lsn of 'new_name'
  table if it exists; if that table exists and is more recent than the
  record, remove the 'old_name' table).
  * don't replay DDLs on corrupted tables (play safe)
  * fail also in non-debug builds if table is open when it should not be
  (when creating it for example, it should not be already open).
  * when the trace file is not stdout (i.e. when this is ha_maria),
  if really doing a recovery (reading REDOs or UNDOs), print a one-line
  message to stderr to inform about start and end of recovery
  (useful to know what mysqld is doing, especially if it takes long
  or crashes).
storage/maria/ma_recovery.h:
  parameter to replay DDLs or not
storage/maria/maria_read_log.c:
  replay DDLs in maria_read_log, to be able to recreate tables from
  scratch.
2007-09-15 14:45:26 +02:00
unknown
19b75b6c73 Fixes problem with getting not LSN address gotten from
horizon addres.


storage/maria/ma_loghandler.c:
  New function to get correct LSN from chunk address.
storage/maria/ma_loghandler.h:
  New function to get correct LSN from chunk address.
2007-09-14 15:01:44 +03:00
unknown
a303f5b2c8 Fixes of the empty log problem.
storage/maria/ma_checkpoint.c:
  The new macro for easier printing LSN added.
storage/maria/ma_loghandler.c:
  The assertion returned.
  The new macro for easier printing LSN added.
storage/maria/ma_loghandler_lsn.h:
  The new macro for easier printing LSN added.
storage/maria/ma_pagecache.c:
  The new macro for easier printing LSN added.
storage/maria/ma_recovery.c:
  Recovery checks empty log state.
  RECHEADER_READ_ERROR means some real error.
storage/maria/maria_read_log.c:
  Read log starts from real beggining of the log and precess
  error and empty log states.
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  The new macro for easier printing LSN added.
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
  The new macro for easier printing LSN added.
2007-09-13 10:37:51 +03:00
unknown
9b2663926b MY_ALLOW_ZERO_PTR in my_realloc() to fix safemalloc errors in pushbuild
storage/maria/ma_recovery.c:
  MY_ALLOW_ZERO_PTR needed as log_record_buffer.str is initially NULL.
2007-09-12 19:18:52 +02:00
unknown
a5f4e79db9 WL#3072 Maria Recovery
* added replaying of REDO_REPAIR_TABLE, but disabled it as
mysterious linker errors appear.
* after replaying RENAME/REPAIR, we must bump create_rename_lsn
for idempotency of maria_read_log.


sql/mysqld.cc:
  typo
storage/maria/ma_checkpoint.c:
  silence compiler warning
storage/maria/ma_recovery.c:
  * added replaying of REDO_REPAIR_TABLE, but disabled it as
  mysterious linker errors appear.
  * after replaying RENAME/REPAIR, we must bump create_rename_lsn
  for idempotency of maria_read_log.
2007-09-12 12:39:04 +02:00
unknown
cec8ac3e07 WL#3071 Maria checkpoint
Finally this is the real checkpoint code.
It however exhibits unstabilities when a checkpoint runs concurrently
with data-modifying clients (table corruption, transaction log's
assertions) so for now a checkpoint is taken only at startup after
recovery and at shutdown, i.e. not in concurrent situations. Later
we will let it run periodically, as well as flush dirty pages
periodically (almost all needed code is there already, only pagecache
code is written but not committed).
WL#3072 Maria recovery
* replacing UNDO_ROW_PURGE with CLR_END; testing of those CLR_END via
ma_test2 which has INSERTs failing with duplicate keys.
* replaying of REDO_RENAME_TABLE
Now, off to test Recovery in ha_maria :)


BitKeeper/deleted/.del-ma_least_recently_dirtied.c:
  Delete: storage/maria/ma_least_recently_dirtied.c
BitKeeper/deleted/.del-ma_least_recently_dirtied.h:
  Delete: storage/maria/ma_least_recently_dirtied.h
storage/maria/Makefile.am:
  compile Checkpoint module
storage/maria/ha_maria.cc:
  When ha_maria starts, do a recovery from last checkpoint.
  Take a checkpoint when that recovery has ended and when ha_maria
  shuts down cleanly.
storage/maria/ma_blockrec.c:
  * even if my_sync() fails we have to my_close() (otherwise we leak
  a descriptor)
  * UNDO_ROW_PURGE is replaced by a simple CLR_END for UNDO_ROW_INSERT,
  as promised in the old comment; it gives us skipping during the
  UNDO phase.
storage/maria/ma_check.c:
  All REDOs before create_rename_lsn are ignored by Recovery. So
  create_rename_lsn must be set only after all data/index has been
  flushed and forced to disk. We thus move write_log_record_for_repair()
  to after _ma_flush_tables_files_after_repair().
storage/maria/ma_checkpoint.c:
  Checkpoint module.
storage/maria/ma_checkpoint.h:
  optional argument if caller wants a thread to periodically take
  checkpoints and flush dirty pages.
storage/maria/ma_create.c:
  * no need to init some vars as the initial bzero(share) takes care of this.
  * update to new function's name
  * even if we fail in my_sync() we have to my_close()
storage/maria/ma_extra.c:
  Checkpoint reads share->last_version under intern_lock, so we make
  maria_extra() update it under intern_lock. THR_LOCK_maria still needed
  because of _ma_test_if_reopen().
storage/maria/ma_init.c:
  destroy checkpoint module when Maria shuts down.
storage/maria/ma_loghandler.c:
  * UNDO_ROW_PURGE gone (see ma_blockrec.c)
  * we need to remember the LSN of the LOGREC_FILE_ID for a share,
  because this LSN is needed into the checkpoint record (Recovery wants
  to know the validity domain of an id->name mapping)
  * translog_get_horizon_no_lock() needed for Checkpoint
  * comment about failing assertion (Sanja knows)
  * translog_init_reader_data() thought that translog_read_record_header_scan()
  returns 0 in case of error, but 0 just means "0-length header".
  * translog_assign_id_to_share() now needs the MARIA_HA because
  LOGREC_FILE_ID uses a log-write hook.
  * Verify that (de)assignment of share->id happens only under intern_lock,
  as Checkpoint reads this id with intern_lock.
  * translog_purge() can accept TRANSLOG_ADDRESS, not necessarily
  a real LSN.
storage/maria/ma_loghandler.h:
  prototype updates
storage/maria/ma_open.c:
  no need to initialize "res"
storage/maria/ma_pagecache.c:
  When taking a checkpoint, we don't need to know the maximum rec_lsn
  of dirty pages; this LSN was intended to be used in the two-checkpoint
  rule, but last_checkpoint_lsn is as good.
  4 bytes for stored_list_size is enough as PAGECACHE::blocks (number
  of blocks which the pagecache can contain) is int.
storage/maria/ma_pagecache.h:
  new prototype
storage/maria/ma_recovery.c:
  * added replaying of REDO_RENAME_TABLE
  * UNDO_ROW_PURGE gone (see ma_blockrec.c), replaced by CLR_END
  * Recovery from the last checkpoint record now possible
  * In new_table() we skip the table if the id->name mapping is older than
  create_rename_lsn (mapping dates from lsn_of_file_id).
  * in get_MARIA_HA_from_REDO_record() we skip the record
  if the id->name mapping is newer than the record (can happen if processing
  a record which is before the checkpoint record).
  * parse_checkpoint_record() has to return a LSN, that's what caller expects
storage/maria/ma_rename.c:
  new function's name; log end zeroes of tables' names (ease recovery)
storage/maria/ma_test2.c:
  * equivalent of ma_test1's --test-undo added (named -u here).
  * -t=1 now stops right after creating the table, so that
  we can test undoing of INSERTs with duplicate keys (which tests the
  CLR_END logged by _ma_write_abort_block_record()).
storage/maria/ma_test_recovery.expected:
  Result of testing undoing of INSERTs with duplicate keys; there are
  some differences in maria_chk -dvv but they are normal (removing
  records does not shrink data/index file, does not put back the
  "analyzed, optimized keys"(etc) index state.
storage/maria/ma_test_recovery:
  Test undoing of INSERTs with duplicate keys, using ma_test2;
  when such INSERT happens, it logs REDO_INSERT, UNDO_INSERT, REDO_DELETE,
  CLR_END; we abort after that, and test that CLR_END causes recovery
  to jump over UNDO_INSERT.
storage/maria/ma_write.c:
  comment
storage/maria/maria_chk.c:
  comment
storage/maria/maria_def.h:
  * a new bit in MARIA_SHARE::in_checkpoint, used to build a list
  of unique shares during Checkpoint.
  * MARIA_SHARE::lsn_of_file_id added: the LSN of the last LOGREC_FILE_ID
  for this share; needed to know to which LSN domain the mappings
  found in the Checkpoint record apply (new mappings should not apply
  to old REDOs).
storage/maria/trnman.c:
  * small changes to how trnman_collect_transactions() fills its buffer;
  it also uses a non-dummy lsn_read_non_atomic() found in ma_checkpoint.h
2007-09-12 11:27:34 +02:00
unknown
0b2ba820c3 WL#3072 Maria recovery
* testing of execution of UNDO_ROW_UPDATE
* when executing an UNDO_ROW_UPDATE, store "UNDO_ROW_UPDATE" as
"type of undone record" into the CLR_END record.


storage/maria/ma_blockrec.c:
  When logging a CLR_END in write_block_record(), it can be for
  a DELETE or for an UPDATE (now that Monty has coded execution of
  UNDO_UPDATE)
storage/maria/ma_loghandler.c:
  UNDO_ROW_UPDATE's execution coded, so no crash
storage/maria/ma_recovery.c:
  UNDO_ROW_UPDATE's execution now coded, so no crash
storage/maria/ma_test1.c:
  upper case letter
storage/maria/ma_test_recovery.expected:
  output of testing execution of UNDO_ROW_UPDATE. Table's checksum
  not recovered (known issue not specific to UPDATE).
storage/maria/ma_test_recovery:
  Test execution of UNDO_ROW_UPDATE: first we stop ma_test1 after
  deletes and commit, then we stop ma_test1 after updates and abort;
  we verify that updates are rolled back by comparing tables
2007-09-11 11:11:22 +02:00
unknown
cb2b22f0e0 Merge bk-internal.mysql.com:/home/bk/mysql-maria
into  mysql.com:/home/my/mysql-maria


storage/maria/ma_check.c:
  Auto merged
storage/maria/ma_locking.c:
  Auto merged
storage/maria/ma_loghandler.c:
  Auto merged
storage/maria/ma_open.c:
  Auto merged
storage/maria/ma_recovery.c:
  Auto merged
storage/maria/maria_def.h:
  Auto merged
storage/maria/maria_read_log.c:
  Auto merged
storage/maria/ma_blockrec.c:
  Manual merge
storage/maria/ma_test1.c:
  Manual merge (using Guilhems code)
2007-09-09 19:22:20 +03:00
unknown
155193a6e2 Added applying of undo for updates
Fixed bug in duplicate key handling for block records during repair
All read-row methods now return error number in case of error
Don't calculate checksum for null fields
Fixed bug when running maria_read_log with -o


BUILD/SETUP.sh:
  Added STACK_DIRECTION
BUILD/compile-pentium-debug-max:
  Moved STACK_DIRECTION to SETUP
include/myisam.h:
  Added extra parameter to write_key
storage/maria/ma_blockrec.c:
  Added applying of undo for updates
  Fixed indentation
  Removed some not needed casts
  Fixed wrong logging of CLR record
  Split ma_update_block_record to two functions to be able to reuse it from undo-applying
  Simplify filling of packed fields
  ma_record_block_record) now returns error number on failure
  Sligtly changed log record information for undo-update
storage/maria/ma_check.c:
  Fixed bug in duplicate key handling for block records during repair
storage/maria/ma_checksum.c:
  Don't calculate checksum for null fields
storage/maria/ma_dynrec.c:
  _ma_read_dynamic_reocrd() now returns error number on error
  Rest of the changes are code simplification and indentation fixes
storage/maria/ma_locking.c:
  Added comment
storage/maria/ma_loghandler.c:
  More debugging
  Removed printing of total_record_length as this was always same as record_length
storage/maria/ma_open.c:
  Allocate bitmap for changed fields
storage/maria/ma_packrec.c:
  read_record now returns error number on error
storage/maria/ma_recovery.c:
  Fixed wrong arguments to undo_row_update
storage/maria/ma_statrec.c:
  read_record now returns error number on error (not 1)
  Code simplification
storage/maria/ma_test1.c:
  Added exit possibility after update phase (to test undo of updates)
storage/maria/maria_def.h:
  Include bitmap header file
storage/maria/maria_read_log.c:
  Fixed bug when running with -o
2007-09-09 19:15:10 +03:00
unknown
69d7db7758 WL#3072 - Maria Recovery
At the end of recovery, we initialize the transaction manager's
trid generator with the maximum trid seen during the REDO phase.
This ensures that trids always grow (needed for versioning),
even after a crash.
This patch is only preparation, as ma_recover() is not called
from ha_maria yet.


storage/maria/ha_maria.cc:
  trnman_init() needs argument now (soon trnman_init() will rather
  be done via ma_recover() and thus it will not be 0)
storage/maria/ma_recovery.c:
  During the REDO phase, remember the max long trid of transactions
  which we have seen (both in the checkpoint record and the
  LOGREC_LONG_TRANSACTION_ID records)
storage/maria/ma_test1.c:
  trnman_init() needs argument now
storage/maria/ma_test2.c:
  trnman_init() needs argument now
storage/maria/trnman.c:
  new argument to trnman_init() so that caller can decide which
  value the generator of trids starts from.
storage/maria/trnman_public.h:
  trnman_init() needs argument now
storage/maria/unittest/trnman-t.c:
  trnman_init() needs argument now
2007-09-07 15:52:25 +02:00
unknown
2291f932b2 - WL#3072 Maria Recovery:
Recovery of state.records (the count of records which is stored into
the header of the index file). For that, state.is_of_lsn is introduced;
logic is explained in ma_recovery.c (look for "Recovery of the state").
The net gain is that in case of crash, we now recover state.records,
and it is idempotent (ma_test_recovery tests it).
state.checksum is not recovered yet, mail sent for discussion.
- WL#3071 Maria Checkpoint: preparation for it, by protecting
all modifications of the state in memory or on disk with intern_lock
(with the exception of the really-often-modified state.records,
which is now protected with the log's lock, see ma_recovery.c
(look for "Recovery of the state"). Also, if maria_close() sees that
Checkpoint is looking at this table it will not my_free() the share.
- don't compute row's checksum twice in case of UPDATE (correction
to a bugfix I made yesterday).


storage/maria/ha_maria.cc:
  protect state write with intern_lock (against Checkpoint)
storage/maria/ma_blockrec.c:
  * don't reset trn->rec_lsn in _ma_unpin_all_pages(), because it
  should wait until we have corrected the allocation in the bitmap
  (as the REDO can serve to correct the allocation during Recovery);
  introducing _ma_finalize_row() for that.
  * In a changeset yesterday I moved computation of the checksum
  into write_block_record(), to fix a bug in UPDATE. Now I notice
  that maria_update() already computes the checksum, it's just that
  it puts it into info->cur_row while _ma_update_block_record()
  uses info->new_row; so, removing the checksum computation from
  write_block_record(), putting it back into allocate_and_write_block_record()
  (which is called only by INSERT and UNDO_DELETE), and copying
  cur_row->checksum into new_row->checksum in _ma_update_block_record().
storage/maria/ma_check.c:
  new prototypes, they will take intern_lock when writing the state;
  also take intern_lock when changing share->kfile. In both cases
  this is to protect against Checkpoint reading/writing the state or reading
  kfile at the same time.
  Not updating create_rename_lsn directly at end of write_log_record_for_repair()
  as it wouldn't have intern_lock.
storage/maria/ma_close.c:
  Checkpoint builds a list of shares (under THR_LOCK_maria), then it
  handles each such share (under intern_lock) (doing flushing etc);
  if maria_close() freed this share between the two, Checkpoint
  would see a bad pointer. To avoid this, when building the list Checkpoint
  marks each share, so that maria_close() knows it should not free it
  and Checkpoint will free it itself.
  Extending the zone covered by intern_lock to protect against
  Checkpoint reading kfile, writing state.
storage/maria/ma_create.c:
  When we update create_rename_lsn, we also update is_of_lsn to
  the same value: it is logical, and allows us to test in maria_open()
  that the former is not bigger than the latter (the contrary is a sign
  of index header corruption, or severe logging bug which hinders
  Recovery, table needs a repair).
  _ma_update_create_rename_lsn_on_disk() also writes is_of_lsn;
  it now operates under intern_lock (protect against Checkpoint),
  a shortcut function is available for cases where acquiring
  intern_lock is not needed (table's creation or first open).
storage/maria/ma_delete.c:
  if table is transactional, "records" is already decremented
  when logging UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
  comments
storage/maria/ma_extra.c:
  Protect modifications of the state, in memory and/or on disk,
  with intern_lock, against a concurrent Checkpoint.
  When state goes to disk, update it's is_of_lsn (by calling
  the new _ma_state_info_write()).
  In HA_EXTRA_FORCE_REOPEN, don't set share->changed to 0 (undoing
  a change I made a few days ago) and ASK_MONTY
storage/maria/ma_locking.c:
  no real code change here.
storage/maria/ma_loghandler.c:
  Log-write-hooks for updating "state.records" under log's mutex
  when writing/updating/deleting a row or deleting all rows.
storage/maria/ma_loghandler_lsn.h:
  merge (make LSN_ERROR and LSN_REPAIRED_BY_MARIA_CHK different)
storage/maria/ma_open.c:
  When opening a table verify that is_of_lsn >= create_rename_lsn; if
  false the header must be corrupted.
  _ma_state_info_write() is split in two: _ma_state_info_write_sub()
  which is the old _ma_state_info_write(), and _ma_state_info_write()
  which additionally takes intern_lock if requested (to protect
  against Checkpoint) and updates is_of_lsn.
  _ma_open_keyfile() should change kfile.file under intern_lock
  to protect Checkpoint from reading a wrong kfile.file.
storage/maria/ma_recovery.c:
  Recovery of state.records: when the REDO phase sees UNDO_ROW_INSERT
  which has a LSN > state.is_of_lsn it increments state.records.
  Same for UNDO_ROW_DELETE and UNDO_ROW_PURGE.
  When closing a table during Recovery, we know its state is at least
  as new as the current log record we are looking at, so increase
  is_of_lsn to the LSN of the current log record.
storage/maria/ma_rename.c:
  update for new behaviour of _ma_update_create_rename_lsn_on_disk().
storage/maria/ma_test1.c:
  update to new prototype
storage/maria/ma_test2.c:
  update to new prototype (actually prototype was changed days ago,
  but compiler does not complain about the extra argument??)
storage/maria/ma_test_recovery.expected:
  new result file of ma_test_recovery. Improvements: record
  count read from index's header is now always correct.
storage/maria/ma_test_recovery:
  "rm" fails if file does not exist. Redirect stderr of script.
storage/maria/ma_write.c:
  if table is transactional, "records" is already incremented when
  logging UNDO_ROW_INSERT. Comments.
storage/maria/maria_chk.c:
  update is_of_lsn too
storage/maria/maria_def.h:
  - MARIA_STATE_INFO::is_of_lsn which is used by Recovery. It is stored
  into the index file's header.
  - Checkpoint can now mark a table as "don't free this", and maria_close()
  can reply "ok then you will free it".
  - new functions
storage/maria/maria_pack.c:
  update for new name
2007-09-07 15:02:30 +02:00
unknown
d53991853e - speed optimization:
minimize writes to transactional Maria tables: don't write
data pages, state, and open_count at the end of each statement.
Data pages will be written by a background thread periodically.
State will be written by Checkpoint periodically.
open_count serves to detect when a table is potentially damaged
due to an unclean mysqld stop, but thanks to recovery an unclean
mysqld stop will be corrected and so open_count becomes useless.
As state is written less often, it is often obsolete on disk,
we thus should avoid to read it from disk.
- by removing the data page writes above, it is necessary to put
it back at the start of some statements like check, repair and
delete_all. It was already necessary in fact (see ma_delete_all.c).
- disabling CACHE INDEX on Maria tables for now (fixes crash
of test 'key_cache' when run with --default-storage-engine=maria).
- correcting some fishy code in maria_extra.c (we possibly could lose
index pages when doing a DROP TABLE under Windows, in theory).


storage/maria/ha_maria.cc:
  disable CACHE INDEX in Maria for now (there is a single cache for now),
  it crashes and it's not a priority
storage/maria/ma_bitmap.c:
  debug message
storage/maria/ma_check.c:
  The statement before maria_repair() may not flush state,
  so it needs to be done by maria_repair() (indeed this function
  uses maria_open(HA_OPEN_COPY) so reads state from disk,
  so needs to find it up-to-date on disk).
  For safety (but normally this is not needed) we remove index blocks
  out of the cache before repairing.
  _ma_flush_blocks() becomes _ma_flush_table_files_after_repair():
  it now additionally flushes the data file and state and syncs files.
  As a side effect, the assertion "no WRITE_CACHE_USED" from
  _ma_flush_table_files() fired so we move all end_io_cache() done
  at the end of repair to before the calls to _ma_flush_table_files_after_repair().
storage/maria/ma_close.c:
  when closing a transactional table, we fsync it. But we need to
  do this only after writing its state.
  We need to write the state at close time only for transactional
  tables (the other tables do that at last unlock).
  Putting back the O_RDONLY||crashed condition which I had
  removed earlier.
  Unmap the file before syncing it (does not matter now as Maria
  does not use mmap)
storage/maria/ma_delete_all.c:
  need to flush data pages before chsize-ing it. Was needed even when
  we flushed data pages at the end of each statement, because we didn't
  anyway do it if under LOCK TABLES: the change here thus fixes this bug:
  create table t(a int) engine=maria;lock tables t write;
  insert into t values(1);delete from t;unlock tables;check table t;
  "Size of datafile is: 16384       Should be: 8192"
  (an obsolete page went to disk after the chsize(), at unlock time).
storage/maria/ma_extra.c:
  When doing share->last_version=0, we make the MARIA_SHARE-in-memory
  invisible to future openers, so need to have an up-to-date state
  on disk for them. The same way, future openers will reopen the data
  and index file, so they will not find our cached blocks, so we
  need to flush them to disk.
  In HA_EXTRA_FORCE_REOPEN, this probably happens naturally as all
  tables normally get closed, we however add a safety flush.
  In HA_EXTRA_PREPARE_FOR_RENAME, we need to do the flushing. On
  Windows we additionally need to close files.
  In HA_EXTRA_PREPARE_FOR_DROP, we don't need to flush anything but
  remove dirty cached blocks from memory. On Windows we need to close
  files.
  Closing files forces us to sync them before (requirement for transactional
  tables).
  For mutex reasons (don't lock intern_lock twice), we move
  maria_lock_database() and _ma_decrement_open_count() first in the list
  of operations.
  Flush also data file in HA_EXTRA_FLUSH.
storage/maria/ma_locking.c:
  For transactional tables:
    - don't write data pages / state at unlock time;
    as a consequence, "share->changed=0" cannot be done.
    - don't write state in _ma_writeinfo()
    - don't maintain open_count on disk (Recovery corrects the table in case of crash
    anyway, and we gain speed by not writing open_count to disk),
  For non-transactional tables, flush the state at unlock only
  if the table was changed (optimization).
  Code which read the state from disk is relevant only with
  external locking, we disable it (if want to re-enable it, it shouldn't
  for transactional tables as state on disk may be obsolete (such tables
  does not flush state at unlock anymore).
  The comment "We have to flush the write cache" is now wrong because
  maria_lock_database(F_UNLCK) now happens before thr_unlock(), and
  we are not using external locking.
storage/maria/ma_open.c:
  _ma_state_info_read() is only used in ma_open.c, making it static
storage/maria/ma_recovery.c:
  set MARIA_SHARE::changed to TRUE when we are going to apply a
  REDO/UNDO, so that the state gets flushed at close.
storage/maria/ma_test_recovery.expected:
  Changes introduced by this patch:
  - good: the "open" (table open, not properly closed) is gone,
  it was pointless for a recovered table
  - bad: stemming from different moments of writing the index's state
  probably (_ma_writeinfo() used to write the state after every row
  write in ma_test* programs, doesn't anymore as the table is
  transactional): some differences in indexes (not relevant as we don't
  yet have recovery for them); some differences in count of records
  (changed from a wrong value to another wrong value) (not relevant
  as we don't recover this count correctly yet anyway, though
  a patch will be pushed soon).
storage/maria/ma_test_recovery:
  for repeatable output, no names of varying directories.
storage/maria/maria_chk.c:
  function renamed
storage/maria/maria_def.h:
  Function became local to ma_open.c. Function renamed.
2007-09-06 16:53:26 +02:00
unknown
ac4ad9bdba WL#3072 Maria Recovery
misc fixes of execution of UNDOs in the UNDO phase:
- into the CLR_END, store the LSN of the _previous_ UNDO (we debated
what was best, so far we're going with "previous"; later we can change
to "current" if needed), and store the type of record which is being
undone (needed to know how to update state.records when we see the
CLR_END during the REDO phase).
- declaring all UNDOs and CLR_END as "compressed"
- when executing an UNDO in the UNDO phase, state.records is updated
as a hook when writing CLR_END (needed for "recovery of the state"),
and so is trn->undo_lsn (needed for when we have checkpoints).
- bugfix (execution of UNDO_ROW_DELETE didn't store the correct checksum
into the re-inserted row, maria_chk -r thus threw the row away).
- modifications of ma_test1: where to stop is now driven by --testflag;
--test-undo just tells how to stop (flush data, flush log, nothing).
- ma_test_recovery: testing of the UNDO phase, more testing of the
REDO phase, identification of a bug.


storage/maria/ma_blockrec.c:
  - bugfix: execution of UNDO_ROW_DELETE didn't store the correct
  checksum into the row (leading to "maria_chk -r" eliminating the
  re-inserted row, net effect was that rollback appeared to have
  rolled back no deletion). Reason was that write_block_record() used
  info->cur_row.checksum, while "row" can be != &info->cur_row
  (case of UNDO_ROW_DELETE). After fixing this, problems with
  _ma_update_block_record() appeared; indeed checksum was computed
  by  allocate_and_write_block_record() while _ma_update_block_record()
  directly calls write_block_record(). Solution is to compute checksum
  in write_block_record() instead.
  - when executing an UNDO, we now pass the LSN of the _previous_ UNDO
  to block_format functions. This LSN can be 0 (if the being-executed UNDO
  was the transaction's first UNDO), so "undo_lsn==0" cannot work
  anymore to indicate "this is not UNDO work". Using undo_lsn==LSN_ERROR
  instead (this is an impossible LSN).
  - store into CLR_END the type of log record which was undone
  (INSERT/UPDATE/DELETE); needed for Recovery to know if/how it has
  to update state.records if it sees this CLR_END in the REDO phase.
  - when writing the CLR_END in _ma_apply_undo_row_insert(),
  the place to store file's id is log_data+LSN_STORE_SIZE.
  - in _ma_apply_undo_row_insert(), the records-- is moved
  to a hook when writing the CLR_END (this way it is under log's mutex
  which is needed for "recovery of the state")
storage/maria/ma_loghandler.c:
  - all UNDOs, and CLR_END, start with the LSN of another UNDO; so
  we can declare them "compressed".
  - write_hook_for_clr_end() to set trn->undo_lsn (to the previous
  UNDO's LSN) under log's lock (like UNDOs set trn->undo_lsn under log's
  lock), and also update, if appropriate, state.records.
  - reset share->id to 0 when deassigning; not useful for now but
  sounds logical.
storage/maria/ma_recovery.c:
  - if no table is found for a REDO, it's not an error; for an UNDO, it is
  - in the REDO phase, when we see a CLR_END we must update trn->undo_lsn
  and sometimes state.records.
  - in the UNDO phase, when we execute an UNDO_ROW_INSERT:
    * update trn->undo_lsn only after executing the record
    * store the _previous_ undo_lsn into the CLR_END
  - at the end of the REDO phase, when we recreate TRN objects, they
  have already their long id in the log (either via a
  LOGREC_LONG_TRANSACTION_ID, or in a checkpoint record), don't write
  a new, useless LOGREC_LONG_TRANSACTION_ID for them.
storage/maria/ma_test1.c:
  * where to stop execution is now driven by --testflag and not --test-undo
  (ma_test2 already has --testflag for the same purpose). This allows
  us to do a clean stop (with commit) at any point.
  * --test-undo=# tells how to abort (flush all pages (which implies
  flushing log) or only log or nothing); all such "ways of crashing"
  are tested in ma_test_recovery
storage/maria/ma_test_recovery:
  * Testing execution of UNDOs, with and without BLOBs.
  * Testing idempotency of REDOs.
  * See @todo for a probable bug with BLOBs.
  * maria_chk -rq instead of -r, as with -q it nicely stops on any
  problem in the data file (like the checksum bug see comment of
  ma_blockrec.c).
  * Testing if log was written by UNDO phase (often expected),
  not written by REDO phase (always expected).
  * Less output on the screen, compares with expected output in the end.
  * some shell thingies like "set --" and $# are courtesy of
  Danny and Pekka.
storage/maria/maria_read_log.c:
  when only displaying the records, don't do an UNDO phase
storage/maria/ma_test_recovery.expected:
  This is the expected output of a great part of ma_test_recovery.
  ma_test_recovery compares its output to the expected output
  and tells if different.
  If we look at this file it mentions differences in checksum
  (normal, it's not recovered yet) and in records count
  (getting a correct records' count when recovery starts on an
  already existing table, like when testing rollback,
  is coded but not yet pushed).
2007-09-06 16:04:36 +02:00
unknown
044c4103ba Added undo of deleted row
Added part of undo of update row
Extended ma_test1 for recovery testing
Some bug fixes


storage/maria/ha_maria.cc:
  Ignore 'state.split' in case of block records
storage/maria/ma_bitmap.c:
  Added return value for _ma_bitmap_find_place() for how much data we should put on head page
storage/maria/ma_blockrec.c:
  Added undo of deleted row.
  - Added logging of CLR_END records in write_block_record()
  - Split ma_write_init_block_record() to two functions to get better code reuse
  - Added _ma_apply_undo_row_delete()
  - Added ma_get_length()
  
  Added 'empty' prototype for undo_row_update()
  
  Fixed bug when moving data withing a head/tail page.
  Fixed bug when reading a page with bigger LSN but of different type than was expected.
  Store undo_lsn first in CLR_END record
  
  Simplified some code by adding local variables.
  Changed log format for UNDO_ROW_DELETE to store total length of used blobs
storage/maria/ma_blockrec.h:
  Added prototypes for undo code.
storage/maria/ma_pagecache.c:
  Allow plain page to change to LSN page (needed in recovery to apply UNDO)
storage/maria/ma_recovery.c:
  Added undo handling of UNDO_ROW_DELETE and UNDO_ROW_UPDATE
storage/maria/ma_test1.c:
  Extended --test-undo option to allow us to die after insert or after delete.
  Fixed bug in printing key values when using -v
storage/maria/maria_def.h:
  Moved some variables around to be getter alignment
  Added length_buff buffer to be used during undo handling
2007-09-05 02:57:53 +03:00
unknown
03437ea043 Added UNDO handling of insert during recovery
storage/maria/ma_blockrec.c:
  Added UNDO handling of insert during recovery
  To do this, I also had to add write locking of tail pages during undo phase (As we need to access the same page twice if extents are split over two pages)
  Another way to handle the undo of insert would be to store the extent information as part of the UNDO_INSERT block.
storage/maria/ma_blockrec.h:
  Added new prototype
storage/maria/ma_loghandler.c:
  Changed type of CLR_END (to avoid crash in log handler)
  Removed not used variable
storage/maria/ma_loghandler.h:
  Added TRN argument to record_execute_in_undo_phase()
storage/maria/ma_pagecache.c:
  Hack for undo phase of recovery.  During REDO we work with PLAIN pages, but UNDO works with LSN pages, which caused an abort when trying to access a cached page.
storage/maria/ma_recovery.c:
  Added execution of UNDO_ROW_INSERT
storage/maria/ma_test1.c:
  Added option --test-undo for testing recovery with undo
storage/maria/maria_read_log.c:
  Added processing of undos
2007-09-04 10:53:52 +03:00
unknown
5183a4b00b Fixed several bugs found by running *.test with maria engine
Renamed HA_EXTRA_PREAPRE_FOR_DELETE to HA_EXTRA_PERPARE_FOR_DROP
Added HA_EXTRA_PREPARE_FOR_RENAME (as we in the code before used HA_EXTRA_PREPARE_FOR_DELETE also for renames which confused things)
Allow multiple write locks for same page by same file handle
Don't write table state if table is not changed


include/my_base.h:
  Renamed HA_EXTRA_PREAPRE_FOR_DELETE to HA_EXTRA_PERPARE_FOR_DROP
  Added HA_EXTRA_PREPARE_FOR_RENAME (as we in the code before used HA_EXTRA_PREPARE_FOR_DELETE also for renames which confused things)
mysql-test/r/maria.result:
  More tests of things that failed in other tests
mysql-test/t/maria.test:
  More tests of things that failed in other tests
sql/ha_partition.cc:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
  Use HA_EXTRA_PREPARE_FOR_RENAME for renames
sql/ha_partition.h:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
  Use HA_EXTRA_PREPARE_FOR_RENAME for renames
sql/lock.cc:
  Fixed comment
sql/sql_table.cc:
  Fixed wrong usage of HA_EXTRA_PREAPRE_FOR_DELETE
storage/maria/ha_maria.cc:
  Added missing _ma_renable_logging_for_table()  (When using with ALTER TABLE + repair index)
  Enabled fast generation of index
storage/maria/ma_bitmap.c:
  Fixed bug when resetting full pages when page was a tail page
storage/maria/ma_blockrec.c:
  Fixed several bugs found by running *.test with maria engine:
  During update we keep old changed pages locked with a write lock to be able to reuse them.
  - Fixed bug with allocated but not used tail part
  - Fixed bug with blob that only had tail part
  - Fixed bug when update reused a page (needed multiple write locks for same page)
  - Fixed bug when first extent was a tail block
storage/maria/ma_check.c:
  Better error message when bitmap is destroyed
storage/maria/ma_close.c:
  Only write status if file was changed.
  Fixed bug when maria_chk -e file_name changed the file.
storage/maria/ma_dynrec.c:
  Removed not used argument to _ma_state_info_read_dsk
storage/maria/ma_extra.c:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
  Use HA_EXTRA_PREPARE_FOR_RENAME for renames
  Only ignore flushing of pages for DROP (not rename)
storage/maria/ma_locking.c:
  Removed not used argument to _ma_state_info_read_dsk
storage/maria/ma_open.c:
  Removed not used argument to _ma_state_info_read_dsk
storage/maria/ma_pagecache.c:
  Allow multiple write locks for same page by same file handle
  (Not yet complete, Sanja will fix)
storage/maria/ma_recovery.c:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
storage/maria/maria_def.h:
  Removed not used argument to _ma_state_info_read_dsk
storage/myisam/mi_extra.c:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
  Use HA_EXTRA_PREPARE_FOR_RENAME for renames
  Only ignore flushing of pages for DROP (not rename)
storage/myisammrg/ha_myisammrg.cc:
  HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP
  Use HA_EXTRA_PREPARE_FOR_RENAME for renames
2007-09-03 12:05:17 +03:00
unknown
90b63bf754 WL#3072 Maria recovery
manual merge of ma_recovery.c (too big conflict to resolve in fmtool);
the merged Monty's code allows correct replaying of REDO_PURGE_BLOCKS
and was originally in
monty@mysql.com/narttu.mysql.fi|ChangeSet|20070829060310|44058


storage/maria/ma_recovery.c:
  * manually merging Monty's and Sanja's changes of the two last weeks
  to my massively modified version of this file. The merged Monty's
  code allows correct replaying of REDO_PURGE_BLOCKS and was originally
  in monty@mysql.com/narttu.mysql.fi|ChangeSet|20070829060310|44058 .
  * Setting the state to "STATE_CHANGED|etc" in Recovery is more
  logically done when we update the state in memory (for example
  records++).
2007-08-29 22:02:30 +02:00
unknown
e27890cab0 WL#3072 Maria recovery
* 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
2007-08-29 16:43:01 +02:00
unknown
2cccfcd8dd Applying Sanja's patch which makes the log handler not issue
errors when reading a log record which has a 0-length header
(like LOGREC_REDO_DROP_TABLE).


storage/maria/ma_loghandler.c:
  Functions reading record's header now don't use 0 to indicate error,
  as some valid records have a 0-length header (like REDO_DROP_TABLE).
  Instead, negative values are used for EOF and error.
storage/maria/ma_loghandler.h:
  functions to read record's header now return an int
  (either the length of this header (>=0) or some negative values
  for EOF or error).
storage/maria/ma_recovery.c:
  update to the new log handler's behaviour. Note the @todo.
storage/maria/maria_read_log.c:
  inform when program failed
storage/maria/unittest/ma_test_loghandler-t.c:
  update to new log handler's API
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
  update to new log handler's API
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
  update to new log handler's API
2007-07-30 15:05:43 +02:00
unknown
662002fc8f post-merge fixes, and fixes for some of the 16 compiler warnings
found in pushbuild on sapsrv1. Some not fixed as not repeatable
on my machine (32/64 bit issue?).
Fixes for some test failures:
- "maria-connect" now passes;
- "maria": after fixing the obvious reasons for failures, the test
went further and hit a more complex issues: difference in the output
of EXPLAIN output; not fixed;
- "ps_maria" still crashes in assertion
mysqld: ha_maria.cc:1627: virtual int ha_maria::index_read(uchar*, const uchar*, uint, ha_rkey_function): Ass
ertion `inited == INDEX' failed, as already observable in pushbuild.
All this might just be due to an incomplete merge of MyISAM changes
into Maria when 5.1 was last merged to mysql-maria.


include/my_global.h:
  temporary fix until next merge of 5.1; without this it does not build
mysql-test/r/maria-connect.result:
  position changed
mysql-test/t/maria-connect.test:
  If one wants to use the binlog it has to ask for it.
  1582 is not used for dup entry error anymore (it was in older 5.1).
  Size of first event in binlog was increased by 4 (when the new type
  of event "gap" was added).
mysql-test/t/maria.test:
  1582 not used anymore in this case
storage/maria/ha_maria.cc:
  engine now has to say what binlogging it supports
storage/maria/ma_blockrec.c:
  fix for compiler warnings ("comparison is always true" or "always
  false")
storage/maria/ma_loghandler.c:
  fix for compiler warnings (comparing char* to uchar*)
storage/maria/ma_packrec.c:
  fix for compiler warning (fix simply merged from MyISAM)
storage/maria/ma_pagecache.c:
  info_check_pin() was not used so gave a compiler warning.
storage/maria/ma_pagecache.h:
  fixing typo from the last 5.1->maria merge.
storage/maria/ma_recovery.c:
  my_free() has a void* argument, so why cast. byte->uchar.
storage/maria/ma_search.c:
  fix for compiler warning (fix simply merged from MyISAM)
storage/maria/maria_read_log.c:
  gptr->uchar*
storage/maria/trnman.c:
  probable fix for warning found in pushbuild (but not on my machine):
  storage/maria/trnman.c: 142
   passing argument 6 of \u2018lf_hash_init\u2019 from incompatible pointer type
  on sapsrv1.
2007-07-26 17:51:49 +02:00
unknown
6bbca54d7d WL#3072 - Maria recovery
Unit test for recovery: runs ma_test1 and ma_test2 (both only with
INSERTs and DELETEs; UPDATEs disabled as not handled by recovery)
then moves the tables elswhere; recreates tables from the log, and
compares and fails if there is a difference. Passes now.
Most of maria_read_log.c moved to ma_recovery.c, as it will be re-used
for recovery-from-ha_maria.
Bugfixes of applying of REDO_INSERT, REDO_PURGE_ROW.
Applying of REDO_PURGE_BLOCKS, REDO_DELETE_ALL, REDO_DROP_TABLE,
UNDO_ROW_INSERT (in REDO phase only, i.e. just doing records++),
UNDO_ROW_DELETE, UNDO_ROW_PURGE.
Code cleanups.
Monty: please look for "QQ". Sanja: please look for "Sanja".
Future tasks: recovery of the bitmap (easy), recovery of the state
(make it idempotent), more REDOs (Monty to work on
REDO_UPDATE?), UNDO phase...
Pushing this cset as it looks safe, contains test and bugfixes which
will help Monty implement applying of REDO_UPDATE.


sql/handler.cc:
  typo
storage/maria/Makefile.am:
  Adding ma_test_recovery (which ma_test_all invokes, and which can
  also be run alone). Most of maria_read_log.c moved to ma_recovery.c
storage/maria/ha_maria.cc:
  comments
storage/maria/ma_bitmap.c:
  fixing comments. 2 -> sizeof(maria_bitmap_marker).
  Bitmap-related part of _ma_initialize_datafile() moves in bitmap module.
  Now putting the "bm" signature when creating the first bitmap page
  (it used to happen only at next open, but that
  caused an annoying difference when testing Recovery if the original
  run didn't open the table, and it looks more
  logical like this: it goes to disk only with its signature correct);
  see the "QQ" comment towards the _ma_initialize_data_file() call
  in ma_create.c for more).
  When reading a bitmap page, verify its signature (happens when normally
  using the table or when CHECKing it; not when REPAIRing it).
storage/maria/ma_blockrec.c:
  * no need to sync the data file if table is not transactional
  * Comments, code cleanup (log-related data moved to log-related code
  block, int5store->page_store).
  * Store the table's short id into LOGREC_UNDO_ROW_PURGE, like we
  do for other records (though this record will soon be replaced
  with a CLR).
  * If "page" is 1 it means the page which extends from byte
  page*block_size+1 to (page+1)*block_size (byte number 1 being
  the first byte of the file). The last byte of the file is
  data_file_length (same convention).
  A new page needs to be created if the last byte of the page is
  beyond the last byte of the file, i.e.
   (page+1)*block_size+1 > data_file_length, so we correct the test
  (bug found when testing log applying for ma_test1 -M -T --skip-update).
  * update the page's LSN when removing a row from it during
  execution of a REDO_PURGE_ROW record (bug found when testing log
  applying for ma_test1 -M -T --skip-update).
  * applying of REDO_PURGE_BLOCKs (limited to a one-page range for now).
storage/maria/ma_blockrec.h:
  new functions. maria_bitmap_marker does not need to be exported.
storage/maria/ma_close.c:
  we can always flush the table's state when closing the last instance
  of the table. And it is needed for maria_read_log (as it does
  not use maria_lock_database()).
storage/maria/ma_control_file.c:
  when in Recovery, some assertions should not be used.
storage/maria/ma_control_file.h:
  double-inclusion safe
storage/maria/ma_create.c:
  during recovery, don't log records. Comments.
  Moving the creation of the first bitmap page to ma_bitmap.c
storage/maria/ma_delete_table.c:
  during recovery, don't log records. Log the end-zero of the dropped
  table's name, so that recovery can use the string in place without
  extending it to fit an end zero.
storage/maria/ma_loghandler.c:
  * inwrite_rec_hook also needs access to the MARIA_SHARE, like
  prewrite_rec_hook. This will be needed to update
  share->records_diff (in the upcoming patch "recovery of the state").
  * LOG_DESC::record_ends_group changed to an enum.
  * LOG_DESC for LOGREC_REDO_PURGE_BLOCKS and LOGREC_UNDO_ROW_PURGE
  corrected
  * Sanja please see the @todo LOG BUG
  * avoiding DBUG_RETURN(func()) as it gives confusing debug traces.
storage/maria/ma_loghandler.h:
  - log write hooks called while the log's lock is held (inwrite_rec_hook)
  now need the MARIA_SHARE, like prewrite_rec_hook already had
  - instead of a bool saying if this record's type ends groups or not,
  we refine: it may not end a group, it may end a group, or it may
  be a group in itself. Imagine that we had a physical write failure
  to a table before we log the UNDO, we still end up in
  external_lock(F_UNLCK) and then we log a COMMIT: we don't want
  to consider this COMMIT as ending the group of REDOs (don't want
  to execute those REDOs during Recovery), that's why we say "COMMIT
  is a group in itself, it aborts any previous group". This also
  gives one more sanity check in maria_read_log.
storage/maria/ma_recovery.c:
  New Recovery code, replacing the old pseudocode.
  Most of maria_read_log moved here.
  Call-able from ha_maria, but not enabled yet.
  Compared to the previous version of maria_read_log, some bugs have
  been fixed, debugging output can go to stdout or a disk file (for now
  it's useful for me, later it can be changed), execution of
  REDO_DROP_TABLE, REDO_DELETE_ALL, REDO_PURGE_BLOCKS has been added. Duplicate code
  has been factored into functions. We abort an unfinished group
  of records if we see a record which is a group in itself (like COMMIT).
  No need for maria_panic() after a bug (which caused tables to not
  be closed) was fixed; if there is yet another bug I prefer to see it.
  When opening a table for Recovery, set data_file_length
  and key_file_length to their real physical value (these are the
  easiest state members to restore :). Warn us if the last page
  was truncated (but Recovery handles it).
  MARIA_SHARE::state::state::records is now partly recovered (not
  idempotent, but works if recreating tables from scracth).
  When applying a REDO to a page, stamp it with the UNDO's LSN
  (current_group_end_lsn), not with the REDO's LSN; it makes
  the table more identical to the original table (easier to compare
  the two tables in the end).
  Big thing missing: some types of REDOs are not handled,
  and the UNDO phase does not exist (missing functions to execute UNDOs
  to actually rollback). So for now tests are only inserting/deleting
  a few 100 rows, closing the table and seeing if the log is applied ok;
  it works. UPDATE not handled.
storage/maria/ma_recovery.h:
  new functions: ma_recover() for recovery from inside ha_maria;
  _ma_apply_log() for maria_read_log (ma_recover() calls _ma_apply_log()).
  Btw, we need to not use the word "recover" for REPAIR/maria_chk anymore.
storage/maria/ma_rename.c:
  don't write log records during recovery
storage/maria/ma_test2.c:
  - fail if maria_info() or other subtests find some wrong information
  - new option -g to skip updates.
  - init the translog before creating the table, so that log applying
  can work.
  - in "#if 0" you'll see some fixed bugs (will be removed).
storage/maria/ma_test_all.sh:
  cleanup files. Test log applying.
storage/maria/maria_read_log.c:
  most of the logic moves to ma_recovery.c to be shared between
  maria_read_log and recovery-from-inside-mysqld.
  See ma_recovery.c for additional changes made to the moved code.
storage/maria/ma_test_recovery:
  unit test for Recovery. Tests insert and delete,
  REDO_UPDATE not yet coded.
  Script is called from ma_test_all. Can run standalone.
2007-07-26 11:56:21 +02:00
unknown
46922b5125 GPL license update (same change as was done for all files in 5.1).
storage/maria/Makefile.am:
  GPL license update
storage/maria/ft_maria.c:
  GPL license update
storage/maria/ha_maria.cc:
  GPL license update
storage/maria/ha_maria.h:
  GPL license update
storage/maria/lockman.c:
  GPL license update
storage/maria/lockman.h:
  GPL license update
storage/maria/ma_bitmap.c:
  GPL license update
storage/maria/ma_blockrec.c:
  GPL license update
storage/maria/ma_blockrec.h:
  GPL license update
storage/maria/ma_cache.c:
  GPL license update
storage/maria/ma_changed.c:
  GPL license update
storage/maria/ma_check.c:
  GPL license update
storage/maria/ma_checkpoint.c:
  GPL license update
storage/maria/ma_checkpoint.h:
  GPL license update
storage/maria/ma_checksum.c:
  GPL license update
storage/maria/ma_close.c:
  GPL license update
storage/maria/ma_control_file.c:
  GPL license update
storage/maria/ma_control_file.h:
  GPL license update
storage/maria/ma_create.c:
  GPL license update
storage/maria/ma_dbug.c:
  GPL license update
storage/maria/ma_delete.c:
  GPL license update
storage/maria/ma_delete_all.c:
  GPL license update
storage/maria/ma_delete_table.c:
  GPL license update
storage/maria/ma_dynrec.c:
  GPL license update
storage/maria/ma_extra.c:
  GPL license update
storage/maria/ma_ft_boolean_search.c:
  GPL license update
storage/maria/ma_ft_eval.c:
  GPL license update
storage/maria/ma_ft_eval.h:
  GPL license update
storage/maria/ma_ft_nlq_search.c:
  GPL license update
storage/maria/ma_ft_parser.c:
  GPL license update
storage/maria/ma_ft_stem.c:
  GPL license update
storage/maria/ma_ft_test1.c:
  GPL license update
storage/maria/ma_ft_test1.h:
  GPL license update
storage/maria/ma_ft_update.c:
  GPL license update
storage/maria/ma_ftdefs.h:
  GPL license update
storage/maria/ma_fulltext.h:
  GPL license update
storage/maria/ma_info.c:
  GPL license update
storage/maria/ma_init.c:
  GPL license update
storage/maria/ma_key.c:
  GPL license update
storage/maria/ma_keycache.c:
  GPL license update
storage/maria/ma_least_recently_dirtied.c:
  GPL license update
storage/maria/ma_least_recently_dirtied.h:
  GPL license update
storage/maria/ma_locking.c:
  GPL license update
storage/maria/ma_open.c:
  GPL license update
storage/maria/ma_packrec.c:
  GPL license update
storage/maria/ma_page.c:
  GPL license update
storage/maria/ma_panic.c:
  GPL license update
storage/maria/ma_preload.c:
  GPL license update
storage/maria/ma_range.c:
  GPL license update
storage/maria/ma_recovery.c:
  GPL license update
storage/maria/ma_recovery.h:
  GPL license update
storage/maria/ma_rename.c:
  GPL license update
storage/maria/ma_rfirst.c:
  GPL license update
storage/maria/ma_rkey.c:
  GPL license update
storage/maria/ma_rlast.c:
  GPL license update
storage/maria/ma_rnext.c:
  GPL license update
storage/maria/ma_rnext_same.c:
  GPL license update
storage/maria/ma_rprev.c:
  GPL license update
storage/maria/ma_rrnd.c:
  GPL license update
storage/maria/ma_rsame.c:
  GPL license update
storage/maria/ma_rsamepos.c:
  GPL license update
storage/maria/ma_rt_index.c:
  GPL license update
storage/maria/ma_rt_index.h:
  GPL license update
storage/maria/ma_rt_key.c:
  GPL license update
storage/maria/ma_rt_key.h:
  GPL license update
storage/maria/ma_rt_mbr.c:
  GPL license update
storage/maria/ma_rt_mbr.h:
  GPL license update
storage/maria/ma_rt_split.c:
  GPL license update
storage/maria/ma_rt_test.c:
  GPL license update
storage/maria/ma_scan.c:
  GPL license update
storage/maria/ma_search.c:
  GPL license update
storage/maria/ma_sort.c:
  GPL license update
storage/maria/ma_sp_defs.h:
  GPL license update
storage/maria/ma_sp_key.c:
  GPL license update
storage/maria/ma_sp_test.c:
  GPL license update
storage/maria/ma_static.c:
  GPL license update
storage/maria/ma_statrec.c:
  GPL license update
storage/maria/ma_test1.c:
  GPL license update
storage/maria/ma_test2.c:
  GPL license update
storage/maria/ma_test3.c:
  GPL license update
storage/maria/ma_unique.c:
  GPL license update
storage/maria/ma_update.c:
  GPL license update
storage/maria/ma_write.c:
  GPL license update
storage/maria/maria_chk.c:
  GPL license update
storage/maria/maria_def.h:
  GPL license update
storage/maria/maria_ftdump.c:
  GPL license update
storage/maria/maria_pack.c:
  GPL license update
storage/maria/tablockman.c:
  GPL license update
storage/maria/tablockman.h:
  GPL license update
storage/maria/trnman.c:
  GPL license update
storage/maria/trnman.h:
  GPL license update
2007-03-02 11:20:23 +01:00
unknown
cdf831cf94 WL#3071 Maria checkpoint:
changing pseudocode to use the structures of the Maria pagecache
    ("pagecache->changed_blocks" etc) and other Maria structures
    inherited from MyISAM (THR_LOCK_maria etc).


mysys/mf_pagecache.c:
  comment
storage/maria/ma_checkpoint.c:
  changing pseudocode to use the structures of the Maria pagecache
  ("pagecache->changed_blocks" etc) and other Maria structures
  inherited from MyISAM (THR_LOCK_maria etc).
storage/maria/ma_checkpoint.h:
  copyright
storage/maria/ma_control_file.c:
  copyright
storage/maria/ma_control_file.h:
  copyright
storage/maria/ma_least_recently_dirtied.c:
  copyright
storage/maria/ma_least_recently_dirtied.h:
  copyright
storage/maria/ma_recovery.c:
  copyright
storage/maria/ma_recovery.h:
  copyright
storage/maria/unittest/Makefile.am:
  copyright
2006-09-14 19:06:51 +02:00
unknown
a1f25544d5 WL#3234 "Maria - control file manager"
- fixes to the control file module
- unit test for it
- renames of all Maria files I created to start with ma_


storage/maria/ma_checkpoint.c:
  Rename: storage/maria/checkpoint.c -> storage/maria/ma_checkpoint.c
storage/maria/ma_checkpoint.h:
  Rename: storage/maria/checkpoint.h -> storage/maria/ma_checkpoint.h
storage/maria/ma_least_recently_dirtied.c:
  Rename: storage/maria/least_recently_dirtied.c -> storage/maria/ma_least_recently_dirtied.c
storage/maria/ma_least_recently_dirtied.h:
  Rename: storage/maria/least_recently_dirtied.h -> storage/maria/ma_least_recently_dirtied.h
storage/maria/ma_recovery.c:
  Rename: storage/maria/recovery.c -> storage/maria/ma_recovery.c
storage/maria/ma_recovery.h:
  Rename: storage/maria/recovery.h -> storage/maria/ma_recovery.h
storage/maria/Makefile.am:
  control file module and its unit test program
storage/maria/ma_control_file.c:
  DBUG_ tags. Fix for gcc warnings.
  log_no -> logno (I felt "_no" sounded like a standalone "No" word).
  ma_ prefix for some functions.
  last_checkpoint_lsn_at_startup -> last_checkpoint_lsn (no need
  to make special vars for the values at startup). Same for last_logno.
  ma_control_file_write_and_force() now updates last_checkpoint_lsn
  and last_logno, the idea being that they belong to the module,
  others should not update them.
  And thus when the module shuts down, it zeroes those vars.
storage/maria/ma_control_file.h:
  importing structs from Sanja to get the control file module to compile;
  we'll remove that when Sanja pushes the log handler.
  CONTROL_FILE_IMPOSSIBLE_LOGNO is 0, not FFFFFFFF.
storage/maria/ma_control_file_test.c:
  Unit test program for the Maria control file module.
  Modelled after other ma_test* files in this directory (so, does
  not follow the unit test framework recently introduced with libtap;
  TODO as a task on all ma_test* programs).
  We test that writing to the control file works, and re-reading from it
  too, we check (by reading the file by ourselves) that its content
  on disk is correct, and check that a corrupted control file is detected.
2006-09-01 17:53:10 +02:00
Renamed from storage/maria/recovery.c (Browse further)