Commit 0d59bf8e authored by marko's avatar marko

branches/zip: Avoid infinite page splits on compressed tables.

btr_page_get_sure_split_rec(): Remove the check if insert_size
exceeds free_space.

btr_page_split_and_insert(): If a compressed page has already been split,
avoid further splits by inserting the record to an empty page.  As a
performance optimization, avoid invoking btr_page_insert_fits() on
compressed tables.
parent b060f8ba
...@@ -1367,10 +1367,6 @@ btr_page_get_sure_split_rec( ...@@ -1367,10 +1367,6 @@ btr_page_get_sure_split_rec(
if (UNIV_LIKELY(free_space > (ulint) free_space_zip)) { if (UNIV_LIKELY(free_space > (ulint) free_space_zip)) {
free_space = (ulint) free_space_zip; free_space = (ulint) free_space_zip;
if (UNIV_UNLIKELY(insert_size > free_space)) {
return(NULL);
}
} }
} }
...@@ -1815,7 +1811,23 @@ func_start: ...@@ -1815,7 +1811,23 @@ func_start:
if (split_rec) { if (split_rec) {
first_rec = move_limit = split_rec; first_rec = move_limit = split_rec;
offsets = rec_get_offsets(split_rec, cursor->index, offsets,
n_uniq, &heap);
insert_left = cmp_dtuple_rec(tuple, split_rec, offsets) < 0;
if (UNIV_UNLIKELY(!insert_left && new_page_zip
&& n_iterations > 0)) {
/* If a compressed page has already been split,
avoid further splits by inserting the record
to an empty page. */
split_rec = NULL;
goto insert_right;
}
} else { } else {
insert_right:
insert_left = FALSE;
buf = mem_alloc(rec_get_converted_size(cursor->index, buf = mem_alloc(rec_get_converted_size(cursor->index,
tuple, n_ext)); tuple, n_ext));
...@@ -1835,22 +1847,17 @@ func_start: ...@@ -1835,22 +1847,17 @@ func_start:
thus reducing the tree latch contention. */ thus reducing the tree latch contention. */
if (split_rec) { if (split_rec) {
offsets = rec_get_offsets(split_rec, cursor->index, offsets, insert_will_fit = !new_page_zip
n_uniq, &heap); && btr_page_insert_fits(cursor, split_rec,
offsets, tuple, n_ext, heap);
insert_left = cmp_dtuple_rec(tuple, split_rec, offsets) < 0;
insert_will_fit = btr_page_insert_fits(cursor, split_rec,
offsets, tuple,
n_ext, heap);
} else { } else {
mem_free(buf); mem_free(buf);
insert_left = FALSE; insert_will_fit = !new_page_zip
insert_will_fit = btr_page_insert_fits(cursor, NULL, && btr_page_insert_fits(cursor, NULL,
NULL, tuple, NULL, tuple, n_ext, heap);
n_ext, heap);
} }
if (insert_will_fit && page_is_leaf(page) && !page_zip) { if (insert_will_fit && page_is_leaf(page)) {
mtr_memo_release(mtr, dict_index_get_lock(cursor->index), mtr_memo_release(mtr, dict_index_get_lock(cursor->index),
MTR_MEMO_X_LOCK); MTR_MEMO_X_LOCK);
...@@ -1985,8 +1992,7 @@ insert_failed: ...@@ -1985,8 +1992,7 @@ insert_failed:
n_iterations++; n_iterations++;
ut_ad(n_iterations < 2 ut_ad(n_iterations < 2
|| buf_block_get_page_zip(insert_block)); || buf_block_get_page_zip(insert_block));
ut_ad(!insert_will_fit ut_ad(!insert_will_fit);
|| buf_block_get_page_zip(insert_block));
goto func_start; goto func_start;
} }
......
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