diff options
author | unknown <aivanov@mysql.com> | 2006-03-10 19:22:21 +0300 |
---|---|---|
committer | unknown <aivanov@mysql.com> | 2006-03-10 19:22:21 +0300 |
commit | 050f14ac371e03dc96b96e8a9b0cd8fa8e3a23e0 (patch) | |
tree | 8105d79f7267d8af93861befd1899063f1ad42c2 /storage/innobase/btr/btr0sea.c | |
parent | 1cef1679a47bfbf744d656646770193ba07c30fe (diff) | |
download | mariadb-git-050f14ac371e03dc96b96e8a9b0cd8fa8e3a23e0.tar.gz |
Applied innodb-5.1-ss269 snapshot.
Fixed BUGS:
#3300: "UPDATE statement with no index column in where condition locks
all rows"
Implement semi-consistent read to reduce lock conflicts at the cost
of breaking serializability.
ha_innobase::unlock_row(): reset the "did semi consistent read" flag
ha_innobase::was_semi_consistent_read(),
ha_innobase::try_semi_consistent_read(): new methods
row_prebuilt_t, row_create_prebuilt(): add field row_read_type for
keeping track of semi-consistent reads
row_vers_build_for_semi_consistent_read(),
row_sel_build_committed_vers_for_mysql(): new functions
row_search_for_mysql(): implement semi-consistent reads
#9802: "Foreign key checks disallow alter table".
Added test cases.
#12456: "Cursor shows incorrect data - DML does not affect,
probably caching"
This patch implements a high-granularity read view to be used with
cursors. In this high-granularity consistent read view modifications
done by the creating transaction after the cursor is created or
future transactions are not visible. But those modifications that
transaction did before the cursor was created are visible.
#12701: "Support >4GB buffer pool and log files on 64-bit Windows"
Do not call os_file_create_tmpfile() at runtime. Instead, create all
tempfiles at startup and guard access to them with mutexes.
#13778: "If FOREIGN_KEY_CHECKS=0, one can create inconsistent FOREIGN KEYs".
When FOREIGN_KEY_CHECKS=0 we still need to check that datatypes between
foreign key references are compatible.
#14189: "VARBINARY and BINARY variables: trailing space ignored with InnoDB"
innobase_init(): Assert that
DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number.
dtype_get_pad_char(): Do not pad VARBINARY or BINARY columns.
row_ins_cascade_calc_update_vec(): Refuse ON UPDATE CASCADE when trying
to change the length of a VARBINARY column that refers to or is referenced
by a BINARY column. BINARY columns are no longer padded on comparison,
and thus they cannot be padded on storage either.
#14747: "Race condition can cause btr_search_drop_page_hash_index() to crash"
Note that buf_block_t::index should be protected by btr_search_latch
or an s-latch or x-latch on the index page.
btr_search_drop_page_hash_index(): Read block->index while holding
btr_search_latch and use the cached value in the loop. Remove some
redundant assertions.
#15108: "mysqld crashes when innodb_log_file_size is set > 4G"
#15308: "Problem of Order with Enum Column in Primary Key"
#15550: "mysqld crashes in printing a FOREIGN KEY error in InnoDB"
row_ins_foreign_report_add_err(): When printing the parent record,
use the index in the parent table rather than the index in the child table.
#15653: "Slow inserts to InnoDB if many thousands of .ibd files"
Keep track on unflushed modifications to file spaces. When there are tens
of thousands of file spaces, flushing all files in fil_flush_file_spaces()
would be very slow.
fil_flush_file_spaces(): Only flush unflushed file spaces.
fil_space_t, fil_system_t: Add a list of unflushed spaces.
#15991: "innodb-file-per-table + symlink database + rename = cr"
os_file_handle_error(): Map the error codes EXDEV, ENOTDIR, and EISDIR
to the new code OS_FILE_PATH_ERROR. Treat this code as OS_FILE_PATH_ERROR.
This fixes the crash on RENAME TABLE when the .ibd file is a symbolic link
to a different file system.
#16157: "InnoDB crashes when main location settings are empty"
This patch is from Heikki.
#16298: "InnoDB segfaults in INSERTs in upgrade of 4.0 -> 5.0 tables
with VARCHAR BINARY"
dict_load_columns(): Set the charset-collation code
DATA_MYSQL_BINARY_CHARSET_COLL for those binary string columns
that lack a charset-collation code, i.e., the tables were created
with an older version of MySQL/InnoDB than 4.1.2.
#16229: "MySQL/InnoDB uses full explicit table locks in trigger processing"
Take a InnoDB table lock only if user has explicitly requested a table
lock. Added some additional comments to store_lock() and external_lock().
#16387: "InnoDB crash when dropping a foreign key <table>_ibfk_0"
Do not mistake TABLENAME_ibfk_0 for auto-generated id.
dict_table_get_highest_foreign_id(): Ignore foreign constraint
identifiers starting with the pattern TABLENAME_ibfk_0.
#16582: "InnoDB: Error in an adaptive hash index pointer to page"
Account for a race condition when dropping the adaptive hash index
for a B-tree page.
btr_search_drop_page_hash_index(): Retry the operation if a hash index
with different parameters was built meanwhile. Add diagnostics for the
case that hash node pointers to the page remain.
btr_search_info_update_hash(), btr_search_info_update_slow():
Document the parameter "info" as in/out.
#16814: "SHOW INNODB STATUS format error in LATEST FOREIGN KEY ERROR
section"
Add a missing newline to the LAST FOREIGN KEY ERROR section in SHOW
INNODB STATUS output.
dict_foreign_error_report(): Always print a newline after invoking
dict_print_info_on_foreign_key_in_create_format().
#16827: "Better InnoDB error message if ibdata files omitted from my.cnf"
#17126: "CHECK TABLE on InnoDB causes a short hang during check of adaptive
hash"
CHECK TABLE blocking other queries, by releasing the btr_search_latch
periodically during the adaptive hash table validation.
#17405: "Valgrind: conditional jump or move depends on unititialised values"
buf_block_init(): Reset magic_n, buf_fix_count and io_fix to avoid
testing uninitialized variables.
mysql-test/r/innodb.result:
Applied innodb-5.1-ss269 snapshot.
mysql-test/t/innodb.test:
Applied innodb-5.1-ss269 snapshot.
sql/ha_innodb.cc:
Applied innodb-5.1-ss269 snapshot.
sql/ha_innodb.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0btr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0cur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0pcur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/btr/btr0sea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0buf.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0flu.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0lru.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/buf/buf0rea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/data/data0data.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/data/data0type.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0boot.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0crea.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0dict.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0load.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dict/dict0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/dyn/dyn0dyn.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/eval/eval0eval.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/eval/eval0proc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fil/fil0fil.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fsp/fsp0fsp.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/fut/fut0lst.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ha/ha0ha.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ha/hash0hash.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ibuf/ibuf0ibuf.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0btr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0btr.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0cur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0cur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0pcur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0pcur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0sea.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0sea.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/btr0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0buf.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0buf.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0flu.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0flu.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/buf0lru.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0data.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0data.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0type.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/data0type.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/db0err.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0boot.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0boot.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0crea.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0dict.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0dict.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0load.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dict0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dyn0dyn.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/dyn0dyn.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0eval.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0eval.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0proc.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/eval0proc.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fil0fil.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fsp0fsp.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/fut0lst.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ha0ha.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/hash0hash.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/hash0hash.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ibuf0ibuf.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ibuf0ibuf.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/lock0lock.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/lock0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0log.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0log.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/log0recv.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mach0data.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mach0data.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0dbg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0dbg.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0mem.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mem0pool.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0log.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0mtr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/mtr0mtr.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0file.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0proc.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0sync.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0sync.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/os0thread.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0cur.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0cur.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0page.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0page.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/page0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0grm.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0opt.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0pars.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0sym.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/pars0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0que.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0que.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/que0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/read0read.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/read0read.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0cmp.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0cmp.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0rec.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/rem0rec.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0ins.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0mysql.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0purge.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0row.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0row.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0sel.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0sel.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0uins.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0umod.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0undo.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0upd.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0upd.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/row0vers.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/srv0srv.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/srv0start.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0arr.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0rw.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0rw.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0sync.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/sync0sync.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0purge.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0purge.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rec.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0roll.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rseg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0rseg.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0sys.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0sys.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0trx.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0trx.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0undo.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0undo.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/trx0xa.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/univ.i:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/usr0sess.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/usr0types.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0byte.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0byte.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0dbg.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0lst.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0mem.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0mem.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0rnd.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0rnd.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0sort.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0ut.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/include/ut0ut.ic:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/lock/lock0lock.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/log/log0log.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/log/log0recv.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mach/mach0data.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0dbg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mem/mem0pool.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mtr/mtr0log.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/mtr/mtr0mtr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0file.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0proc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0sync.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/os/os0thread.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/page/page0cur.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/page/page0page.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/lexyy.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.h:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0grm.y:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0lex.l:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0opt.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0pars.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/pars/pars0sym.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/que/que0que.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/read/read0read.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/rem/rem0cmp.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/rem/rem0rec.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0ins.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0mysql.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0purge.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0row.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0sel.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0uins.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0umod.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0undo.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0upd.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/row/row0vers.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0que.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0srv.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/srv/srv0start.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0arr.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0rw.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/sync/sync0sync.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/thr/thr0loc.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0purge.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0rec.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0roll.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0rseg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0sys.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0trx.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/trx/trx0undo.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/usr/usr0sess.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0byte.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0dbg.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0mem.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0rnd.c:
Applied innodb-5.1-ss269 snapshot.
storage/innobase/ut/ut0ut.c:
Applied innodb-5.1-ss269 snapshot.
mysql-test/r/innodb_unsafe_binlog.result:
New BitKeeper file ``mysql-test/r/innodb_unsafe_binlog.result''
mysql-test/t/innodb_unsafe_binlog-master.opt:
New BitKeeper file ``mysql-test/t/innodb_unsafe_binlog-master.opt''
mysql-test/t/innodb_unsafe_binlog.test:
New BitKeeper file ``mysql-test/t/innodb_unsafe_binlog.test''
storage/innobase/pars/make_bison.sh:
New BitKeeper file ``storage/innobase/pars/make_bison.sh''
Diffstat (limited to 'storage/innobase/btr/btr0sea.c')
-rw-r--r-- | storage/innobase/btr/btr0sea.c | 357 |
1 files changed, 205 insertions, 152 deletions
diff --git a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c index 7a4e92a672a..a2f571f11e9 100644 --- a/storage/innobase/btr/btr0sea.c +++ b/storage/innobase/btr/btr0sea.c @@ -103,7 +103,7 @@ btr_search_check_free_space_in_heap(void) table = btr_search_sys->hash_index; heap = table->heap; - + /* Note that we peek the value of heap->free_block without reserving the latch: this is ok, because we will not guarantee that there will be enough free space in the hash table. */ @@ -133,9 +133,9 @@ btr_search_sys_create( { /* We allocate the search latch from dynamic memory: see above at the global variable definition */ - + btr_search_latch_temp = mem_alloc(sizeof(rw_lock_t)); - + rw_lock_create(&btr_search_latch); btr_search_sys = mem_alloc(sizeof(btr_search_sys_t)); @@ -169,10 +169,10 @@ btr_search_info_create( info->last_hash_succ = FALSE; - info->n_hash_succ = 0; - info->n_hash_fail = 0; - info->n_patt_succ = 0; - info->n_searches = 0; + info->n_hash_succ = 0; + info->n_hash_fail = 0; + info->n_patt_succ = 0; + info->n_searches = 0; /* Set some sensible values */ info->n_fields = 1; @@ -191,7 +191,7 @@ static void btr_search_info_update_hash( /*========================*/ - btr_search_t* info, /* in: search info */ + btr_search_t* info, /* in/out: search info */ btr_cur_t* cursor) /* in: cursor which was just positioned */ { dict_index_t* index; @@ -223,7 +223,7 @@ btr_search_info_update_hash( hash prefix */ if (info->n_fields >= n_unique && cursor->up_match >= n_unique) { - + info->n_hash_potential++; return; @@ -244,20 +244,20 @@ btr_search_info_update_hash( if ((info->side == BTR_SEARCH_LEFT_SIDE && cmp > 0) || (info->side == BTR_SEARCH_RIGHT_SIDE && cmp <= 0)) { - goto set_new_recomm; + goto set_new_recomm; } info->n_hash_potential++; return; - + set_new_recomm: /* We have to set a new recommendation; skip the hash analysis for a while to avoid unnecessary CPU time usage when there is no chance for success */ - + info->hash_analysis = 0; - + cmp = ut_pair_cmp(cursor->up_match, cursor->up_bytes, cursor->low_match, cursor->low_bytes); if (cmp == 0) { @@ -282,7 +282,7 @@ set_new_recomm: info->n_fields = cursor->low_match + 1; info->n_bytes = 0; - } else { + } else { info->n_fields = cursor->low_match; info->n_bytes = cursor->low_bytes + 1; } @@ -300,7 +300,7 @@ set_new_recomm: info->n_fields = cursor->up_match + 1; info->n_bytes = 0; - } else { + } else { info->n_fields = cursor->up_match; info->n_bytes = cursor->up_bytes + 1; } @@ -308,7 +308,7 @@ set_new_recomm: info->side = BTR_SEARCH_RIGHT_SIDE; } } - + /************************************************************************* Updates the block search info on hash successes. NOTE that info and block->n_hash_helps, n_fields, n_bytes, side are NOT protected by any @@ -337,19 +337,19 @@ btr_search_update_block_hash_info( ut_a(info->magic_n == BTR_SEARCH_MAGIC_N); if ((block->n_hash_helps > 0) - && (info->n_hash_potential > 0) - && (block->n_fields == info->n_fields) - && (block->n_bytes == info->n_bytes) - && (block->side == info->side)) { - + && (info->n_hash_potential > 0) + && (block->n_fields == info->n_fields) + && (block->n_bytes == info->n_bytes) + && (block->side == info->side)) { + if ((block->is_hashed) - && (block->curr_n_fields == info->n_fields) - && (block->curr_n_bytes == info->n_bytes) - && (block->curr_side == info->side)) { + && (block->curr_n_fields == info->n_fields) + && (block->curr_n_bytes == info->n_bytes) + && (block->curr_side == info->side)) { /* The search would presumably have succeeded using the hash index */ - + info->last_hash_succ = TRUE; } @@ -366,19 +366,19 @@ btr_search_update_block_hash_info( } if ((block->n_hash_helps > page_get_n_recs(block->frame) - / BTR_SEARCH_PAGE_BUILD_LIMIT) - && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) { + / BTR_SEARCH_PAGE_BUILD_LIMIT) + && (info->n_hash_potential >= BTR_SEARCH_BUILD_LIMIT)) { - if ((!block->is_hashed) - || (block->n_hash_helps + if ((!block->is_hashed) + || (block->n_hash_helps > 2 * page_get_n_recs(block->frame)) - || (block->n_fields != block->curr_n_fields) - || (block->n_bytes != block->curr_n_bytes) - || (block->side != block->curr_side)) { + || (block->n_fields != block->curr_n_fields) + || (block->n_bytes != block->curr_n_bytes) + || (block->side != block->curr_side)) { - /* Build a new hash index on the page */ + /* Build a new hash index on the page */ - return(TRUE); + return(TRUE); } } @@ -415,21 +415,21 @@ btr_search_update_hash_ref( ut_a(!block->is_hashed || block->index == cursor->index); if (block->is_hashed - && (info->n_hash_potential > 0) - && (block->curr_n_fields == info->n_fields) - && (block->curr_n_bytes == info->n_bytes) - && (block->curr_side == info->side)) { + && (info->n_hash_potential > 0) + && (block->curr_n_fields == info->n_fields) + && (block->curr_n_bytes == info->n_bytes) + && (block->curr_side == info->side)) { mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - rec = btr_cur_get_rec(cursor); + rec = btr_cur_get_rec(cursor); + + if (!page_rec_is_user_rec(rec)) { - if (!page_rec_is_user_rec(rec)) { + return; + } - return; - } - tree_id = ((cursor->index)->tree)->id; fold = rec_fold(rec, rec_get_offsets(rec, cursor->index, offsets_, ULINT_UNDEFINED, &heap), @@ -444,22 +444,22 @@ btr_search_update_hash_ref( ha_insert_for_fold(btr_search_sys->hash_index, fold, rec); } -} - +} + /************************************************************************* Updates the search info. */ void btr_search_info_update_slow( /*========================*/ - btr_search_t* info, /* in: search info */ + btr_search_t* info, /* in/out: search info */ btr_cur_t* cursor) /* in: cursor which was just positioned */ { buf_block_t* block; ibool build_index; ulint* params; ulint* params2; - + #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); @@ -480,7 +480,7 @@ btr_search_info_update_slow( btr_search_check_free_space_in_heap(); } - + if (cursor->flag == BTR_CUR_HASH_FAIL) { /* Update the hash node reference, if appropriate */ @@ -511,7 +511,7 @@ btr_search_info_update_slow( optimizations */ params2 = params + btr_search_this_is_zero; - + btr_search_build_page_hash_index(cursor->index, block->frame, params2[0], @@ -531,15 +531,15 @@ btr_search_check_guess( /*===================*/ /* out: TRUE if success */ btr_cur_t* cursor, /* in: guessed cursor position */ - ibool can_only_compare_to_cursor_rec, - /* in: if we do not have a latch on the page + ibool can_only_compare_to_cursor_rec, + /* in: if we do not have a latch on the page of cursor, but only a latch on - btr_search_latch, then ONLY the columns + btr_search_latch, then ONLY the columns of the record UNDER the cursor are protected, not the next or previous record in the chain: we cannot look at the next or previous record to check our guess! */ - dtuple_t* tuple, /* in: data tuple */ + dtuple_t* tuple, /* in: data tuple */ ulint mode, /* in: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, or PAGE_CUR_GE */ mtr_t* mtr) /* in: mtr */ @@ -556,7 +556,7 @@ btr_search_check_guess( *offsets_ = (sizeof offsets_) / sizeof *offsets_; n_unique = dict_index_get_n_unique_in_tree(cursor->index); - + rec = btr_cur_get_rec(cursor); ut_ad(page_rec_is_user_rec(rec)); @@ -579,7 +579,7 @@ btr_search_check_guess( if (match >= n_unique) { success = TRUE; goto exit_func; - } + } } else if (mode == PAGE_CUR_LE) { if (cmp == -1) { goto exit_func; @@ -598,8 +598,8 @@ btr_search_check_guess( } if (can_only_compare_to_cursor_rec) { - /* Since we could not determine if our guess is right just by - looking at the record under the cursor, return FALSE */ + /* Since we could not determine if our guess is right just by + looking at the record under the cursor, return FALSE */ goto exit_func; } @@ -610,7 +610,7 @@ btr_search_check_guess( rec_t* prev_rec; ut_ad(!page_rec_is_infimum(rec)); - + prev_rec = page_rec_get_prev(rec); if (page_rec_is_infimum(prev_rec)) { @@ -635,7 +635,7 @@ btr_search_check_guess( rec_t* next_rec; ut_ad(!page_rec_is_supremum(rec)); - + next_rec = page_rec_get_next(rec); if (page_rec_is_supremum(next_rec)) { @@ -676,18 +676,18 @@ both have sensible values. */ ibool btr_search_guess_on_hash( /*=====================*/ - /* out: TRUE if succeeded */ + /* out: TRUE if succeeded */ dict_index_t* index, /* in: index */ btr_search_t* info, /* in: index search info */ dtuple_t* tuple, /* in: logical record */ ulint mode, /* in: PAGE_CUR_L, ... */ - ulint latch_mode, /* in: BTR_SEARCH_LEAF, ...; + ulint latch_mode, /* in: BTR_SEARCH_LEAF, ...; NOTE that only if has_search_latch is 0, we will have a latch set on the cursor page, otherwise we assume the caller uses his search latch to protect the record! */ - btr_cur_t* cursor, /* out: tree cursor */ + btr_cur_t* cursor, /* out: tree cursor */ ulint has_search_latch,/* in: latch mode the caller currently has on btr_search_latch: RW_S_LATCH, RW_X_LATCH, or 0 */ @@ -699,7 +699,7 @@ btr_search_guess_on_hash( ulint fold; ulint tuple_n_fields; dulint tree_id; - ibool can_only_compare_to_cursor_rec = TRUE; + ibool can_only_compare_to_cursor_rec = TRUE; #ifdef notdefined btr_cur_t cursor2; btr_pcur_t pcur; @@ -729,7 +729,7 @@ btr_search_guess_on_hash( if (UNIV_UNLIKELY(tuple_n_fields == cursor->n_fields) && (cursor->n_bytes > 0)) { - return(FALSE); + return(FALSE); } tree_id = (index->tree)->id; @@ -741,7 +741,7 @@ btr_search_guess_on_hash( cursor->fold = fold; cursor->flag = BTR_CUR_HASH; - + if (UNIV_LIKELY(!has_search_latch)) { rw_lock_s_lock(&btr_search_latch); } @@ -778,7 +778,7 @@ btr_search_guess_on_hash( if (UNIV_UNLIKELY(block->state == BUF_BLOCK_REMOVE_HASH)) { if (UNIV_LIKELY(!has_search_latch)) { - + btr_leaf_page_release(page, latch_mode, mtr); } @@ -798,29 +798,29 @@ btr_search_guess_on_hash( record to determine if our guess for the cursor position is right. */ if (UNIV_EXPECT(ut_dulint_cmp(tree_id, btr_page_get_index_id(page)), 0) - || !btr_search_check_guess(cursor, can_only_compare_to_cursor_rec, - tuple, mode, mtr)) { + || !btr_search_check_guess(cursor, + can_only_compare_to_cursor_rec, tuple, mode, mtr)) { if (UNIV_LIKELY(!has_search_latch)) { - btr_leaf_page_release(page, latch_mode, mtr); + btr_leaf_page_release(page, latch_mode, mtr); } goto failure; } if (UNIV_LIKELY(info->n_hash_potential < BTR_SEARCH_BUILD_LIMIT + 5)) { - + info->n_hash_potential++; } #ifdef notdefined /* These lines of code can be used in a debug version to check the correctness of the searched cursor position: */ - + info->last_hash_succ = FALSE; /* Currently, does not work if the following fails: */ ut_ad(!has_search_latch); - + btr_leaf_page_release(page, latch_mode, mtr); btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, @@ -831,7 +831,7 @@ btr_search_guess_on_hash( /* If mode is PAGE_CUR_GE, then the binary search in the index tree may actually take us to the supremum of the previous page */ - + info->last_hash_succ = FALSE; btr_pcur_open_on_user_rec(index, tuple, mode, latch_mode, @@ -854,14 +854,14 @@ btr_search_guess_on_hash( && buf_block_peek_if_too_old(block)) { buf_page_make_young(page); - } + } /* Increment the page get statistics though we did not really fix the page: for user info only */ buf_pool->n_page_gets++; - return(TRUE); + return(TRUE); /*-------------------------------------------*/ failure_unlock: @@ -889,7 +889,8 @@ Drops a page hash index. */ void btr_search_drop_page_hash_index( /*============================*/ - page_t* page) /* in: index page, s- or x-latched */ + page_t* page) /* in: index page, s- or x-latched, or an index page + for which we know that block->buf_fix_count == 0 */ { hash_table_t* table; buf_block_t* block; @@ -904,18 +905,19 @@ btr_search_drop_page_hash_index( ulint* folds; ulint i; mem_heap_t* heap; + dict_index_t* index; ulint* offsets; #ifdef UNIV_SYNC_DEBUG ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_SHARED)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - +retry: rw_lock_s_lock(&btr_search_latch); block = buf_block_align(page); - if (!block->is_hashed) { + if (UNIV_LIKELY(!block->is_hashed)) { rw_lock_s_unlock(&btr_search_latch); @@ -926,17 +928,22 @@ btr_search_drop_page_hash_index( #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_SHARED) - || rw_lock_own(&(block->lock), RW_LOCK_EX) - || (block->buf_fix_count == 0)); + || rw_lock_own(&(block->lock), RW_LOCK_EX) + || (block->buf_fix_count == 0)); #endif /* UNIV_SYNC_DEBUG */ n_fields = block->curr_n_fields; n_bytes = block->curr_n_bytes; + index = block->index; - ut_a(n_fields + n_bytes > 0); + /* NOTE: The fields of block must not be accessed after + releasing btr_search_latch, as the index page might only + be s-latched! */ rw_lock_s_unlock(&btr_search_latch); - + + ut_a(n_fields + n_bytes > 0); + n_recs = page_get_n_recs(page); /* Calculate and cache fold values into an array for fast deletion @@ -949,33 +956,21 @@ btr_search_drop_page_hash_index( rec = page_get_infimum_rec(page); rec = page_rec_get_next(rec); - if (!page_rec_is_supremum(rec)) { - ut_a(n_fields <= rec_get_n_fields(rec, block->index)); + tree_id = btr_page_get_index_id(page); - if (n_bytes > 0) { - ut_a(n_fields < rec_get_n_fields(rec, block->index)); - } - } + ut_a(0 == ut_dulint_cmp(tree_id, index->id)); - tree_id = btr_page_get_index_id(page); - prev_fold = 0; heap = NULL; offsets = NULL; - if (block->index == NULL) { - - mem_analyze_corruption((byte*)block); - - ut_a(block->index != NULL); - } - while (!page_rec_is_supremum(rec)) { /* FIXME: in a mixed tree, not all records may have enough ordering fields: */ - offsets = rec_get_offsets(rec, block->index, - offsets, n_fields + (n_bytes > 0), &heap); + offsets = rec_get_offsets(rec, index, offsets, + n_fields + (n_bytes > 0), &heap); + ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); fold = rec_fold(rec, offsets, n_fields, n_bytes, tree_id); if (fold == prev_fold && prev_fold != 0) { @@ -999,6 +994,26 @@ next_rec: rw_lock_x_lock(&btr_search_latch); + if (UNIV_UNLIKELY(!block->is_hashed)) { + /* Someone else has meanwhile dropped the hash index */ + + goto cleanup; + } + + ut_a(block->index == index); + + if (UNIV_UNLIKELY(block->curr_n_fields != n_fields) + || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { + + /* Someone else has meanwhile built a new hash index on the + page, with different parameters */ + + rw_lock_x_unlock(&btr_search_latch); + + mem_free(folds); + goto retry; + } + for (i = 0; i < n_cached; i++) { ha_remove_all_nodes_to_page(table, folds[i], page); @@ -1006,8 +1021,20 @@ next_rec: block->is_hashed = FALSE; block->index = NULL; +cleanup: + if (UNIV_UNLIKELY(block->n_pointers)) { + /* Corruption */ + ut_print_timestamp(stderr); + fprintf(stderr, +" InnoDB: Corruption of adaptive hash index. After dropping\n" +"InnoDB: the hash index to a page of %s, still %lu hash nodes remain.\n", + index->name, (ulong) block->n_pointers); + rw_lock_x_unlock(&btr_search_latch); - rw_lock_x_unlock(&btr_search_latch); + btr_search_validate(); + } else { + rw_lock_x_unlock(&btr_search_latch); + } mem_free(folds); } @@ -1032,14 +1059,14 @@ btr_search_drop_page_hash_when_freed( return; } - + mtr_start(&mtr); /* We assume that if the caller has a latch on the page, then the caller has already dropped the hash index for the page, and we never get here. Therefore we can acquire the s-latch to the page without having to fear a deadlock. */ - + page = buf_page_get_gen(space, page_no, RW_S_LATCH, NULL, BUF_GET_IF_IN_POOL, __FILE__, __LINE__, &mtr); @@ -1098,10 +1125,10 @@ btr_search_build_page_hash_index( #endif /* UNIV_SYNC_DEBUG */ rw_lock_s_lock(&btr_search_latch); - + if (block->is_hashed && ((block->curr_n_fields != n_fields) - || (block->curr_n_bytes != n_bytes) - || (block->curr_side != side))) { + || (block->curr_n_bytes != n_bytes) + || (block->curr_side != side))) { rw_lock_s_unlock(&btr_search_latch); @@ -1118,15 +1145,15 @@ btr_search_build_page_hash_index( } /* Check that the values for hash index build are sensible */ - + if (n_fields + n_bytes == 0) { return; } if (dict_index_get_n_unique_in_tree(index) < n_fields - || (dict_index_get_n_unique_in_tree(index) == n_fields - && n_bytes > 0)) { + || (dict_index_get_n_unique_in_tree(index) == n_fields + && n_bytes > 0)) { return; } @@ -1164,20 +1191,20 @@ btr_search_build_page_hash_index( recs[n_cached] = rec; n_cached++; } - + for (;;) { next_rec = page_rec_get_next(rec); if (page_rec_is_supremum(next_rec)) { if (side == BTR_SEARCH_RIGHT_SIDE) { - + folds[n_cached] = fold; recs[n_cached] = rec; n_cached++; } - break; + break; } offsets = rec_get_offsets(next_rec, index, offsets, @@ -1209,21 +1236,21 @@ btr_search_build_page_hash_index( rw_lock_x_lock(&btr_search_latch); if (block->is_hashed && ((block->curr_n_fields != n_fields) - || (block->curr_n_bytes != n_bytes) - || (block->curr_side != side))) { + || (block->curr_n_bytes != n_bytes) + || (block->curr_side != side))) { goto exit_func; } - + block->is_hashed = TRUE; block->n_hash_helps = 0; - + block->curr_n_fields = n_fields; block->curr_n_bytes = n_bytes; block->curr_side = side; block->index = index; for (i = 0; i < n_cached; i++) { - + ha_insert_for_fold(table, folds[i], recs[i]); } @@ -1272,7 +1299,7 @@ btr_search_move_or_delete_hash_entries( ut_a(!block->is_hashed || block->index == index); rw_lock_s_lock(&btr_search_latch); - + if (new_block->is_hashed) { rw_lock_s_unlock(&btr_search_latch); @@ -1393,13 +1420,13 @@ btr_search_update_hash_node_on_insert( rw_lock_x_lock(&btr_search_latch); if ((cursor->flag == BTR_CUR_HASH) - && (cursor->n_fields == block->curr_n_fields) - && (cursor->n_bytes == block->curr_n_bytes) - && (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) { + && (cursor->n_fields == block->curr_n_fields) + && (cursor->n_bytes == block->curr_n_bytes) + && (block->curr_side == BTR_SEARCH_RIGHT_SIDE)) { + + table = btr_search_sys->hash_index; - table = btr_search_sys->hash_index; - - ha_search_and_update_if_found(table, cursor->fold, rec, + ha_search_and_update_if_found(table, cursor->fold, rec, page_rec_get_next(rec)); rw_lock_x_unlock(&btr_search_latch); @@ -1421,7 +1448,7 @@ btr_search_update_hash_on_insert( and the new record has been inserted next to the cursor */ { - hash_table_t* table; + hash_table_t* table; buf_block_t* block; rec_t* rec; rec_t* ins_rec; @@ -1450,7 +1477,7 @@ btr_search_update_hash_on_insert( #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&(block->lock), RW_LOCK_EX)); #endif /* UNIV_SYNC_DEBUG */ - + if (!block->is_hashed) { return; @@ -1494,10 +1521,10 @@ btr_search_update_hash_on_insert( goto check_next_rec; } - - if (fold != ins_fold) { - if (!locked) { + if (fold != ins_fold) { + + if (!locked) { rw_lock_x_lock(&btr_search_latch); @@ -1516,22 +1543,22 @@ check_next_rec: if (side == BTR_SEARCH_RIGHT_SIDE) { - if (!locked) { + if (!locked) { rw_lock_x_lock(&btr_search_latch); locked = TRUE; } - + ha_insert_for_fold(table, ins_fold, ins_rec); } goto function_exit; } - + if (ins_fold != next_fold) { - if (!locked) { - + if (!locked) { + rw_lock_x_lock(&btr_search_latch); locked = TRUE; @@ -1548,8 +1575,8 @@ check_next_rec: } else { ha_insert_for_fold(table, next_fold, next_rec); } - } - + } + function_exit: if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -1573,14 +1600,29 @@ btr_search_validate(void) ulint n_page_dumps = 0; ibool ok = TRUE; ulint i; + ulint cell_count; mem_heap_t* heap = NULL; ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint* offsets = offsets_; *offsets_ = (sizeof offsets_) / sizeof *offsets_; - + + /* How many cells to check before temporarily releasing + btr_search_latch. */ + ulint chunk_size = 10000; + rw_lock_x_lock(&btr_search_latch); - for (i = 0; i < hash_get_n_cells(btr_search_sys->hash_index); i++) { + cell_count = hash_get_n_cells(btr_search_sys->hash_index); + + for (i = 0; i < cell_count; i++) { + /* We release btr_search_latch every once in a while to + give other queries a chance to run. */ + if ((i != 0) && ((i % chunk_size) == 0)) { + rw_lock_x_unlock(&btr_search_latch); + os_thread_yield(); + rw_lock_x_lock(&btr_search_latch); + } + node = hash_get_nth_cell(btr_search_sys->hash_index, i)->node; while (node != NULL) { @@ -1592,11 +1634,11 @@ btr_search_validate(void) + (block->curr_n_bytes > 0), &heap); if (!block->is_hashed - || node->fold != rec_fold((rec_t*)(node->data), - offsets, - block->curr_n_fields, - block->curr_n_bytes, - btr_page_get_index_id(page))) { + || node->fold != rec_fold((rec_t*)(node->data), + offsets, + block->curr_n_fields, + block->curr_n_bytes, + btr_page_get_index_id(page))) { ok = FALSE; ut_print_timestamp(stderr); @@ -1610,9 +1652,9 @@ btr_search_validate(void) (ulong) node->fold, (ulong) rec_fold((rec_t*)(node->data), offsets, - block->curr_n_fields, - block->curr_n_bytes, - btr_page_get_index_id(page))); + block->curr_n_fields, + block->curr_n_bytes, + btr_page_get_index_id(page))); fputs("InnoDB: Record ", stderr); rec_print_new(stderr, (rec_t*)node->data, @@ -1620,11 +1662,11 @@ btr_search_validate(void) fprintf(stderr, "\nInnoDB: on that page." "Page mem address %p, is hashed %lu, n fields %lu, n bytes %lu\n" "side %lu\n", - page, (ulong) block->is_hashed, - (ulong) block->curr_n_fields, - (ulong) block->curr_n_bytes, (ulong) block->curr_side); + page, (ulong) block->is_hashed, + (ulong) block->curr_n_fields, + (ulong) block->curr_n_bytes, (ulong) block->curr_side); - if (n_page_dumps < 20) { + if (n_page_dumps < 20) { buf_page_print(page); n_page_dumps++; } @@ -1633,10 +1675,21 @@ btr_search_validate(void) node = node->next; } } - - if (!ha_validate(btr_search_sys->hash_index)) { - ok = FALSE; + for (i = 0; i < cell_count; i += chunk_size) { + ulint end_index = ut_min(i + chunk_size - 1, cell_count - 1); + + /* We release btr_search_latch every once in a while to + give other queries a chance to run. */ + if (i != 0) { + rw_lock_x_unlock(&btr_search_latch); + os_thread_yield(); + rw_lock_x_lock(&btr_search_latch); + } + + if (!ha_validate(btr_search_sys->hash_index, i, end_index)) { + ok = FALSE; + } } rw_lock_x_unlock(&btr_search_latch); |