Skip to content

Commit

Permalink
Transferring a change from main 5.5 into the 5.5.17 build:
Browse files Browse the repository at this point in the history
| revision-id: [email protected]
| parent: [email protected]
| committer: Inaam Rana <[email protected]>
| branch nick: mysql-5.5
| timestamp: Fri 2011-09-30 07:02:19 -0400
| message:
|   Revert original fix for Bug 12612184 and the follow up fix for
|   Bug 12704861.
|
|   Bug 12704861 fix was revno: 3504.1.1 (rb://693)
|   Bug 12612184 fix was revno: 3445.1.10 (rb://678)
  • Loading branch information
Joerg Bruehe committed Sep 30, 2011
1 parent ea22ebe commit e8cc313
Show file tree
Hide file tree
Showing 31 changed files with 367 additions and 859 deletions.
272 changes: 35 additions & 237 deletions storage/innobase/btr/btr0btr.c

Large diffs are not rendered by default.

140 changes: 38 additions & 102 deletions storage/innobase/btr/btr0cur.c
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,7 @@ btr_cur_optimistic_update(
ulint old_rec_size;
dtuple_t* new_entry;
roll_ptr_t roll_ptr;
trx_t* trx;
mem_heap_t* heap;
ulint i;
ulint n_ext;
Expand All @@ -2001,10 +2002,9 @@ btr_cur_optimistic_update(

heap = mem_heap_create(1024);
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
#if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG
ut_a(!rec_offs_any_null_extern(rec, offsets)
|| trx_is_recv(thr_get_trx(thr)));
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
#ifdef UNIV_BLOB_NULL_DEBUG
ut_a(!rec_offs_any_null_extern(rec, offsets));
#endif /* UNIV_BLOB_NULL_DEBUG */

#ifdef UNIV_DEBUG
if (btr_cur_print_record_ops && thr) {
Expand Down Expand Up @@ -2127,11 +2127,13 @@ btr_cur_optimistic_update(

page_cur_move_to_prev(page_cursor);

trx = thr_get_trx(thr);

if (!(flags & BTR_KEEP_SYS_FLAG)) {
row_upd_index_entry_sys_field(new_entry, index, DATA_ROLL_PTR,
roll_ptr);
row_upd_index_entry_sys_field(new_entry, index, DATA_TRX_ID,
thr_get_trx(thr)->id);
trx->id);
}

/* There are no externally stored columns in new_entry */
Expand Down Expand Up @@ -2217,9 +2219,7 @@ btr_cur_pessimistic_update(
/*=======================*/
ulint flags, /*!< in: undo logging, locking, and rollback
flags */
btr_cur_t* cursor, /*!< in/out: cursor on the record to update;
cursor may become invalid if *big_rec == NULL
|| !(flags & BTR_KEEP_POS_FLAG) */
btr_cur_t* cursor, /*!< in: cursor on the record to update */
mem_heap_t** heap, /*!< in/out: pointer to memory heap, or NULL */
big_rec_t** big_rec,/*!< out: big rec vector whose fields have to
be stored externally by the caller, or NULL */
Expand Down Expand Up @@ -2358,7 +2358,7 @@ btr_cur_pessimistic_update(
record to be inserted: we have to remember which fields were such */

ut_ad(!page_is_comp(page) || !rec_get_node_ptr_flag(rec));
ut_ad(rec_offs_validate(rec, index, offsets));
offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, heap);
n_ext += btr_push_update_extern_fields(new_entry, update, *heap);

if (UNIV_LIKELY_NULL(page_zip)) {
Expand All @@ -2381,10 +2381,6 @@ btr_cur_pessimistic_update(
err = DB_TOO_BIG_RECORD;
goto return_after_reservations;
}

ut_ad(page_is_leaf(page));
ut_ad(dict_index_is_clust(index));
ut_ad(flags & BTR_KEEP_POS_FLAG);
}

/* Store state of explicit locks on rec on the page infimum record,
Expand Down Expand Up @@ -2412,8 +2408,6 @@ btr_cur_pessimistic_update(
rec = btr_cur_insert_if_possible(cursor, new_entry, n_ext, mtr);

if (rec) {
page_cursor->rec = rec;

lock_rec_restore_from_page_infimum(btr_cur_get_block(cursor),
rec, block);

Expand All @@ -2427,10 +2421,7 @@ btr_cur_pessimistic_update(
rec, index, offsets, mtr);
}

btr_cur_compress_if_useful(
cursor,
big_rec_vec != NULL && (flags & BTR_KEEP_POS_FLAG),
mtr);
btr_cur_compress_if_useful(cursor, mtr);

if (page_zip && !dict_index_is_clust(index)
&& page_is_leaf(page)) {
Expand All @@ -2450,21 +2441,6 @@ btr_cur_pessimistic_update(
}
}

if (big_rec_vec) {
ut_ad(page_is_leaf(page));
ut_ad(dict_index_is_clust(index));
ut_ad(flags & BTR_KEEP_POS_FLAG);

/* btr_page_split_and_insert() in
btr_cur_pessimistic_insert() invokes
mtr_memo_release(mtr, index->lock, MTR_MEMO_X_LOCK).
We must keep the index->lock when we created a
big_rec, so that row_upd_clust_rec() can store the
big_rec in the same mini-transaction. */

mtr_x_lock(dict_index_get_lock(index), mtr);
}

/* Was the record to be updated positioned as the first user
record on its page? */
was_first = page_cur_is_before_first(page_cursor);
Expand All @@ -2480,7 +2456,6 @@ btr_cur_pessimistic_update(
ut_a(rec);
ut_a(err == DB_SUCCESS);
ut_a(dummy_big_rec == NULL);
page_cursor->rec = rec;

if (dict_index_is_sec_or_ibuf(index)) {
/* Update PAGE_MAX_TRX_ID in the index page header.
Expand Down Expand Up @@ -2915,12 +2890,10 @@ UNIV_INTERN
ibool
btr_cur_compress_if_useful(
/*=======================*/
btr_cur_t* cursor, /*!< in/out: cursor on the page to compress;
cursor does not stay valid if !adjust and
compression occurs */
ibool adjust, /*!< in: TRUE if should adjust the
cursor position even if compression occurs */
mtr_t* mtr) /*!< in/out: mini-transaction */
btr_cur_t* cursor, /*!< in: cursor on the page to compress;
cursor does not stay valid if compression
occurs */
mtr_t* mtr) /*!< in: mtr */
{
ut_ad(mtr_memo_contains(mtr,
dict_index_get_lock(btr_cur_get_index(cursor)),
Expand All @@ -2929,7 +2902,7 @@ btr_cur_compress_if_useful(
MTR_MEMO_PAGE_X_FIX));

return(btr_cur_compress_recommendation(cursor, mtr)
&& btr_compress(cursor, adjust, mtr));
&& btr_compress(cursor, mtr));
}

/*******************************************************//**
Expand Down Expand Up @@ -3171,7 +3144,7 @@ btr_cur_pessimistic_delete(
mem_heap_free(heap);

if (ret == FALSE) {
ret = btr_cur_compress_if_useful(cursor, FALSE, mtr);
ret = btr_cur_compress_if_useful(cursor, mtr);
}

if (n_extents > 0) {
Expand Down Expand Up @@ -4160,9 +4133,6 @@ btr_store_big_rec_extern_fields_func(
the "external storage" flags in offsets
will not correspond to rec when
this function returns */
const big_rec_t*big_rec_vec, /*!< in: vector containing fields
to be stored externally */

#ifdef UNIV_DEBUG
mtr_t* local_mtr, /*!< in: mtr containing the
latch to rec and to the tree */
Expand All @@ -4171,11 +4141,9 @@ btr_store_big_rec_extern_fields_func(
ibool update_in_place,/*! in: TRUE if the record is updated
in place (not delete+insert) */
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
mtr_t* alloc_mtr) /*!< in/out: in an insert, NULL;
in an update, local_mtr for
allocating BLOB pages and
updating BLOB pointers; alloc_mtr
must not have freed any leaf pages */
const big_rec_t*big_rec_vec) /*!< in: vector containing fields
to be stored externally */

{
ulint rec_page_no;
byte* field_ref;
Expand All @@ -4194,9 +4162,6 @@ btr_store_big_rec_extern_fields_func(

ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_any_extern(offsets));
ut_ad(local_mtr);
ut_ad(!alloc_mtr || alloc_mtr == local_mtr);
ut_ad(!update_in_place || alloc_mtr);
ut_ad(mtr_memo_contains(local_mtr, dict_index_get_lock(index),
MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(local_mtr, rec_block, MTR_MEMO_PAGE_X_FIX));
Expand All @@ -4212,25 +4177,6 @@ btr_store_big_rec_extern_fields_func(
rec_page_no = buf_block_get_page_no(rec_block);
ut_a(fil_page_get_type(page_align(rec)) == FIL_PAGE_INDEX);

if (alloc_mtr) {
/* Because alloc_mtr will be committed after
mtr, it is possible that the tablespace has been
extended when the B-tree record was updated or
inserted, or it will be extended while allocating
pages for big_rec.
TODO: In mtr (not alloc_mtr), write a redo log record
about extending the tablespace to its current size,
and remember the current size. Whenever the tablespace
grows as pages are allocated, write further redo log
records to mtr. (Currently tablespace extension is not
covered by the redo log. If it were, the record would
only be written to alloc_mtr, which is committed after
mtr.) */
} else {
alloc_mtr = &mtr;
}

if (UNIV_LIKELY_NULL(page_zip)) {
int err;

Expand Down Expand Up @@ -4307,7 +4253,7 @@ btr_store_big_rec_extern_fields_func(
}

block = btr_page_alloc(index, hint_page_no,
FSP_NO_DIR, 0, alloc_mtr, &mtr);
FSP_NO_DIR, 0, &mtr);
if (UNIV_UNLIKELY(block == NULL)) {

mtr_commit(&mtr);
Expand Down Expand Up @@ -4434,15 +4380,11 @@ btr_store_big_rec_extern_fields_func(
goto next_zip_page;
}

if (alloc_mtr == &mtr) {
rec_block = buf_page_get(
space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(
rec_block,
SYNC_NO_ORDER_CHECK);
}
rec_block = buf_page_get(space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(rec_block,
SYNC_NO_ORDER_CHECK);

if (err == Z_STREAM_END) {
mach_write_to_4(field_ref
Expand Down Expand Up @@ -4476,8 +4418,7 @@ btr_store_big_rec_extern_fields_func(

page_zip_write_blob_ptr(
page_zip, rec, index, offsets,
big_rec_vec->fields[i].field_no,
alloc_mtr);
big_rec_vec->fields[i].field_no, &mtr);

next_zip_page:
prev_page_no = page_no;
Expand Down Expand Up @@ -4522,23 +4463,19 @@ btr_store_big_rec_extern_fields_func(

extern_len -= store_len;

if (alloc_mtr == &mtr) {
rec_block = buf_page_get(
space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(
rec_block,
SYNC_NO_ORDER_CHECK);
}
rec_block = buf_page_get(space_id, zip_size,
rec_page_no,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(rec_block,
SYNC_NO_ORDER_CHECK);

mlog_write_ulint(field_ref + BTR_EXTERN_LEN, 0,
MLOG_4BYTES, alloc_mtr);
MLOG_4BYTES, &mtr);
mlog_write_ulint(field_ref
+ BTR_EXTERN_LEN + 4,
big_rec_vec->fields[i].len
- extern_len,
MLOG_4BYTES, alloc_mtr);
MLOG_4BYTES, &mtr);

if (prev_page_no == FIL_NULL) {
btr_blob_dbg_add_blob(
Expand All @@ -4548,19 +4485,18 @@ btr_store_big_rec_extern_fields_func(

mlog_write_ulint(field_ref
+ BTR_EXTERN_SPACE_ID,
space_id, MLOG_4BYTES,
alloc_mtr);
space_id,
MLOG_4BYTES, &mtr);

mlog_write_ulint(field_ref
+ BTR_EXTERN_PAGE_NO,
page_no, MLOG_4BYTES,
alloc_mtr);
page_no,
MLOG_4BYTES, &mtr);

mlog_write_ulint(field_ref
+ BTR_EXTERN_OFFSET,
FIL_PAGE_DATA,
MLOG_4BYTES,
alloc_mtr);
MLOG_4BYTES, &mtr);
}

prev_page_no = page_no;
Expand Down
25 changes: 25 additions & 0 deletions storage/innobase/buf/buf0buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,31 @@ buf_page_set_accessed_make_young(
}
}

/********************************************************************//**
Resets the check_index_page_at_flush field of a page if found in the buffer
pool. */
UNIV_INTERN
void
buf_reset_check_index_page_at_flush(
/*================================*/
ulint space, /*!< in: space id */
ulint offset) /*!< in: page number */
{
buf_block_t* block;
buf_pool_t* buf_pool = buf_pool_get(space, offset);

buf_pool_mutex_enter(buf_pool);

block = (buf_block_t*) buf_page_hash_get(buf_pool, space, offset);

if (block && buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE) {
ut_ad(!buf_pool_watch_is_sentinel(buf_pool, &block->page));
block->check_index_page_at_flush = FALSE;
}

buf_pool_mutex_exit(buf_pool);
}

/********************************************************************//**
Returns the current state of is_hashed of a page. FALSE if the page is
not in the pool. NOTE that this operation does not fix the page in the
Expand Down
Loading

0 comments on commit e8cc313

Please sign in to comment.