Commit a6fe621c authored by marko's avatar marko

branches/zip: Minor improvements.

page_set_max_trx_id(), page_update_max_trx_id(): Add parameter page_zip.

Check that page_zip_decompress() is never called after modifying the
header or trailer of the compressed page, i.e., that page_zip_decompress()
will restore the uncompressed page as it was before the failed operation.
parent d4231b11
......@@ -891,7 +891,7 @@ btr_page_reorganize_low(
page_copy_rec_list_end_no_locks(page,
page_get_infimum_rec(new_page), index, mtr);
/* Copy max trx id to recreated page */
page_set_max_trx_id(page, page_get_max_trx_id(new_page));
page_set_max_trx_id(page, NULL, page_get_max_trx_id(new_page));
if (UNIV_LIKELY_NULL(page_zip)) {
if (UNIV_UNLIKELY(!page_zip_compress(page_zip, page))) {
......
......@@ -1795,8 +1795,6 @@ btr_cur_optimistic_update(
lock_rec_restore_from_page_infimum(rec, page);
page_cur_move_to_next(page_cursor);
mem_heap_free(heap);
return(DB_SUCCESS);
......
......@@ -2664,7 +2664,7 @@ ibuf_insert_low(
&mtr);
if (err == DB_SUCCESS) {
/* Update the page max trx id field */
page_update_max_trx_id(buf_frame_align(ins_rec),
page_update_max_trx_id(buf_frame_align(ins_rec), NULL,
thr_get_trx(thr)->id);
}
} else {
......@@ -2685,7 +2685,7 @@ ibuf_insert_low(
&mtr);
if (err == DB_SUCCESS) {
/* Update the page max trx id field */
page_update_max_trx_id(buf_frame_align(ins_rec),
page_update_max_trx_id(buf_frame_align(ins_rec), NULL,
thr_get_trx(thr)->id);
}
......@@ -3214,8 +3214,8 @@ ibuf_merge_or_delete_for_page(
dict_index_t* dummy_index;
dulint max_trx_id = page_get_max_trx_id(
buf_frame_align(ibuf_rec));
page_update_max_trx_id(page, max_trx_id);
page_update_max_trx_id(page, NULL, max_trx_id);
entry = ibuf_build_entry_from_ibuf_rec(ibuf_rec,
heap, &dummy_index);
#ifdef UNIV_IBUF_DEBUG
......
......@@ -145,8 +145,10 @@ Sets the max trx id field value. */
void
page_set_max_trx_id(
/*================*/
page_t* page, /* in/out: page */
dulint trx_id);/* in: transaction id */
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
dulint trx_id);/* in: transaction id */
/*****************************************************************
Sets the max trx id field value if trx_id is bigger than the previous
value. */
......@@ -154,8 +156,10 @@ UNIV_INLINE
void
page_update_max_trx_id(
/*===================*/
page_t* page, /* in/out: page */
dulint trx_id);/* in: transaction id */
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
dulint trx_id);/* in: transaction id */
/*****************************************************************
Reads the given header field. */
UNIV_INLINE
......
......@@ -35,14 +35,16 @@ UNIV_INLINE
void
page_update_max_trx_id(
/*===================*/
page_t* page, /* in/out: page */
dulint trx_id) /* in: transaction id */
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
dulint trx_id) /* in: transaction id */
{
ut_ad(page);
if (ut_dulint_cmp(page_get_max_trx_id(page), trx_id) < 0) {
page_set_max_trx_id(page, trx_id);
page_set_max_trx_id(page, page_zip, trx_id);
}
}
......
......@@ -4825,6 +4825,7 @@ lock_rec_insert_check_and_lock(
/* Update the page max trx id field */
page_update_max_trx_id(buf_frame_align(rec),
NULL/*TODO*/,
thr_get_trx(thr)->id);
}
......@@ -4863,6 +4864,7 @@ lock_rec_insert_check_and_lock(
/* Update the page max trx id field */
page_update_max_trx_id(buf_frame_align(rec),
NULL/*TODO*/,
thr_get_trx(thr)->id);
}
......@@ -5043,6 +5045,7 @@ lock_sec_rec_modify_check_and_lock(
/* Update the page max trx id field */
page_update_max_trx_id(buf_frame_align(rec),
NULL/*TODO*/,
thr_get_trx(thr)->id);
}
......
......@@ -200,8 +200,10 @@ Sets the max trx id field value. */
void
page_set_max_trx_id(
/*================*/
page_t* page, /* in/out: page */
dulint trx_id) /* in: transaction id */
page_t* page, /* in/out: page */
page_zip_des_t* page_zip,/* in/out: compressed page whose
uncompressed part will be updated, or NULL */
dulint trx_id) /* in: transaction id */
{
buf_block_t* block;
......@@ -218,6 +220,10 @@ page_set_max_trx_id(
page is the maximum trx id assigned before the crash. */
mach_write_to_8(page + (PAGE_HEADER + PAGE_MAX_TRX_ID), trx_id);
if (UNIV_LIKELY_NULL(page_zip)) {
page_zip_write_header(page_zip,
page + (PAGE_HEADER + PAGE_MAX_TRX_ID), 8);
}
if (block->is_hashed) {
rw_lock_x_unlock(&btr_search_latch);
......@@ -476,7 +482,7 @@ page_create(
page_header_set_field(page, NULL, PAGE_DIRECTION, PAGE_NO_DIRECTION);
page_header_set_field(page, NULL, PAGE_N_DIRECTION, 0);
page_header_set_field(page, NULL, PAGE_N_RECS, 0);
page_set_max_trx_id(page, ut_dulint_zero);
page_set_max_trx_id(page, NULL, ut_dulint_zero);
memset(heap_top, 0, UNIV_PAGE_SIZE - PAGE_EMPTY_DIR_START
- (heap_top - page));
......@@ -615,25 +621,25 @@ page_copy_rec_list_end(
page = ut_align_down(rec, UNIV_PAGE_SIZE);
/* Update the lock table, MAX_TRX_ID, and possible hash index */
lock_move_rec_list_end(new_page, page, rec);
page_update_max_trx_id(new_page, page_get_max_trx_id(page));
if (UNIV_LIKELY_NULL(new_page_zip)) {
if (UNIV_UNLIKELY(!page_zip_compress(new_page_zip,
new_page))) {
if (UNIV_UNLIKELY(!page_zip_decompress(
new_page_zip, new_page, mtr))) {
/* TODO: does not work */
ut_error;
}
return(FALSE);
}
}
/* Update the lock table, MAX_TRX_ID, and possible hash index */
lock_move_rec_list_end(new_page, page, rec);
page_update_max_trx_id(new_page, new_page_zip,
page_get_max_trx_id(page));
btr_search_move_or_delete_hash_entries(new_page, page, index);
return(TRUE);
......@@ -696,10 +702,6 @@ page_copy_rec_list_start(
mem_heap_free(heap);
}
/* Update MAX_TRX_ID, the lock table, and possible hash index */
page_update_max_trx_id(new_page, page_get_max_trx_id(page));
if (UNIV_LIKELY_NULL(new_page_zip)) {
if (UNIV_UNLIKELY(!page_zip_compress(new_page_zip,
new_page))) {
......@@ -713,6 +715,11 @@ page_copy_rec_list_start(
}
}
/* Update MAX_TRX_ID, the lock table, and possible hash index */
page_update_max_trx_id(new_page, new_page_zip,
page_get_max_trx_id(page));
lock_move_rec_list_start(new_page, page, rec, old_end);
btr_search_move_or_delete_hash_entries(new_page, page, index);
......@@ -1116,7 +1123,8 @@ page_move_rec_list_start(
temp_page - page + split_rec, index, mtr);
/* Copy max trx id to recreated page */
page_set_max_trx_id(page, page_get_max_trx_id(temp_page));
page_set_max_trx_id(page, NULL,
page_get_max_trx_id(temp_page));
/* Update the record lock bitmaps */
lock_move_reorganize_page(page, temp_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment