summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-08-01 12:18:18 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-08-16 12:25:29 +0530
commit14457d80f2b908c29ab1295d750d4fb3fd628e4d (patch)
tree1bb0c151a6bc0806e4ade1e110aea5a6982675d2
parent39cafb666b3d5a551dfacb7168c4ad90010327cb (diff)
downloadmariadb-git-bb-10.6-MDEV-13013.tar.gz
MDEV-13013 InnoDB unnecessarily extends data filesbb-10.6-MDEV-13013
- 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.
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff12
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff12
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff12
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff12
-rw-r--r--mysql-test/suite/innodb/r/check_ibd_filesize.result4
-rw-r--r--mysql-test/suite/innodb/t/temporary_table.test1
-rw-r--r--storage/innobase/fsp/fsp0fsp.cc41
7 files changed, 56 insertions, 38 deletions
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff
index 6cf0fdf4159..8fd2b30752b 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff
@@ -1,18 +1,18 @@
---- check_ibd_filesize.result
-+++ check_ibd_filesize.result,32k
+--- ./check_ibd_filesize.result 2022-08-01 12:15:25.079517400 +0530
++++ check_ibd_filesize.reject 2022-08-01 12:15:39.987918265 +0530
@@ -3,18 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 196608
+-# bytes: 65536
++# bytes: 131072
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
-# bytes: 9437184
+# bytes: 786432
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 196608
+-# bytes: 65536
++# bytes: 131072
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
-# bytes: 4194304
-DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
index 52cd6832755..1f89b318382 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
@@ -1,17 +1,17 @@
---- check_ibd_filesize.result
-+++ check_ibd_filesize.result,4k
+--- ./check_ibd_filesize.result 2022-08-01 12:15:25.079517400 +0530
++++ check_ibd_filesize.reject 2022-08-01 12:16:38.865497299 +0530
@@ -3,18 +3,18 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 24576
+-# bytes: 65536
++# bytes: 16384
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 24576
+-# bytes: 65536
++# bytes: 16384
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff
index 23d9fbe608f..f0e458e8c8d 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff
@@ -1,18 +1,18 @@
---- check_ibd_filesize.result
-+++ check_ibd_filesize.result,64k
+--- ./check_ibd_filesize.result 2022-08-01 12:15:25.079517400 +0530
++++ check_ibd_filesize.reject 2022-08-01 12:16:24.409110166 +0530
@@ -3,18 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 393216
+-# bytes: 65536
++# bytes: 262144
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
-# bytes: 9437184
+# bytes: 983040
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 393216
+-# bytes: 65536
++# bytes: 262144
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
-# bytes: 4194304
-DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff
index 17936a3def9..59655ea8db3 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff
@@ -1,17 +1,17 @@
---- check_ibd_filesize.result
-+++ check_ibd_filesize.result,8k
+--- ./check_ibd_filesize.result 2022-08-01 12:15:25.079517400 +0530
++++ check_ibd_filesize.reject 2022-08-01 12:16:48.649759120 +0530
@@ -3,18 +3,18 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 49152
+-# bytes: 65536
++# bytes: 32768
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
--# bytes: 98304
-+# bytes: 49152
+-# bytes: 65536
++# bytes: 32768
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/r/check_ibd_filesize.result b/mysql-test/suite/innodb/r/check_ibd_filesize.result
index a6f5fbd9387..0d224d6ac5f 100644
--- a/mysql-test/suite/innodb/r/check_ibd_filesize.result
+++ b/mysql-test/suite/innodb/r/check_ibd_filesize.result
@@ -3,12 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 65536
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 65536
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/temporary_table.test b/mysql-test/suite/innodb/t/temporary_table.test
index 594ab95ef58..e59f51623b7 100644
--- a/mysql-test/suite/innodb/t/temporary_table.test
+++ b/mysql-test/suite/innodb/t/temporary_table.test
@@ -5,6 +5,7 @@
#
--source include/have_innodb.inc
+--source include/innodb_page_size.inc
# Embedded server does not restart of server
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc
diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 54a43b920bb..028ecfa87e5 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1664,6 +1664,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
fseg_inode_t* inode;
ib_id_t seg_id;
uint32_t n_reserved;
+ bool reserved_extent = false;
DBUG_ENTER("fseg_create");
@@ -1677,14 +1678,6 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
ut_ad(!block || block->page.id().space() == space->id);
- if (!has_done_reservation) {
- *err = fsp_reserve_free_extents(&n_reserved, space, 2,
- FSP_NORMAL, mtr);
- if (UNIV_UNLIKELY(*err != DB_SUCCESS)) {
- DBUG_RETURN(nullptr);
- }
- }
-
buf_block_t* header = fsp_get_header(space, mtr, err);
if (!header) {
block = nullptr;
@@ -1692,11 +1685,35 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
}
buf_block_t* iblock;
-
+inode_alloc:
inode = fsp_alloc_seg_inode(space, header, &iblock, mtr, err);
if (inode == NULL) {
+reserve_extent:
+ if (!has_done_reservation && !reserved_extent) {
+ *err = fsp_reserve_free_extents(
+ &n_reserved, space, 2,
+ FSP_NORMAL, mtr);
+ if (UNIV_UNLIKELY(*err != DB_SUCCESS)) {
+ ut_ad(0);
+ DBUG_RETURN(nullptr);
+ }
+
+ /* Extents reserved successfully. So
+ try allocating the page or inode */
+ reserved_extent = true;
+ if (inode) {
+ goto page_alloc;
+ }
+
+ goto inode_alloc;
+ }
+
block = nullptr;
+ if (inode) {
+ fsp_free_seg_inode(space, inode, iblock, mtr);
+ }
+
goto funct_exit;
}
@@ -1724,6 +1741,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
FSEG_FRAG_SLOT_SIZE * FSEG_FRAG_ARR_N_SLOTS, 0xff);
if (!block) {
+page_alloc:
block = fseg_alloc_free_page_low(space,
inode, iblock, 0, FSP_UP,
#ifdef UNIV_DEBUG
@@ -1736,8 +1754,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
ut_ad(!has_done_reservation || block != NULL);
if (!block) {
- fsp_free_seg_inode(space, inode, iblock, mtr);
- goto funct_exit;
+ goto reserve_extent;
}
ut_d(const auto x = block->page.lock.x_lock_count());
@@ -1759,7 +1776,7 @@ fseg_create(fil_space_t *space, ulint byte_offset, mtr_t *mtr, dberr_t *err,
+ block->page.frame, space->id);
funct_exit:
- if (!has_done_reservation) {
+ if (!has_done_reservation && reserved_extent) {
space->release_free_extents(n_reserved);
}