Commit 483faa77 authored by marko's avatar marko

branches/zip: Fix some crash recovery bugs.

page_zip_alloc(): Add parameter "mtr" and log successful calls
to page_zip_compress().

page_zip_write_blob_ptr(), page_zip_write_node_ptr(): Write the offset on
the uncompressed page, because mlog_write_initial_log_record_fast()
does not do so.

page_zip_write_header_log(), page_zip_parse_write_header(): Encode the
offset in one byte.
parent f119108f
...@@ -1577,7 +1577,7 @@ btr_cur_update_in_place( ...@@ -1577,7 +1577,7 @@ btr_cur_update_in_place(
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& UNIV_UNLIKELY(!page_zip_alloc(page_zip, && UNIV_UNLIKELY(!page_zip_alloc(page_zip,
buf_block_get_frame(block), index, buf_block_get_frame(block), index,
rec_offs_size(offsets), 0))) { rec_offs_size(offsets), 0, mtr))) {
return(DB_ZIP_OVERFLOW); return(DB_ZIP_OVERFLOW);
} }
...@@ -1746,7 +1746,7 @@ btr_cur_optimistic_update( ...@@ -1746,7 +1746,7 @@ btr_cur_optimistic_update(
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& !page_zip_alloc(page_zip, page, index, && !page_zip_alloc(page_zip, page, index,
new_rec_size, 0)) { new_rec_size, 0, mtr)) {
mem_heap_free(heap); mem_heap_free(heap);
return(DB_ZIP_OVERFLOW); return(DB_ZIP_OVERFLOW);
......
...@@ -94,8 +94,9 @@ page_zip_alloc( ...@@ -94,8 +94,9 @@ page_zip_alloc(
const page_t* page, /* in: uncompressed page */ const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */ ulint length, /* in: combined size of the record */
ulint create) /* in: nonzero=add the record to the heap */ ulint create, /* in: nonzero=add the record to the heap */
__attribute__((warn_unused_result, nonnull)); mtr_t* mtr) /* in: mini-transaction, or NULL */
__attribute__((warn_unused_result, nonnull(1,2,3)));
/************************************************************************** /**************************************************************************
Write an entire record on the compressed page. The data must already Write an entire record on the compressed page. The data must already
......
...@@ -156,7 +156,8 @@ page_zip_alloc( ...@@ -156,7 +156,8 @@ page_zip_alloc(
const page_t* page, /* in: uncompressed page */ const page_t* page, /* in: uncompressed page */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
ulint length, /* in: combined size of the record */ ulint length, /* in: combined size of the record */
ulint create) /* in: nonzero=add the record to the heap */ ulint create, /* in: nonzero=add the record to the heap */
mtr_t* mtr) /* in: mini-transaction, or NULL */
{ {
ut_ad(page_is_comp((page_t*) page)); ut_ad(page_is_comp((page_t*) page));
ut_ad(page_zip_validate(page_zip, page)); ut_ad(page_zip_validate(page_zip, page));
...@@ -171,7 +172,11 @@ page_zip_alloc( ...@@ -171,7 +172,11 @@ page_zip_alloc(
return(FALSE); return(FALSE);
} }
if (!page_zip_compress(page_zip, page, index)) { if (page_zip_compress(page_zip, page, index)) {
if (mtr) {
page_zip_compress_write_log(page_zip, page, mtr);
}
} else {
/* Unable to compress the page */ /* Unable to compress the page */
return(FALSE); return(FALSE);
} }
......
...@@ -921,7 +921,7 @@ page_cur_insert_rec_low( ...@@ -921,7 +921,7 @@ page_cur_insert_rec_low(
/* 2. Try to find suitable space from page memory management */ /* 2. Try to find suitable space from page memory management */
if (UNIV_LIKELY_NULL(page_zip) if (UNIV_LIKELY_NULL(page_zip)
&& !page_zip_alloc(page_zip, page, index, rec_size, 1)) { && !page_zip_alloc(page_zip, page, index, rec_size, 1, mtr)) {
return(NULL); return(NULL);
} }
......
...@@ -2262,13 +2262,16 @@ page_zip_write_blob_ptr( ...@@ -2262,13 +2262,16 @@ page_zip_write_blob_ptr(
if (mtr) { if (mtr) {
byte* log_ptr = mlog_open(mtr, byte* log_ptr = mlog_open(mtr,
11 + 2 + BTR_EXTERN_FIELD_REF_SIZE); 11 + 2 + 2 + BTR_EXTERN_FIELD_REF_SIZE);
if (UNIV_UNLIKELY(!log_ptr)) { if (UNIV_UNLIKELY(!log_ptr)) {
return; return;
} }
log_ptr = mlog_write_initial_log_record_fast((byte*) field, log_ptr = mlog_write_initial_log_record_fast((byte*) field,
MLOG_ZIP_WRITE_BLOB_PTR, log_ptr, mtr); MLOG_ZIP_WRITE_BLOB_PTR, log_ptr, mtr);
mach_write_to_2(log_ptr,
ut_align_offset(field, UNIV_PAGE_SIZE));
log_ptr += 2;
mach_write_to_2(log_ptr, externs - page_zip->data); mach_write_to_2(log_ptr, externs - page_zip->data);
log_ptr += 2; log_ptr += 2;
memcpy(log_ptr, externs, BTR_EXTERN_FIELD_REF_SIZE); memcpy(log_ptr, externs, BTR_EXTERN_FIELD_REF_SIZE);
...@@ -2397,13 +2400,17 @@ page_zip_write_node_ptr( ...@@ -2397,13 +2400,17 @@ page_zip_write_node_ptr(
memcpy(storage, field, REC_NODE_PTR_SIZE); memcpy(storage, field, REC_NODE_PTR_SIZE);
if (mtr) { if (mtr) {
byte* log_ptr = mlog_open(mtr, 11 + 2 + REC_NODE_PTR_SIZE); byte* log_ptr = mlog_open(mtr,
11 + 2 + 2 + REC_NODE_PTR_SIZE);
if (UNIV_UNLIKELY(!log_ptr)) { if (UNIV_UNLIKELY(!log_ptr)) {
return; return;
} }
log_ptr = mlog_write_initial_log_record_fast(field, log_ptr = mlog_write_initial_log_record_fast(field,
MLOG_ZIP_WRITE_NODE_PTR, log_ptr, mtr); MLOG_ZIP_WRITE_NODE_PTR, log_ptr, mtr);
mach_write_to_2(log_ptr,
ut_align_offset(field, UNIV_PAGE_SIZE));
log_ptr += 2;
mach_write_to_2(log_ptr, storage - page_zip->data); mach_write_to_2(log_ptr, storage - page_zip->data);
log_ptr += 2; log_ptr += 2;
memcpy(log_ptr, field, REC_NODE_PTR_SIZE); memcpy(log_ptr, field, REC_NODE_PTR_SIZE);
...@@ -2780,13 +2787,12 @@ page_zip_parse_write_header( ...@@ -2780,13 +2787,12 @@ page_zip_parse_write_header(
ut_ad(!page == !page_zip); ut_ad(!page == !page_zip);
if (UNIV_UNLIKELY(end_ptr < ptr + (2 + 1))) { if (UNIV_UNLIKELY(end_ptr < ptr + (1 + 1))) {
return(NULL); return(NULL);
} }
offset = mach_read_from_2(ptr); offset = (ulint) *ptr++;
ptr += 2;
len = (ulint) *ptr++; len = (ulint) *ptr++;
if (UNIV_UNLIKELY(!len) || UNIV_UNLIKELY(offset + len >= PAGE_DATA) if (UNIV_UNLIKELY(!len) || UNIV_UNLIKELY(offset + len >= PAGE_DATA)
...@@ -2828,7 +2834,7 @@ page_zip_write_header_log( ...@@ -2828,7 +2834,7 @@ page_zip_write_header_log(
ulint length, /* in: length of the data */ ulint length, /* in: length of the data */
mtr_t* mtr) /* in: mini-transaction */ mtr_t* mtr) /* in: mini-transaction */
{ {
byte* log_ptr = mlog_open(mtr, 11 + 1); byte* log_ptr = mlog_open(mtr, 11 + 1 + 1);
ut_ad(offset < PAGE_DATA); ut_ad(offset < PAGE_DATA);
ut_ad(offset + length < PAGE_DATA); ut_ad(offset + length < PAGE_DATA);
#if PAGE_DATA > 255 #if PAGE_DATA > 255
...@@ -2844,6 +2850,7 @@ page_zip_write_header_log( ...@@ -2844,6 +2850,7 @@ page_zip_write_header_log(
log_ptr = mlog_write_initial_log_record_fast(page_zip->data + offset, log_ptr = mlog_write_initial_log_record_fast(page_zip->data + offset,
MLOG_ZIP_WRITE_HEADER, log_ptr, mtr); MLOG_ZIP_WRITE_HEADER, log_ptr, mtr);
*log_ptr++ = (byte) offset;
*log_ptr++ = (byte) length; *log_ptr++ = (byte) length;
mlog_close(mtr, log_ptr); mlog_close(mtr, log_ptr);
......
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