1. 20 Nov, 2007 2 commits
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-maria · 11afc5d4
      unknown authored
      into  mysql.com:/home/my/mysql-maria
      
      
      include/my_sys.h:
        Auto merged
      sql/mysqld.cc:
        Auto merged
      storage/maria/ma_checkpoint.c:
        Auto merged
      storage/maria/ma_pagecache.c:
        Auto merged
      storage/maria/ma_pagecache.h:
        Auto merged
      storage/maria/maria_chk.c:
        Auto merged
      storage/maria/ma_recovery.c:
        SCCS merged
      11afc5d4
    • unknown's avatar
      Fixes for redo/undo logging of key pages · ea6ec89e
      unknown authored
      New extendable format for maria_log_control file
      Fixed some compiler warnings
      
      
      include/maria.h:
        Added maria_disable_logging() and maria_enable_logging()
      mysql-test/include/maria_verify_recovery.inc:
        Updated tests now when key redo/undo works
      mysql-test/r/maria-recovery.result:
        Updated tests now when key redo/undo works
      storage/maria/ma_blockrec.c:
        Use unified CLR code
        Added rec_lsn for full pages
        Moved clr write hook to ma_key_recover.c
        Changed REDO code to keep pages pinned until undo
        Mark page_link's as changed
      storage/maria/ma_blockrec.h:
        Moved write_hook_for_clr_end() to ma_key_recover.c
      storage/maria/ma_check.c:
        Changed key check code to use PAGECACHE_READ_UNKNOWN_PAGE
        Fixed wrong warning when checking files after maria_pack
        When unpacking files, we have to use new keypos_to_recpos method
        When doing repair, we can disregard index key file pages in page cache
      storage/maria/ma_commit.c:
        Added simple enable/disable logging functions
        (Needed for recovery)
      storage/maria/ma_control_file.c:
        Make maria control file extendable without having to make it incompatible for older versions
      storage/maria/ma_control_file.h:
        New error messages
        Added CONTROL_FILE_VERSION
      storage/maria/ma_delete.c:
        Added redo/undo for key pages
        change_length -> changed_length to make things similar
        More comments & more DBUG
      storage/maria/ma_key_recover.c:
        Unified CLR method
        Moved here write_hook_for_clr_end() and common keypage log functions
        Changed REDO to keep pages pinned until undo
        Changed UNDO code to change key_root under log mutex
      storage/maria/ma_key_recover.h:
        New structures and functions
      storage/maria/ma_loghandler.c:
        Include needed files
      storage/maria/ma_open.c:
        Change maria_open() to use pread() instead of read()
      storage/maria/ma_page.c:
        Fixed bug in key_del handling
        Clear pages if IDENTICAL_PAGES_AFTER_RECOVERY is defined
      storage/maria/ma_pagecache.c:
        Indentation and spelling fixes
        More DBUG
        Added helper function: pagecache_block_link_to_buffer()
      storage/maria/ma_pagecache.h:
        Added pagecache_block_link_to_buffer()
      storage/maria/ma_recovery.c:
        Fixed state.changed
        Fixed that REDO keeps pages pinned until UNDO
        Some bug fixes from previous commit
        Fixes for UNDO/REDO of key pages
      storage/maria/ma_search.c:
        Fixed packing and storing of keys to provide more information to caller so
        that we can do efficent REDO logging of the changes.
      storage/maria/ma_test1.c:
        Fixed bug with not initialized variable
      storage/maria/ma_test2.c:
        Removed not used code
      storage/maria/ma_test_all.res:
        Updated results
      storage/maria/ma_test_all.sh:
        Changed one test to test more
        Removed timing tests as not relevant here
      storage/maria/ma_test_recovery.expected:
        Updated test result after redo/undo if key pages works
      storage/maria/ma_test_recovery:
        Updated test after redo/undo if key pages works
      storage/maria/ma_write.c:
        Moved some general log functions to ma_key_recover.c
        Fixed some bugs in undo
        Moved ma_log_split() to _ma_split_page()
        Small changes in some function arguments to be able to do redo logging
      storage/maria/maria_chk.c:
        disable logging while doing repair table
      storage/maria/maria_def.h:
        New function prototypes
        Move some structs and functions to ma_key_recover.c
      storage/maria/unittest/ma_control_file-t.c:
        Updated with patch from Sanja
        NOTE: This is not complete and need to be updated to new control file format
      storage/maria/unittest/ma_test_loghandler-t.c:
        Fixed compiler warning
      ea6ec89e
  2. 16 Nov, 2007 3 commits
    • unknown's avatar
      WL#3071 Maria checkpoint, WL#3072 Maria recovery · 2c6961ef
      unknown authored
      instead of fprintf(stderr) when a task (with no user connected) gets
      an error, use my_printf_error(). Flags ME_JUST_WARNING and ME_JUST_INFO
      added to my_error()/my_printf_error(), which pass it to
      my_message_sql() which is modified to call the appropriate
      sql_print_*(). This way recovery can signal its start and end with
      [Note] and not [ERROR] (but failure with [ERROR]).
      Recovery's detailed progress (percents etc) still uses stderr as they
      have to stay on one single line.
      sql_print_error() changed to use my_progname_short (nicer display).
      mysql-test-run.pl --gdb/--ddd does not run mysqld, because
      a breakpoint in mysql_parse is too late to debug startup problems;
      instead, dev should set the breakpoints it wants and then "run" ("r").
      
      
      include/my_sys.h:
        new flags to tell error_handler_hook that this is not an error
        but an information or warning
      mysql-test/mysql-test-run.pl:
        when running with --gdb/--ddd to debug mysqld, breaking at mysql_parse
        is too late to debug startup problems; now, it does not run mysqld,
        does not set breakpoints, developer can set as early breakpoints
        as it wants and is responsible for typing "run" (or "r")
      mysys/my_init.c:
        set my_progname_short
      mysys/my_static.c:
        my_progname_short added
      sql/mysqld.cc:
        * my_message_sql() can now receive info or warning, not only error;
        this allows mysys to tell the user (or the error log if no user)
        about an info or warning. Used from Maria.
        * plugins (or engines like Maria) may want to call my_error(), so
        set up the error handler hook (my_message_sql) before initializing
        plugins; otherwise they get my_message_no_curses which is less
        integrated into mysqld (is just fputs())
        * using my_progname_short instead of my_progname, in my_message_sql()
        (less space on screen)
      storage/maria/ma_checkpoint.c:
        fprintf(stderr) -> ma_message_no_user()
      storage/maria/ma_checkpoint.h:
        function for any Maria task, not connected to a user (example:
        checkpoint, recovery; soon could be deleted records purger)
        to report a message (calls my_printf_error() which, when inside ha_maria,
        leads to sql_print_*(), and when outside, leads to
        my_message_no_curses i.e. stderr).
      storage/maria/ma_recovery.c:
        To tell that recovery starts and ends we use ma_message_no_user()
        (sql_print_*() in practice). Detailed progress info still uses
        stderr as sql_print() cannot put several messages on one line.
        071116 18:42:16 [Note] mysqld: Maria engine: starting recovery
        recovered pages: 0% 67% 100% (0.0 seconds); transactions to roll back: 1 0 (0.0
        seconds); tables to flush: 1 0 (0.0 seconds);
        071116 18:42:16 [Note] mysqld: Maria engine: recovery done
      storage/maria/maria_chk.c:
        my_progname_short moved to mysys
      storage/maria/maria_read_log.c:
        my_progname_short moved to mysys
      storage/myisam/myisamchk.c:
        my_progname_short moved to mysys
      2c6961ef
    • unknown's avatar
      WL#3071 Maria checkpoint · 38c23ade
      unknown authored
      background page flushing was using dfile even when it wanted to flush
      the index file.
      
      
      storage/maria/ma_checkpoint.c:
        * filter_flush_data_file* functions are in fact for the index file too,
        renaming them.
        * flush of index file was using dfile (bad copy-paste)
      38c23ade
    • unknown's avatar
      Flush status differentiation between error and skipping pinned pages. · 9f42986b
      unknown authored
      
      storage/maria/ma_checkpoint.c:
        React only on errors during the flush.
      9f42986b
  3. 14 Nov, 2007 3 commits
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-maria · 6ceb1a47
      unknown authored
      into  mysql.com:/home/my/mysql-maria
      
      
      storage/maria/ha_maria.cc:
        Auto merged
      storage/maria/ma_bitmap.c:
        Auto merged
      storage/maria/ma_checkpoint.c:
        Auto merged
      storage/maria/ma_close.c:
        Auto merged
      storage/maria/ma_loghandler.c:
        Auto merged
      storage/maria/ma_loghandler.h:
        Auto merged
      storage/maria/ma_open.c:
        Auto merged
      storage/maria/ma_pagecache.h:
        Auto merged
      storage/maria/ma_write.c:
        Auto merged
      storage/maria/maria_def.h:
        Auto merged
      storage/maria/unittest/ma_pagecache_single.c:
        Auto merged
      storage/maria/ma_blockrec.c:
        Manual merge
      storage/maria/ma_page.c:
        Manual merge
      storage/maria/ma_pagecache.c:
        Manual merge
      storage/maria/ma_preload.c:
        Manual merge
      storage/maria/ma_recovery.c:
        Manual merge
        Add _ma_unpin_all_pages() to all new UNDO redo_exec_hook's
      6ceb1a47
    • unknown's avatar
      First part of redo/undo for key pages · 5d6ee443
      unknown authored
      Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
      For transactional tables, shift record number in keys up with 1 bit to have place to indicate if transid follows
      Checksum for MyISAM now ignores NULL and not used part of VARCHAR
      Renamed some variables that caused shadow compiler warnings
      Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
      Fixed crashing bugs when using Maria TEMPORARY tables with TRUNCATE. Removed 'hack' code in sql directory to go around this bug.
      pagecache_unlock_by_ulink() now has extra argument to say if page was changed.
      Give error message if we fail to open control file
      Mark page cache variables as not flushable
      
      
      include/maria.h:
        Made min page cache larger (needed for pinning key page)
        Added key_nr to st_maria_keydef for faster keyinfo->keynr conversion
        Added write_comp_flag to move some runtime code to maria_open()
      include/my_base.h:
        Added new error message to be used when handler initialization failed
      include/my_global.h:
        Renamed dummy to swap_dummy to avoid conflicts with local 'dummy' variables
      include/my_handler.h:
        Added const to some parameters
      mysys/array.c:
        More DBUG
      mysys/my_error.c:
        Fixed indentation
      mysys/my_handler.c:
        Added const to some parameters
        Added missing error messages
      sql/field.h:
        Renamed variables to avoid variable shadowing
      sql/handler.h:
        Renamed parameter to avoid variable name conflict
      sql/item.h:
        Renamed variables to avoid variable shadowing
      sql/log_event_old.h:
        Renamed variables to avoid variable shadowing
      sql/set_var.h:
        Renamed variables to avoid variable shadowing
      sql/sql_delete.cc:
        Removed maria hack for temporary tables
        Fixed indentation
      sql/sql_table.cc:
        Moved extra() call when waiting for tables to not be used to after tables are removed from cache.
        This was needed to ensure we don't do a PREPARE_FOR_DROP or similar call while the table is still in use.
      sql/table.cc:
        Copy page_checksum from share
        Removed Maria hack
      storage/maria/Makefile.am:
        Added new files
      storage/maria/ha_maria.cc:
        Renamed records -> record_count and info -> create_info to avoid variable name conflicts
        Mark page cache variables as not flushable
      storage/maria/ma_blockrec.c:
        Moved _ma_unpin_all_pages() to ma_key_recover.c
        Moved init of info->pinned_pages to ma_open.c
        Moved _ma_finalize_row() to maria_key_recover.h
        Renamed some variables to avoid variable name conflicts
        Mark page_link.changed for blocks we change directly
        Simplify handling of undo link when writing LOGREC_UNDO_ROW_INSERT (old code crashed when having redo for index)
      storage/maria/ma_blockrec.h:
        Removed extra empty line
      storage/maria/ma_checkpoint.c:
        Remove not needed trnman.h
      storage/maria/ma_close.c:
        Free pinned pages (which are now always allocated)
      storage/maria/ma_control_file.c:
        Give error message if we fail to open control file
      storage/maria/ma_delete.c:
        Changes for redo logging (first part, logging of underflow not yet done)
        - Log undo-key-delete
        - Log delete of key
        - Updated arguments to _ma_fetch_keypage(), _ma_dispose(), _ma_write_keypage(), _ma_insert()
        - Added new arguments to some functions to be able to write redo information
        - Mark key pages as changed when we write with PAGECACHE_LOCK_LEFT_WRITELOCKED
        
        Remove one not needed _ma_write_keypage() in d_search() when upper level will do the write anyway
        Changed 2 bmove_upp() to bmove() as this made code easer to understand
        More function comments
        Indentation fixes
      storage/maria/ma_ft_update.c:
        New arguments to _ma_write_keypage()
      storage/maria/ma_loghandler.c:
        Fixed some DBUG_PRINT messages
        Simplify code
        Added new log entrys for key page redo
        Renamed some variables to avoid variable name shadowing
      storage/maria/ma_loghandler.h:
        Moved some defines here
        Added define for storing key number on key pages
        Added new translog record types
        Added enum for type of operations in LOGREC_REDO_INDEX
      storage/maria/ma_open.c:
        Always allocate info.pinned_pages (we need now also for normal key page usage)
        Update keyinfo->key_nr
        Added virtual functions to convert record position o number to be stored on key pages
        Update keyinfo->write_comp_flag to value of search flag to be used when writing key
      storage/maria/ma_page.c:
        Added redo for key pages
        - Extended _ma_fetch_keypage() with type of lock to put on page and address to used MARIA_PINNED_PAGE
        - _ma_fetch_keypage() now pin's pages if needed
        - Extended _ma_write_keypage() with type of locks to be used
        - ma_dispose() now locks info->s->state.key_del from other threads
        - ma_dispose() writes redo log record
        - ma_new() locks info->s->state.key_del from other threads if it was used
        - ma_new() now pins read page
        
        Other things:
        - Removed some not needed arguments from _ma_new() and _ma_dispose)
        - Added some new variables to simplify code
        - If EXTRA_DEBUG is used, do crc on full page to catch not unitialized bytes
      storage/maria/ma_pagecache.h:
        Applied patch from Sanja to add extra argument to pagecache_unlock_by_ulink() to mark if page was changed
        Added some defines for pagecache priority levels that one can use
      storage/maria/ma_range.c:
        Added new arguments for call to _ma_fetch_keypage()
      storage/maria/ma_recovery.c:
        - Added hooks for new translog types:
          REDO_INDEX, REDO_INDEX_NEW_PAGE, REDO_INDEX_FREE_PAGE, UNDO_KEY_INSERT, UNDO_KEY_DELETE and
          UNDO_KEY_DELETE_WITH_ROOT.
        - Moved variable declarations to start of function (portability fixes)
        - Removed some not needed initializations
        - Set only relevant state changes for each redo/undo entry
      storage/maria/lockman.c:
        Removed end space
      storage/maria/ma_check.c:
        Removed end space
      storage/maria/ma_create.c:
        Removed end space
      storage/maria/ma_locking.c:
        Removed end space
      storage/maria/ma_packrec.c:
        Removed end space
      storage/maria/ma_pagecache.c:
        Removed end space
      storage/maria/ma_panic.c:
        Removed end space
      storage/maria/ma_rt_index.c:
        Added new arguments for call to _ma_fetch_keypage(), _ma_write_keypage(), _ma_dispose() and _ma_new()
        Fixed indentation
      storage/maria/ma_rt_key.c:
        Added new arguments for call to _ma_fetch_keypage()
      storage/maria/ma_rt_split.c:
        Added new arguments for call to _ma_new()
        Use new keypage header
        Added new arguments for call to _ma_write_keypage()
      storage/maria/ma_search.c:
        Updated comments & indentation
        Added new arguments for call to _ma_fetch_keypage()
        Made some variables and arguments const
        Added virtual functions for converting row position to number to be stored in key
        use MARIA_RECORD_POS of record position instead of my_off_t
        Record in MARIA_KEY_PARAM how page was changed one key insert (needed for REDO)
      storage/maria/ma_sort.c:
        Removed end space
      storage/maria/ma_statrec.c:
        Updated arguments for call to _ma_rec_pos()
      storage/maria/ma_test1.c:
        Fixed too small buffer to init_pagecache()
        Fixed bug when using insert_count and test_flag
      storage/maria/ma_test2.c:
        Use more resonable pagecache size
        Remove not used code
        Reset blob_length to fix wrong output message
      storage/maria/ma_test_all.sh:
        Fixed wrong test
      storage/maria/ma_write.c:
        Lots of new code to handle REDO of key pages
        No logic changes because of REDO code, mostly adding new arguments and adding new code for logging 
        
        Added new arguments for calls to _ma_fetch_keypage(), _ma_write_keypage() and similar functions
        Move setting of comp_flag in ma_ck_wrte_btree() from runtime to maria_open()
        Zerofill new used pages for:
        - To remove possible sensitive data left in buffer
        - To get idenitical data on pages after running redo
        - Better compression of pages if archived
      storage/maria/maria_chk.c:
        Added information if table is crash safe
      storage/maria/maria_def.h:
        New virtual function to convert between record position on key and normal record position
        Aded mutex and extra variables to handle locking of share->state.key_del
        Moved some structure variables to get things more aligned
        Added extra arguments to MARIA_KEY_PARAM to be able to remember what was changed on key page on key insert
        Added argument to MARIA_PINNED_PAGE to indicate if page was changed
        Updated prototypes for functions
        Added some structures for signaling changes in REDO handling
      storage/maria/unittest/ma_pagecache_single.c:
        Updated arguments for changed function calls
      storage/myisam/mi_check.c:
        Made calc_check_checksum virtual
      storage/myisam/mi_checksum.c:
        Update checksums to ignore null columns
      storage/myisam/mi_create.c:
        Mark if table has null column (to know when we have to use mi_checksum())
      storage/myisam/mi_open.c:
        Added virtual function for calculating checksum to be able to easily ignore NULL fields
      storage/myisam/mi_test2.c:
        Fixed bug
      storage/myisam/myisamdef.h:
        Added virtual function for calculating checksum during check table
        Removed ha_key_cmp() as this is in handler.h
      storage/maria/ma_key_recover.c:
        New BitKeeper file ``storage/maria/ma_key_recover.c''
      storage/maria/ma_key_recover.h:
        New BitKeeper file ``storage/maria/ma_key_recover.h''
      storage/maria/ma_key_redo.c:
        New BitKeeper file ``storage/maria/ma_key_redo.c''
      5d6ee443
    • unknown's avatar
      WL#3072 - Maria recovery · 644361af
      unknown authored
      maria_read_log used to always print a warning message at startup
      to say it is unsafe if ALTER TABLE was used. Now it prints it only
      if the log does show the problem (=ALTER TABLE or CREATE SELECT, which
      both disable logging of REDO_INSERT*).
      For that, when ha_maria::external_lock() disables transactionality
      it writes a LOGREC_INCOMPLETE_LOG to the log, which "maria_read_log -a"
      picks up to write a warning.
      REPAIR TABLE also disables those REDO_INSERT* but as maria_read_log
      executes LOGREC_REDO_REPAIR no warning is needed.
      
      
      storage/maria/ha_maria.cc:
        as we now log a record when disabling transactionility, we need the
        TRN to be set up first
      storage/maria/ma_blockrec.c:
        comment
      storage/maria/ma_loghandler.c:
        new type of log record
      storage/maria/ma_loghandler.h:
        new type of log record
      storage/maria/ma_recovery.c:
        * maria_apply_log() now returns a count of warnings. What currently
        produces warnings is:
        - skipping applying UNDOs though there are some (=> inconsistent table)
        - replaying log (in maria_read_log) though the log contains some
        ALTER TABLE or CREATE SELECT (log misses REDO_INSERT* for those
        and is so incomplete).
        Count of warnings affects the final message of maria_read_log and
        recovery (though in recovery none of the two conditions above should
        happen).
        * maria_read_log used to always print a warning message at startup
        to say it is unsafe if ALTER TABLE was used. Now it prints it only
        if the log does show the problem, i.e. ALTER TABLE or CREATE SELECT
        was used (both disable logging of REDO_INSERT* as those records are
        not needed for recovery; those missing records in turn make
        recreation-from-scratch, via maria_read_log, impossible). For that,
        when ha_maria::external_lock() disables transactionality,
        _ma_tmp_disable_logging_for_table() writes a LOGREC_INCOMPLETE_LOG to
        the log, which maria_apply_log() picks up to write a warning.
      storage/maria/ma_recovery.h:
        maria_apply_log() returns a count of warnings
      storage/maria/maria_def.h:
        _ma_tmp_disable_logging_for_table() grows so becomes a function
      storage/maria/maria_read_log.c:
        maria_apply_log can now return a count of warnings, to temper the
        "SUCCESS" message printed in the end by maria_read_log.
        Advise users to make a backup first.
      644361af
  4. 13 Nov, 2007 2 commits
    • unknown's avatar
      Addendum to WL#4137 "Maria- Framework for testing recovery in mysql-test-run": · 9c6f8a2b
      unknown authored
      possibility, if requested in the test, to do byte-for-byte comparison
      of data files after recovery. This makes sense only when testing
      REDOs, as UNDO phase generates new log records thus data pages get
      new LSNs. First test of maria-recovery.test is changed to test only
      REDOs and do byte-for-byte comparison.
      
      
      mysql-test/include/maria_make_snapshot.inc:
        possibility to compare physically the data files (makes sense
        only if testing REDO phase).
      mysql-test/include/maria_verify_recovery.inc:
        allow physical comparison of data files after recovery if requested
      mysql-test/r/maria-recovery.result:
        result update (first test tests REDO only now)
      mysql-test/t/maria-recovery.test:
        first test tests REDO only now, and thus can do byte-for-byte
        comparison of data files.
      9c6f8a2b
    • unknown's avatar
      * WL#4137 Maria- Framework for testing recovery in mysql-test-run · c0a735d5
      unknown authored
      See test maria-recovery.test for a model; all include scripts have
      an "API" section at start if they do take parameters from outside.
      * Fixing bug reported by Jani and Monty (when two REDOs about the same
      page in one group, see ma_blockrec.c). 
      * Fixing small bugs in recovery
      
      
      mysql-test/include/wait_until_connected_again.inc:
        be sure to enter the loop (the previous query by the caller may not have
        failed: it could be
        query;
        mysqladmin shutdown;
        call this script).
      mysql-test/lib/mtr_process.pl:
        * Through the "expect" file a test can tell mtr that a server crash
        is expected. What the file contains is irrelevant. Now if its last
        line starts with "wait", mtr will wait before restarting (it will
        wait for the last line to not start with "wait"). This is for
        tests which need to mangle files under the feet of a dead mysqld.
        * Remove "expect" file before restarting; otherwise there could be a
        race condition: tests sees server restarted, does something, writes
        an "expect" file, and then mtr removes that file, then
        test kills mysqld, and then mtr will never restart it.
      storage/maria/ma_blockrec.c:
        - when applying a REDO in recovery, we don't anymore put UNDO's LSN on the page
        at once; indeed if in this REDO's group there comes another REDO
        for the same page it would be wrongly skipped. Instead, we keep
        pages pinned, don't change their LSN. When done with all REDOs
        of the group we unpin them and stamp them with UNDO's LSN.
        - fixing bug in applying of REDO_PURGE_BLOCKS in recovery: page_range
        sometimes has TAIL_BIT set, need to turn it down to know the real page
        range.
        - Both bugs are covered in maria-recovery.test
      storage/maria/ma_checkpoint.c:
        Capability to, in debug builds only, do some special operations
        (flush all bitmap and data pages, flush state, flush log)
        and crash mysqld, to later test recovery.
         Driven by some --debug=d, symbols.
      storage/maria/ma_open.c:
        debugging info
      storage/maria/ma_pagecache.c:
        Now that we can _ma_unpin_all_pages() during the REDO phase
        to set page's LSN, the assertion needs to be relaxed.
      storage/maria/ma_recovery.c:
        - open trace file in append mode (useful when a test triggers several
        recoveries, we see them all).
        - fixing wrong error detection, it's possible that during recovery
        we want to open an already open table.
        - when applying a REDO in recovery, we don't anymore put UNDO's LSN on the page
        at once; indeed if in this REDO's group there comes another REDO
        for the same page it would be wrongly skipped. Instead, we keep
        pages pinned, don't change their LSN. When done with all REDOs
        of the group we unpin them and stamp them with UNDO's LSN.
        - we verify that all log records of a group are about the same table,
        for debugging.
      mysql-test/r/maria-recovery.result:
        result
      mysql-test/t/maria-recovery-master.opt:
        crash is expected, core file would take room, stack trace would
        wake pushbuild up.
      mysql-test/t/maria-recovery.test:
        Test of recovery from mysql-test (it is already tested as unit tests
        in ma_test_recovery) (WL#4137)
        - test that, if recovery is made to start on an empty table it can
        replay the effects of committed and uncommitted statements (having only
        the committed ones in the end result). This should be the first test
        for someone writing code of new REDOs.
        - test that, if mysqld is crashed and recovery runs we have only
        committed statements in the end result. Crashes are done in different
        ways: flush nothing (so, uncommitted statement is often missing
        from the log => no rollback to do); flush pagecache (implicitely flushes
        log (WAL)) and flush log, both causes rollbacks; flush log can also
        flush state (state.records etc) to test recovery of the state
        (not tested well now as we repair the index anyway).
        - test of bug found by Jani and Monty in recovery (two REDO about
        the same page in one group).
      mysql-test/include/maria_empty_logs.inc:
        removes logs, to have a clean sheet for testing recovery.
      mysql-test/include/maria_make_snapshot.inc:
        copies a table to another directory, or back, or compares both
        (comparison is not implemented as physical comparison is impossible
        if an UNDO phase happened).
      mysql-test/include/maria_make_snapshot_for_comparison.inc:
        copies tables to another directory so that they can later
        serve as a comparison reference (they are the good tables,
        recovery should produce similar ones).
      mysql-test/include/maria_make_snapshot_for_feeding_recovery.inc:
        When we want to force recovery to start on old tables, we prepare
        old tables with this script: we put them in a spare directory.
        They are later copied back over mysqltest tables while mysqld is dead.
        We also need to copy back the control file, otherwise mysqld,
        in recovery, would start from the latest checkpoint: latest
        checkpoint plus old tables is not a recovery-possible scenario of course.
      mysql-test/include/maria_verify_recovery.inc:
        causes mysqld to crash, restores old tables if requested,
        lets recovery run, compares resulting tables with reference tables
        by using CHECKSUM TABLE.
        We don't do any sanity checks on page's LSN in resulting tables, yet.
      c0a735d5
  5. 11 Nov, 2007 2 commits
    • unknown's avatar
      comments · 80022872
      unknown authored
      80022872
    • unknown's avatar
      WL#3071 Maria checkpoint · a3365263
      unknown authored
      Fixing bad comments (I remember my maths' teacher "one late night you'll
      obey to the simplifications made by your tired neurons"; exactly
      what happened here). In Checkpoint, when we flush a table's state
      we must flush all log records (WAL), not only those before checkpoint
      started.
      
      
      storage/maria/ma_bitmap.c:
        there was a flaw in reasoning, bug does exist.
      storage/maria/ma_blockrec.c:
        moving piece of comment to ma_checkpoint.c
      storage/maria/ma_checkpoint.c:
        Comments.
        When checkpoint flushes a state, WAL imposes that all records up
        to this state have been flushed, not only up to checkpoint_start_log_horizon.
      storage/maria/ma_recovery.c:
        finishing comment.
      a3365263
  6. 09 Nov, 2007 2 commits
    • unknown's avatar
      WL#3071 - Maria checkpoint · e0028938
      unknown authored
      Observe WAL for the table's state: all log records needed for undoing
      uncommitted state must be in the log before we flush state.
      
      
      storage/maria/ha_maria.cc:
        comments
      storage/maria/ma_bitmap.c:
        Comment for why there is no bug
      storage/maria/ma_blockrec.c:
        comment for why there is no bug
      storage/maria/ma_checkpoint.c:
        Observe WAL for the table's state: all log records needed for undoing
        uncommitted state must be in the log before we flush state. I tested
        by hand that the bug existed (create table, insert one row into it
        but let that insert pause after increasing data_file_length, let
        checkpoint start but kill it after it has flushed state).
        Log contains nothing, table is not recovered though it has
        a too big data_file_length. With this bugfix, the log contains
        REDO so table is opened so data_file_length is corrected.
      storage/maria/ma_close.c:
        If table is read-only we must never write to it.
        Should be a no-change in fact, as if read-only, share->changed is
        normally always false.
      storage/maria/ma_recovery.c:
        documenting bug found by Monty. Print when fixing data_file_length.
      e0028938
    • unknown's avatar
      Infinite loop in case of given address more then last LSN fixed. · 5ddc4d8f
      unknown authored
      
      storage/maria/ma_loghandler.c:
        Infinite loop in case of given address more then last LSN fixed
        (now it means just flush all log).
        Removed unneeded ASSERT.
      storage/maria/unittest/ma_test_loghandler-t.c:
        The test case of flushing all log added.
      5ddc4d8f
  7. 05 Nov, 2007 1 commit
  8. 19 Oct, 2007 5 commits
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-maria · fd39bb6f
      unknown authored
      into  mysql.com:/home/my/mysql-maria
      
      
      include/my_sys.h:
        Auto merged
      mysql-test/r/maria.result:
        Auto merged
      mysql-test/t/maria.test:
        Auto merged
      sql/handler.h:
        Auto merged
      sql/mysqld.cc:
        Auto merged
      storage/maria/ha_maria.cc:
        Auto merged
      storage/maria/ma_bitmap.c:
        Auto merged
      storage/maria/ma_blockrec.c:
        Auto merged
      storage/maria/ma_loghandler.c:
        Auto merged
      storage/maria/ma_pagecache.c:
        Auto merged
      storage/maria/ma_test1.c:
        Auto merged
      storage/maria/ma_test_recovery.expected:
        Auto merged
      storage/maria/ma_test_recovery:
        Auto merged
      sql/mysql_priv.h:
        manual merge
      storage/maria/ma_recovery.c:
        manual merge
      storage/maria/ma_test2.c:
        manual merge
      fd39bb6f
    • unknown's avatar
      Merge some changes from sql directory in 5.1 tree · 9af00f4d
      unknown authored
      Changed format for REDO_INSERT_ROWS_BLOBS
      Fixed several bugs in handling of big blobs
      Added redo_free_head_or_tail() & redo_insert_row_blobs()
      Added uuid to control file
      maria_checks now verifies that not used part of bitmap is 0
      REDO_PURGE_BLOCKS -> REDO_FREE_BLOCKS
      Added REDO_FREE_HEAD_OR_TAIL
      Fixes problem when trying to read block outside of file during REDO
      
      
      include/my_global.h:
        STACK_DIRECTION is already set by configure
      mysql-test/r/maria.result:
        Updated results
      mysql-test/t/maria.test:
        Test shrinking of VARCHAR
      mysys/my_realloc.c:
        Fixed indentation
      mysys/safemalloc.c:
        Fixed indentation
      sql/filesort.cc:
        Removed some casts
      sql/mysqld.cc:
        Added missing setting of myisam_stats_method_str
      sql/uniques.cc:
        Removed some casts
      storage/maria/ma_bitmap.c:
        Added printing of bitmap (for debugging)
        Renamed _ma_print_bitmap() -> _ma_print_bitmap_changes()
        Added _ma_set_full_page_bits()
        Fixed bug in ma_bitmap_find_new_place() (affecting updates) when using big files
      storage/maria/ma_blockrec.c:
        Changed format for REDO_INSERT_ROWS_BLOBS
        Fixed several bugs in handling of big blobs
        Added code to fix some cases where redo when using blobs didn't produce idenital .MAD files as normal usage
        REDO_FREE_ROW_BLOCKS doesn't anymore change pages; We only mark things free in bitmap
        Remove TAIL and filler extents from REDO_FREE_BLOCKS log entry. (Fixed some asserts)
        REDO_PURGE_BLOCKS -> REDO_FREE_BLOCKS
        Delete tails in update. (Fixed bug when doing update that shrinks blob/varchar length)
        Fixed bug when doing insert in block outside of file size.
        Added redo_free_head_or_tail() & redo_insert_row_blobs()
        Added pagecache_unlock_by_link() when read fails.
        Much more comments, DBUG and ASSERT entries
      storage/maria/ma_blockrec.h:
        Prototypes of new functions
        Define of SUB_RANGE_SIZE & BLOCK_FILLER_SIZE
      storage/maria/ma_check.c:
        Verify that not used part of bitmap is 0
      storage/maria/ma_control_file.c:
        Added uuid to control file
      storage/maria/ma_loghandler.c:
        REDO_PURGE_BLOCKS -> REDO_FREE_BLOCKS
        Added REDO_FREE_HEAD_OR_TAIL
      storage/maria/ma_loghandler.h:
        REDO_PURGE_BLOCKS -> REDO_FREE_BLOCKS
        Added REDO_FREE_HEAD_OR_TAIL
      storage/maria/ma_pagecache.c:
        If we write full block, remove error flag for block.
        (Fixes problem when trying to read block outside of file)
      storage/maria/ma_recovery.c:
        REDO_PURGE_BLOCKS -> REDO_FREE_BLOCKS
        Added REDO_FREE_HEAD_OR_TAIL
      storage/maria/ma_test1.c:
        Allow option after 'b' to be compatible with ma_test2
        (This is just to simplify test scripts like ma_test_recovery)
      storage/maria/ma_test2.c:
        Default size of blob is now 1000 instead of 1
      storage/maria/ma_test_all.sh:
        Added test for bigger blobs
      storage/maria/ma_test_recovery.expected:
        Updated results
      storage/maria/ma_test_recovery:
        Added test for bigger blobs
      9af00f4d
    • unknown's avatar
      WL#3071 - Maria checkpoint · 8e2211e0
      unknown authored
      don't take a checkpoint at end of REDO phase because blocks' rec_lsn
      are not set. Fixes some assertion failures during tests of killing
      the UNDO phase (recovery then started from the end-of-REDO-phase
      checkpoint, wrongly ignoring REDOs before that record).
      
      
      storage/maria/ma_blockrec.c:
        note for a bug (mail sent to colleagues, put on todo)
      storage/maria/ma_recovery.c:
        this checkpoint at end of REDO phase is incorrect, disabling it.
        The one at end of UNDO phase remains.
      8e2211e0
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-maria · d4b296b6
      unknown authored
      into  gbichot4.local:/home/mysql_src/mysql-maria-for-undo-phase
      
      d4b296b6
    • unknown's avatar
      WL#3071 - Maria checkpoint · 78c22772
      unknown authored
      - serializing calls to flush_pagecache_blocks_int() on the same file
      to avoid known concurrency bugs
      - having that, we can now enable the background thread, as the
      flushes it does are now supposedly safe in concurrent situations.
      - new type of flush FLUSH_KEEP_LAZY: when the background checkpoint
      thread is flushing a packet of dirty pages between two checkpoints,
      it uses this flush type, indeed if a file is already being flushed
      by another thread it's smarter to move on to the next file than wait.
      - maria_checkpoint_frequency renamed to maria_checkpoint_interval.
      
      
      include/my_sys.h:
        new type of flushing for the page cache: FLUSH_KEEP_LAZY
      mysql-test/r/maria.result:
        result update
      mysys/mf_keycache.c:
        indentation. No FLUSH_KEEP_LAZY support in key cache.
      storage/maria/ha_maria.cc:
        maria_checkpoint_frequency was somehow a hidden part of the
        Checkpoint API and that was not good. Now we have checkpoint_interval,
        local to ha_maria.cc, which serves as container for the user-visible
        maria_checkpoint_interval global variable; setting it calls
        update_checkpoint_interval which passes the new value to
        ma_checkpoint_init(). There is no hiding anymore.
        By default, enable background thread which does checkpoints
        every 30 seconds, and dirty page flush in between. That thread takes
        a checkpoint when it ends, so no need for maria_hton_panic to take one.
        The | is | and not ||, because maria_panic() must always be called.
        frequency->interval.
      storage/maria/ma_checkpoint.c:
        Use FLUSH_KEEP_LAZY for background thread when it flushes packets of
        dirty pages between two checkpoints: it is smarter to move on to
        the next file than wait for it to have been completely flushed, which
        may take long.
        Comments about flush concurrency bugs moved from ma_pagecache.c.
        Removing out-of-date comment.
        frequency->interval.
        create_background_thread -> (interval>0).
        In ma_checkpoint_background(), some variables need to be preserved
        between iterations.
      storage/maria/ma_checkpoint.h:
        new prototype
      storage/maria/ma_pagecache.c:
        - concurrent calls of flush_pagecache_blocks_int() on the same file
        cause bugs (see @note in that function); we fix them by serializing
        in this situation. For that we use a global hash of (file, wqueue).
        When flush_pagecache_blocks_int() starts it looks into the hash,
        using the file as key. If not found, it inserts (file,wqueue) into the
        hash, flushes the file, and finally removes itself from the hash and
        wakes up any waiter in the queue. If found, it adds itself to the
        wqueue and waits.
        - As a by-product, we can remove changed_blocks_is_incomplete
        and replace it by scanning the hash, replace the sleep() by a queue wait.
        - new type of flush FLUSH_KEEP_LAZY: when flushing a file, if it's
        already being flushed by another thread (even partially), return
        immediately.
      storage/maria/ma_pagecache.h:
        In pagecache, a hash of files currently being flushed (i.e. there
        is a call to flush_pagecache_blocks_int() for them).
      storage/maria/ma_recovery.c:
        new prototype
      storage/maria/ma_test1.c:
        new prototype
      storage/maria/ma_test2.c:
        new prototype
      78c22772
  9. 18 Oct, 2007 2 commits
    • unknown's avatar
      mysys/my_getopt.c · 32680d62
      unknown authored
          always process uint/ulong using ulonglong (unsigned) code
          dbug printout for adjusted option values
      strings/llstr.c
          ullstr() - the unsigned brother of llstr()
      
      
      include/m_string.h:
        ullstr() - the unsigned brother of llstr()
      mysql-test/t/variables.test:
        test adjusted for 32bit
      mysys/my_getopt.c:
        always process uint/ulong using ulonglong (unsigned) code
        dbug printout for adjusted option values
      strings/llstr.c:
        ullstr() - the unsigned brother of llstr()
      32680d62
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-maria · 3f79ff98
      unknown authored
      into  gbichot4.local:/home/mysql_src/mysql-maria-tmp
      
      3f79ff98
  10. 17 Oct, 2007 5 commits
    • unknown's avatar
      Bugfix from Sanja (when truncating log at restart) · 0069c09b
      unknown authored
      
      storage/maria/ma_loghandler.c:
        applying patch for bugfix, by Sanja.
      0069c09b
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-maria · 0ad6d3b6
      unknown authored
      into  gbichot4.local:/home/mysql_src/mysql-maria-for-undo-phase
      
      
      storage/maria/ma_recovery.c:
        Auto merged
      0ad6d3b6
    • unknown's avatar
      WL#3071 Maria checkpoint · cfe03d87
      unknown authored
      Ability for flush_pagecache_blocks() to flush only certain pages of
      a file, as instructed by an option "filter" pointer-to-function argument;
      Checkpoint and background dirty page flushing use that to flush only
      pages which have been dirty for long enough and bitmap pages.
      Fix for a bug in flush_cached_blocks() (no idea if it could produce
      a bug in real life, but theoretically it is).
      Testing checkpoint in ma_test_recovery via ma_test1 and ma_test2.
      Background checkpoint & dirty pages flush thread is still disabled
      by default in ha_maria.
      
      
      mysql-test/r/maria.result:
        result update
      storage/maria/ha_maria.cc:
        blank after function comment
      storage/maria/ma_checkpoint.c:
        Using an enum instead of 0/1/2 (applying Sanja's review comments).
        The comment about "this is an horizon" can be removed as Sanja
        created translog_next_LSN() which parse_checkpoint_record() uses.
        Variables in ma_checkpoint_background() cannot be declared in the
        for() as their value must not be reset at each iteration!
      storage/maria/ma_pagecache.c:
        adding to flush_pagecache_blocks() optional arguments 'filter'
        (pointer to function) and 'filter_arg'; if filter!=NULL this function
        will be called for each block of the file and will reply if this
        block and following ones should be flushed or not (3 possible
        replies).
        Fixing a bug when flush_cached_blocks() skips a pinned page: it has
        to unset PCBLOCK_IN_FLUSH set by flush_pagecache_blocks_int().
      storage/maria/ma_pagecache.h:
        flush_pagecache_blocks() is changed to take "filter" and "filter_arg"
        arguments. "filter", if it is not NULL, may return one value
        among enum pagecache_flush_filter_result.
      storage/maria/ma_recovery.c:
        open_count=0 when closing tables at the end of recovery.
      storage/maria/ma_test1.c:
        Optional checkpoints (-H#) at various stages (stages similar
        to --testflag), for testing of checkpoints.
      storage/maria/ma_test2.c:
        Optional checkpoints (-H#) at various stages (stages similar
        to -t), for testing of checkpoints.
      storage/maria/ma_test_recovery.expected:
        Result update: the results of the additional test run with -H#
        (checkpoints) are added here. They are exactly identical to without
        checkpoints except that the index's Root (printed by maria_chk)
        is more correct when using checkpoints. This is because checkpoint
        flushed the state, so it happens to be correct, while no-checkpoint
        does not flush the state, and recovery does not recover indexes
        so Root is never fixed. When we recover indices, this will go away.
      storage/maria/ma_test_recovery:
        We duplicate the loop of tests to add an additional run with
        checkpoints at various stages, to see if maria_read_log
        uses them fine.
      cfe03d87
    • unknown's avatar
      Merge desktop.sanja.is.com.ua:/home/bell/mysql/bk/mysql-maria · cf811f9e
      unknown authored
      into  desktop.sanja.is.com.ua:/home/bell/mysql/bk/work-maria-bug
      
      
      storage/maria/ma_recovery.c:
        Auto merged
      cf811f9e
    • unknown's avatar
      Checking that the very last record is fully written · 6ca17629
      unknown authored
        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.
      6ca17629
  11. 16 Oct, 2007 3 commits
    • unknown's avatar
      WL#3072 Maria recovery, cleanups, removing some out-of-date @todos · a5dcfca2
      unknown authored
      
      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
      a5dcfca2
    • unknown's avatar
      Merge gbichot@bk-internal.mysql.com:/home/bk/mysql-maria · 18a4194b
      unknown authored
      into  gbichot4.local:/home/mysql_src/mysql-maria-tmp
      
      18a4194b
    • unknown's avatar
      WL#3072 Maria recovery · 8f714513
      unknown authored
      - 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).
      8f714513
  12. 15 Oct, 2007 1 commit
  13. 13 Oct, 2007 2 commits
  14. 12 Oct, 2007 6 commits
    • unknown's avatar
      different fix for strict-aliasing problem · 7de6b459
      unknown authored
      7de6b459
    • unknown's avatar
      bugs/warnings fixed in lf_alloc-pin.c: · 2cb4f952
      unknown authored
      1. available_stack_size() was getting the direction wrong,
         so alloca() was never used
      2. (char*) casts added to kill "break strict-aliasing rules" warnings
      3. s/node/node=0/ to kill "pointer casted to integer" warning
      4. added volatiles as appropriate to prevent gcc from moving
         assignment out of the loop
      
      
      mysys/lf_alloc-pin.c:
        bugs/warnings fixed:
        1. available_stack_size() was getting the direction wrong,
           so alloca() was never used
        2. (char*) casts added to kill "break strict-aliasing rules" warnings
        3. s/node/node=0/ to kill "pointer casted to integer" warning
        4. added volatiles as appropriate to prevent gcc from moving
           assignment out of the loop
      2cb4f952
    • unknown's avatar
      Merge bk-internal.mysql.com:/home/bk/mysql-maria · bbbc4b65
      unknown authored
      into  janus.mylan:/usr/home/serg/Abk/mysql-maria
      
      bbbc4b65
    • unknown's avatar
      make maria more pluggable · 94fb9e14
      unknown authored
      
      mysql-test/r/maria.result:
        test for maria variables
      mysql-test/t/maria.test:
        test for maria variables
      BitKeeper/etc/ignore:
        Added sql/link_sources ylwrap libmysql_r/link_sources to the ignore list
      sql/sql_delete.cc:
        fix incorrect check
      storage/maria/ha_maria.cc:
        maria status and pagecache variables
      94fb9e14
    • unknown's avatar
      int->my_bool transformation fixed (thanks Guilhem) · 432ea6b4
      unknown authored
      Mutex owner checks added.
      
      432ea6b4
    • unknown's avatar
      translog_next_LSN() changed to support pointer to the page end · 408cb46a
      unknown authored
        which can happen when you save address of horizon
      
      408cb46a
  15. 11 Oct, 2007 1 commit