------------------------------------------------------------ revno: 8777 committer: Laurynas Biveinis branch nick: mysql-5.7-percona-patches timestamp: Thu 2014-11-06 20:59:50 +0200 message: Fix http://bugs.mysql.com/bug.php?id=68970 (fsp_reserve_free_extents switches from small to big tblspace handling too early) by: - adjusting fsp_reserve_free_extents to actually do the documented logic of using special rules for small single-table tablespaces for the ones smaller than FSP_EXTENT_SIZE pages rather than FSP_EXTENT_SIZE / 2 pages. This applies for non-BLOB reservation type, which is not subject to special small tablespace handling. - in the same function, set the number of available free extents n_free_up to zero instead of overwrapped large numbers if allocating for BLOBs. - tweak assertion in fsp_reserve_free_pages for the new cutoff value. - add assert to fsp_get_available_space_in_free_extents that we don't end up with overwrapped free extent value. - re-record innodb_zip.innodb_wl6347_comp_indx_stat as with the above changes the tablespace file ends up being one page larger at the check time. diff: === modified file 'mysql-test/suite/innodb_zip/r/innodb_wl6347_comp_indx_stat.result' --- mysql-test/suite/innodb_zip/r/innodb_wl6347_comp_indx_stat.result 2014-08-29 08:20:34 +0000 +++ mysql-test/suite/innodb_zip/r/innodb_wl6347_comp_indx_stat.result 2014-11-06 18:59:50 +0000 @@ -981,7 +981,7 @@ AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 159744 +The size of the tab5.ibd file: 163840 # fetch the compressed page and check the stats =============== Fetch Records @@ -1007,7 +1007,7 @@ AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 159744 +The size of the tab5.ibd file: 163840 # fetch the compressed same page once again and check the stats # the stat figures should be same as above query =============== @@ -1034,7 +1034,7 @@ AND table_name='tab5' AND database_name='test' AND index_name like 'idx%' ; compress_stat 1 -The size of the tab5.ibd file: 159744 +The size of the tab5.ibd file: 163840 DROP TABLE tab5; #reset the stat table before starting next testcase SET GLOBAL innodb_cmp_per_index_enabled=0; === modified file 'storage/innobase/fsp/fsp0fsp.cc' --- storage/innobase/fsp/fsp0fsp.cc 2014-08-29 09:18:37 +0000 +++ storage/innobase/fsp/fsp0fsp.cc 2014-11-06 18:59:50 +0000 @@ -2868,7 +2868,7 @@ ulint n_used; ut_a(!is_system_tablespace(space)); - ut_a(size < FSP_EXTENT_SIZE / 2); + ut_a(size < FSP_EXTENT_SIZE); descr = xdes_get_descriptor_with_space_hdr(space_header, space, 0, mtr); @@ -2949,7 +2949,7 @@ try_again: size = mtr_read_ulint(space_header + FSP_SIZE, MLOG_4BYTES, mtr); - if (alloc_type != FSP_BLOB && size < FSP_EXTENT_SIZE / 2) { + if (alloc_type != FSP_BLOB && size < FSP_EXTENT_SIZE) { /* Use different rules for small single-table tablespaces */ *n_reserved = 0; return(fsp_reserve_free_pages(space, space_header, size, mtr)); @@ -2964,7 +2964,12 @@ some of them will contain extent descriptor pages, and therefore will not be free extents */ - n_free_up = (size - free_limit) / FSP_EXTENT_SIZE; + if (size >= free_limit) { + n_free_up = (size - free_limit) / FSP_EXTENT_SIZE; + } else { + ut_ad(alloc_type == FSP_BLOB); + n_free_up = 0; + } if (n_free_up > 0) { n_free_up--; @@ -3122,6 +3127,7 @@ some of them will contain extent descriptor pages, and therefore will not be free extents */ + ut_ad(size >= free_limit); n_free_up = (size - free_limit) / FSP_EXTENT_SIZE; if (n_free_up > 0) {