diff options
author | Marko Mäkelä <marko.makela@oracle.com> | 2012-08-21 10:47:17 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@oracle.com> | 2012-08-21 10:47:17 +0300 |
commit | 3f249921f81bec183ef2da02b839fc2f10577218 (patch) | |
tree | d7bf5b287f576f040dadf7824df0226a54e910b9 /storage | |
parent | 5d83889791c138955ec0ab61967e8d0dcdede871 (diff) | |
download | mariadb-git-3f249921f81bec183ef2da02b839fc2f10577218.tar.gz |
Fix regression from Bug#12845774 OPTIMISTIC INSERT/UPDATE USES WRONG
HEURISTICS FOR COMPRESSED PAGE SIZE
The fix of Bug#12845774 was supposed to skip known-to-fail
btr_cur_optimistic_insert() calls. There was only one such call, in
btr_cur_pessimistic_update(). All other callers of
btr_cur_pessimistic_insert() would release and reacquire the B-tree
page latch before attempting the pessimistic insert. This would allow
other threads to restructure the B-tree, allowing (and requiring) the
insert to succeed as an optimistic (single-page) operation.
Failure to attempt an optimistic insert before a pessimistic one would
trigger an attempt to split an empty page.
rb:1234 approved by Sunny Bains
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innodb_plugin/ibuf/ibuf0ibuf.c | 18 | ||||
-rw-r--r-- | storage/innodb_plugin/row/row0ins.c | 9 |
2 files changed, 21 insertions, 6 deletions
diff --git a/storage/innodb_plugin/ibuf/ibuf0ibuf.c b/storage/innodb_plugin/ibuf/ibuf0ibuf.c index f1da399167c..965d8df7d0c 100644 --- a/storage/innodb_plugin/ibuf/ibuf0ibuf.c +++ b/storage/innodb_plugin/ibuf/ibuf0ibuf.c @@ -2752,11 +2752,19 @@ ibuf_insert_low( root = ibuf_tree_root_get(&mtr); - err = btr_cur_pessimistic_insert(BTR_NO_LOCKING_FLAG - | BTR_NO_UNDO_LOG_FLAG, - cursor, - ibuf_entry, &ins_rec, - &dummy_big_rec, 0, thr, &mtr); + err = btr_cur_optimistic_insert( + BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG, + cursor, ibuf_entry, &ins_rec, + &dummy_big_rec, 0, thr, &mtr); + + if (err == DB_FAIL) { + err = btr_cur_pessimistic_insert( + BTR_NO_LOCKING_FLAG + | BTR_NO_UNDO_LOG_FLAG, + cursor, ibuf_entry, &ins_rec, + &dummy_big_rec, 0, thr, &mtr); + } + if (err == DB_SUCCESS) { /* Update the page max trx id field */ page_update_max_trx_id(btr_cur_get_block(cursor), NULL, diff --git a/storage/innodb_plugin/row/row0ins.c b/storage/innodb_plugin/row/row0ins.c index 4994a91dd23..92ce04774ea 100644 --- a/storage/innodb_plugin/row/row0ins.c +++ b/storage/innodb_plugin/row/row0ins.c @@ -2179,9 +2179,16 @@ row_ins_index_entry_low( goto function_exit; } - err = btr_cur_pessimistic_insert( + + err = btr_cur_optimistic_insert( 0, &cursor, entry, &insert_rec, &big_rec, n_ext, thr, &mtr); + + if (err == DB_FAIL) { + err = btr_cur_pessimistic_insert( + 0, &cursor, entry, &insert_rec, + &big_rec, n_ext, thr, &mtr); + } } } |