commit b2fb272e44f459de312c07090347af9fa8165b08 Author: nizamordulu Date: 2 days ago Fix the bugs revealed by simulate_comp_failures test. Summary: This diff fixes the bugs revealed by the simulate_comp_failures test Test Plan: OK Reviewers: mcallaghan CC: db-eng@lists Differential Revision: https://phabricator.fb.com/D382730 Revert Plan: ok Task ID: 855216 diff --git a/storage/innodb_plugin/btr/btr0cur.c b/storage/innodb_plugin/btr/btr0cur.c index cd820e3..9112cf1 100644 --- a/storage/innodb_plugin/btr/btr0cur.c +++ b/storage/innodb_plugin/btr/btr0cur.c @@ -1226,7 +1226,10 @@ fail_err: if (UNIV_UNLIKELY(reorg)) { ut_a(zip_size); - ut_a(*rec); + /* It's possible for rec to be NULL if the page is compressed. + This is because a reorganized page may become incompressible */ + if (!*rec) + goto fail; } } @@ -2022,8 +2025,11 @@ any_extern: goto err_exit; } + /* We do not attempt to reorganize if the page is compressed. + This is because the page may fail to compress after reorganization */ max_size = old_rec_size - + page_get_max_insert_size_after_reorganize(page, 1); + + (page_zip ? page_get_max_insert_size(page, 1) + : page_get_max_insert_size_after_reorganize(page, 1)); if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMIT) && (max_size >= new_rec_size)) @@ -2384,7 +2390,10 @@ make_external: err = DB_SUCCESS; goto return_after_reservations; } else { - ut_a(optim_err != DB_UNDERFLOW); + /* If the page is compressed, it is possible for btr_cur_optimistic_update() + to return DB_UNDERFLOW and btr_cur_insert_if_possible() to return FALSE. + See http://bugs.mysql.com/bug.php?id=61208 */ + ut_a(page_zip || optim_err != DB_UNDERFLOW); /* Out of space: reset the free bits. */ if (!dict_index_is_clust(index) diff --git a/storage/innodb_plugin/page/page0page.c b/storage/innodb_plugin/page/page0page.c index 91ac5e8..b3d9036 100644 --- a/storage/innodb_plugin/page/page0page.c +++ b/storage/innodb_plugin/page/page0page.c @@ -817,10 +817,12 @@ page_copy_rec_list_start( /* The page was reorganized: Seek to ret_pos. */ ret = new_page + PAGE_NEW_INFIMUM; - - do { + /* ret_pos may be zero */ + while (ret_pos) { + ut_a(ret); ret = rec_get_next_ptr(ret, TRUE); - } while (--ret_pos); + --ret_pos; + } } } }