Skip to content

Commit 953db42

Browse files
Bug #21640679 ONLINE ALTER CRASHES FOR 4K PAGE SIZE
WHEN THERE IS NO FREE EXTENT Problem: ======= When a new extent is allocated to a tablespace, its xdes entry will be put onto the FSP_FREE segment list. But extent happens to contain an extent descriptor page, then the extent is put into FSP_FREE_FRAG list. Still tablespace won't find any extent in FREE_LIST. It happens only when less than or equal to 4kb page size is used, because once the tablespace grows to 32 extent size or 32 MB then 4 extents are allocated at a time rather than one. For page size less than 4k only, allocation of extent contains extent descriptor page before reaching 32 extent or MB. Fix: === Once the tablespace size reaches page_size page then allocate 4 extent at a time. Reviewed-by: Annamalai Gurusami <[email protected]> Reviewed-by: Jimmy Yang <[email protected]> RB: 10267
1 parent 8fbefe8 commit 953db42

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

mysql-test/suite/innodb_zip/r/innodb_wl6347_comp_indx_stat.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ AND compress_ops BETWEEN @inl_val AND 1000
267267
AND table_name='tab5' AND database_name='test'
268268
AND index_name like 'idx%' ;
269269
compress_stat 1
270-
The size of the tab5.ibd file: 2097152
270+
The size of the tab5.ibd file: 5242880
271271
# fetch the compressed page and check the stats
272272
===============
273273
Fetch Records
@@ -293,7 +293,7 @@ AND compress_ops BETWEEN @inl_val AND 1000
293293
AND table_name='tab5' AND database_name='test'
294294
AND index_name like 'idx%' ;
295295
compress_stat 1
296-
The size of the tab5.ibd file: 2097152
296+
The size of the tab5.ibd file: 5242880
297297
# fetch the compressed same page once again and check the stats
298298
# the stat figures should be same as above query
299299
===============
@@ -320,7 +320,7 @@ AND compress_ops BETWEEN @inl_val AND 1000
320320
AND table_name='tab5' AND database_name='test'
321321
AND index_name like 'idx%' ;
322322
compress_stat 1
323-
The size of the tab5.ibd file: 2097152
323+
The size of the tab5.ibd file: 5242880
324324
# Restarting server
325325
# set the flag on (default off)
326326
SET GLOBAL innodb_cmp_per_index_enabled=ON;

storage/innobase/fsp/fsp0fsp.cc

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,10 +952,20 @@ fsp_try_extend_data_file(
952952
}
953953
} else {
954954
/* We extend single-table tablespaces first one extent
955-
at a time, but for bigger tablespaces more. It is not
956-
enough to extend always by one extent, because some
957-
extents are frag page extents. */
955+
at a time, but 4 at a time for bigger tablespaces. It is
956+
not enough to extend always by one extent, because we need
957+
to add at least one extent to FSP_FREE.
958+
A single extent descriptor page will track many extents.
959+
And the extent that uses its extent descriptor page is
960+
put onto the FSP_FREE_FRAG list. Extents that do not
961+
use their extent descriptor page are added to FSP_FREE.
962+
The physical page size is used to determine how many
963+
extents are tracked on one extent descriptor page. */
958964
ulint extent_size; /*!< one megabyte, in pages */
965+
ulint threshold; /*!< The size of the tablespace
966+
(in number of pages) where we
967+
start allocating more than one
968+
extent at a time. */
959969

960970
if (!zip_size) {
961971
extent_size = FSP_EXTENT_SIZE;
@@ -964,6 +974,14 @@ fsp_try_extend_data_file(
964974
* UNIV_PAGE_SIZE / zip_size;
965975
}
966976

977+
/* Threshold is set at 32mb except when the page
978+
size is small enough that it must be done sooner.
979+
For page size less than 4k, we may reach the
980+
extent contains extent descriptor page before
981+
32 mb. */
982+
threshold = ut_min((32 * extent_size),
983+
(zip_size ? zip_size : UNIV_PAGE_SIZE));
984+
967985
if (size < extent_size) {
968986
/* Let us first extend the file to extent_size */
969987
success = fsp_try_extend_data_file_with_pages(
@@ -980,7 +998,7 @@ fsp_try_extend_data_file(
980998
size = extent_size;
981999
}
9821000

983-
if (size < 32 * extent_size) {
1001+
if (size < threshold) {
9841002
size_increase = extent_size;
9851003
} else {
9861004
/* Below in fsp_fill_free_list() we assume

0 commit comments

Comments
 (0)