mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
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.
This commit is contained in:
parent
c208006080
commit
32167225c7
8 changed files with 66 additions and 49 deletions
|
@ -1,18 +1,18 @@
|
|||
--- check_ibd_filesize.result
|
||||
+++ check_ibd_filesize.result,32k
|
||||
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
|
||||
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:29:25.129637040 +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;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--- check_ibd_filesize.result
|
||||
+++ check_ibd_filesize.result,4k
|
||||
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
|
||||
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:39.288769153 +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;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
--- check_ibd_filesize.result
|
||||
+++ check_ibd_filesize.result,64k
|
||||
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
|
||||
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:30:28.957174270 +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;
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
--- check_ibd_filesize.result
|
||||
+++ check_ibd_filesize.result,8k
|
||||
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
|
||||
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:03.516962339 +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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -30,13 +30,13 @@ FOUND 1 /Database page corruption detected.*/ in backup.log
|
|||
FOUND 1 /completed OK!/ in backup.log
|
||||
--- "innodb_corrupted_pages" file content: ---
|
||||
test/t1_corrupted
|
||||
6 8 9
|
||||
4 6 7
|
||||
test/t2_corrupted
|
||||
7 8 10
|
||||
5 6 8
|
||||
test/t4_corrupted_new
|
||||
1
|
||||
test/t5_corrupted_to_rename_renamed
|
||||
6
|
||||
4
|
||||
test/t7_corrupted_to_alter
|
||||
3
|
||||
------
|
||||
|
@ -46,19 +46,19 @@ INSERT INTO t3_inc VALUES (3), (4), (5), (6), (7), (8), (9);
|
|||
# Backup must not fail, but "innodb_corrupted_pages" file must be created due to --log-innodb-page-corruption option
|
||||
--- "innodb_corrupted_pages" file content: ---
|
||||
test/t1_corrupted
|
||||
6 8 9
|
||||
4 6 7
|
||||
test/t1_inc_corrupted
|
||||
6 8 9
|
||||
4 6 7
|
||||
test/t2_corrupted
|
||||
7 8 10
|
||||
5 6 8
|
||||
test/t2_inc_corrupted
|
||||
7 8 10
|
||||
5 6 8
|
||||
test/t4_inc_corrupted_new
|
||||
1
|
||||
test/t5_corrupted_to_rename_renamed
|
||||
6
|
||||
4
|
||||
test/t5_inc_corrupted_to_rename_renamed
|
||||
6
|
||||
4
|
||||
test/t7_inc_corrupted_to_alter
|
||||
3
|
||||
------
|
||||
|
@ -82,15 +82,15 @@ DROP TABLE t7_inc_corrupted_to_alter;
|
|||
# Full backup with --log-innodb-page-corruption
|
||||
--- "innodb_corrupted_pages" file content: ---
|
||||
test/t3
|
||||
6 8
|
||||
4 6
|
||||
------
|
||||
# Extend some tablespace and corrupt extended pages for incremental backup
|
||||
# Incremental backup --log-innodb-page-corruption
|
||||
--- "innodb_corrupted_pages" file content: ---
|
||||
test/t3
|
||||
6 8
|
||||
4 6
|
||||
test/t3_inc
|
||||
6 8
|
||||
4 6
|
||||
------
|
||||
# Full backup prepare
|
||||
# "innodb_corrupted_pages" file must not exist after successful prepare
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue