fsp_reserve_free_extents switches from small to big tblspace handling too early
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
MySQL Server |
Unknown
|
Unknown
|
|||
Percona Server moved to https://jira.percona.com/projects/PS |
Fix Released
|
High
|
Laurynas Biveinis | ||
5.1 |
Won't Fix
|
Low
|
Unassigned | ||
5.5 |
Fix Released
|
High
|
Laurynas Biveinis | ||
5.6 |
Fix Released
|
High
|
Laurynas Biveinis |
Bug Description
Description:
fsp_reserve_
First, all newly-created tablespaces have their FSP_FREE_LIMIT initialized to 64 in fsp_fill_
"note that in a single-table tablespace where size < 64 pages, this number is 64, i.e., we have initialized the space about the first extent, but have not physically allocted those pages to the file"
But fsp_reserve_
if (size < FSP_EXTENT_SIZE / 2) {
/* Use different rules for small single-table tablespaces */
*n_reserved = 0;
return(
}
This means that, whenever size > 32 and < 64, fsp_reserve_
n_free_up = (size - free_limit) / FSP_EXTENT_SIZE;
where free_limit = 64 and size < 64.
If that kind of unsigned math was intended there, it should be explained at least. But the code, including the call to fil_space_
Some sample var values with size between 32 and 64:
(gdb) print n_free_up
$3 = 288230376151711743
(gdb) print n_free_up
$4 = 270215977642229759
(gdb) print n_free
$6 = 270215977642229759
2808 if (n_free <= reserve + n_ext) {
(gdb) print reserve
$9 = 2
(gdb) print n_ext
$10 = 3
(gdb) n
2825 success = fil_space_
My first fix idea would be to cut off small tablespace handling at 64 pages instead of 32 pages. But I am not familiar with this code enough to suggest that this would be correct.
How to repeat:
innodb_
Note that my suggested fix perturbs the resulting size of tablespaces as checked by the testcase:
@@ -987,7 +987,7 @@
AND table_name='tab5' AND database_
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
@@ -1013,7 +1013,7 @@
AND table_name='tab5' AND database_
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
===============
@@ -1040,7 +1040,7 @@
AND table_name='tab5' AND database_
AND index_name like 'idx%' ;
compress_stat 1
-The size of the tab5.ibd file: 159744
+The size of the tab5.ibd file: 163840
#cleanup
DROP TABLE IF EXISTS tab5;
#reset the stat table before starting next testcase
Suggested fix:
=== modified file 'storage/
--- storage/
+++ storage/
@@ -2681,7 +2681,7 @@
ulint n_used;
ut_a(space != 0);
- ut_a(size < FSP_EXTENT_SIZE / 2);
+ ut_a(size < FSP_EXTENT_SIZE);
descr = xdes_get_
mtr);
@@ -2761,7 +2761,7 @@
try_again:
size = mtr_read_
- if (size < FSP_EXTENT_SIZE / 2) {
+ if (size < FSP_EXTENT_SIZE) {
/* Use different rules for small single-table tablespaces */
*n_reserved = 0;
return(
@@ -2776,6 +2776,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) {
Related branches
- Stewart Smith (community): Approve
-
Diff: 223 lines (+169/-9)4 files modifiedPercona-Server/mysql-test/include/percona_show_ibd_size.inc (+7/-0)
Percona-Server/mysql-test/suite/innodb/r/percona_ibd_size.result (+48/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_ibd_size.test (+108/-0)
Percona-Server/storage/innobase/fsp/fsp0fsp.c (+6/-9)
- Stewart Smith (community): Approve
-
Diff: 253 lines (+172/-11)5 files modifiedPercona-Server/mysql-test/include/percona_show_ibd_size.inc (+7/-0)
Percona-Server/mysql-test/suite/innodb/r/innodb_wl6347_comp_indx_stat.result (+3/-3)
Percona-Server/mysql-test/suite/innodb/r/percona_ibd_size.result (+48/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_ibd_size.test (+108/-0)
Percona-Server/storage/innobase/fsp/fsp0fsp.cc (+6/-8)
tags: | added: innodb |
Setting triage to High because the combination of the bug 1083700 fix and this bug results in more than 10x size increase in small tablespaces, as shown by innodb_ wl6347_ comp_indx_ stat:
@@ -987,7 +987,7 @@ name='test' name='test' name='test'
AND table_name='tab5' AND database_
AND index_name like 'idx%' ;
compress_stat 1
-The size of the tab5.ibd file: 159744
+The size of the tab5.ibd file: 2097152
# fetch the compressed page and check the stats
===============
Fetch Records
@@ -1013,7 +1013,7 @@
AND table_name='tab5' AND database_
AND index_name like 'idx%' ;
compress_stat 1
-The size of the tab5.ibd file: 159744
+The size of the tab5.ibd file: 2097152
# fetch the compressed same page once again and check the stats
# the stat figures should be same as above query
===============
@@ -1040,7 +1040,7 @@
AND table_name='tab5' AND database_
AND index_name like 'idx%' ;
compress_stat 1
-The size of the tab5.ibd file: 159744
+The size of the tab5.ibd file: 2097152
#cleanup
DROP TABLE IF EXISTS tab5;
#reset the stat table before starting next testcase