summaryrefslogtreecommitdiff
path: root/storage/innobase
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-08-16 17:34:38 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-08-17 11:08:49 +0530
commit32167225c728c19ca478bce0529d549a8d056f87 (patch)
tree00d79e501e7d0df37c7c1b134f32d40d47e462d3 /storage/innobase
parentc2080060801342f46849423adf71515ae7a33e04 (diff)
downloadmariadb-git-32167225c728c19ca478bce0529d549a8d056f87.tar.gz
MDEV-13013 InnoDB unnecessarily extends data files
- While creating a new InnoDB segment, allocates the extent before allocating the inode or page allocation even though the pages are present in fragment segment. This patch does reserve the extent when InnoDB ran out of fragment pages in the tablespace.
Diffstat (limited to 'storage/innobase')
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc38
1 files changed, 27 insertions, 11 deletions
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index ab143a16417..ba50483cee4 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1886,6 +1886,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr,
fseg_header_t* header = 0; /* remove warning */
ulint n_reserved;
ulint i;
+ bool reserved_extent = false;
DBUG_ENTER("fseg_create");
@@ -1909,17 +1910,34 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr,
fil_block_check_type(*block, type, mtr);
}
- if (!has_done_reservation
- && !fsp_reserve_free_extents(&n_reserved, space, 2,
- FSP_NORMAL, mtr)) {
- DBUG_RETURN(NULL);
- }
-
space_header = fsp_get_space_header(space, page_size, mtr);
+inode_alloc:
inode = fsp_alloc_seg_inode(space, space_header, mtr);
if (inode == NULL) {
+reserve_extent:
+ if (!has_done_reservation && !reserved_extent) {
+
+ if (!fsp_reserve_free_extents(
+ &n_reserved, space, 2,
+ FSP_NORMAL, mtr)) {
+ DBUG_RETURN(NULL);
+ }
+
+ /* Extents reserved successfully. So
+ try allocating the page or inode */
+ reserved_extent = true;
+ if (inode) {
+ goto page_alloc;
+ }
+
+ goto inode_alloc;
+ }
+
+ if (inode) {
+ fsp_free_seg_inode(space, page_size, inode, mtr);
+ }
goto funct_exit;
}
@@ -1944,6 +1962,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr,
}
if (!block) {
+page_alloc:
block = fseg_alloc_free_page_low(space, page_size,
inode, 0, FSP_UP,
mtr, mtr
@@ -1957,10 +1976,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr,
ut_ad(!has_done_reservation || block != NULL);
if (block == NULL) {
-
- fsp_free_seg_inode(space, page_size, inode, mtr);
-
- goto funct_exit;
+ goto reserve_extent;
}
ut_ad(rw_lock_get_x_lock_count(&block->lock) == 1);
@@ -1980,7 +1996,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr,
mlog_write_ulint(header + FSEG_HDR_SPACE, space->id, MLOG_4BYTES, mtr);
funct_exit:
- if (!has_done_reservation) {
+ if (!has_done_reservation && reserved_extent) {
space->release_free_extents(n_reserved);
}