diff options
author | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2022-07-28 19:05:17 +0530 |
---|---|---|
committer | Thirunarayanan Balathandayuthapani <thiru@mariadb.com> | 2022-07-29 20:44:45 +0530 |
commit | ca7c21d10b2a20b631fedee2efaafcfcdc308e6d (patch) | |
tree | 81addc63637c8cfb16a0ed96bcca8ec9e62c0777 | |
parent | f9315b33217c5c126995a6c1d2c286d480091776 (diff) | |
download | mariadb-git-bb-10.3-MDEV-13013.tar.gz |
MDEV-13013 InnoDB unnecessarily extends data filesbb-10.3-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.rdiff | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff | 12 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/check_ibd_filesize.result | 4 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/temporary_table.test | 1 | ||||
-rw-r--r-- | storage/innobase/fsp/fsp0fsp.cc | 35 |
7 files changed, 51 insertions, 37 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..aa651d7aa7f 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-07-29 20:18:52.192557118 +0530 ++++ check_ibd_filesize.reject 2022-07-29 20:23:52.924906040 +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..b91186e8694 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-07-29 20:18:52.192557118 +0530 ++++ check_ibd_filesize.reject 2022-07-29 20:21:41.219069676 +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..4f183fefd9e 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-07-29 20:18:52.192557118 +0530 ++++ check_ibd_filesize.reject 2022-07-29 20:24:08.300589857 +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..976058552fd 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-07-29 20:18:52.192557118 +0530 ++++ check_ibd_filesize.reject 2022-07-29 20:23:18.631768442 +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 5f64eb7d22b..cc290b03c34 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 ab143a16417..2771ea3e3af 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,31 @@ 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)) { + /* 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 +1959,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 +1973,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 +1993,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); } |