mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-14795 InnoDB system tablespace cannot be shrunk
- Introduce the option :autoshrink attribute to be added to innodb_data_file_path variable to allow the shrinking of system tablespace during startup process. Steps for shrinking the system tablespace: 1) Find the last used extent in system tablespace by iterating through the BITMAP in extent descriptor pages 2) If the last used extent is lesser than user specified size then set desired target size to user specified size. 3) Store the page contents of "to be modified" extent descriptor pages, latches the "to be modified" extent descriptor pages and check for buffer pool memory availability 4) Make checkpoint to flush all pages in buffer pool, so that pages in flush list doesn't have to use doublewrite buffer and disable doublewrite buffer during shrinking process 5) Update the FSP_SIZE and FSP_FREE_LIMIT in header page 6) Remove the "to be truncated" pages from FSP_FREE and FSP_FREE_FRAG list 7) Reset the bitmap in the last descriptor pages for the "to be truncated" pages. 8) In case of multiple files, calculate the truncated last file size and do the truncation in last file 9) Check whether mini-transaction log size doesn't exceed the minimum value of innodb_log_buffer_size which is 2MB. In that case, replace the modified buffer pool pages with the page old content. 11) Commit the mini-transaction for shrinking the tablespace and enable/disable the doublewrite buffer depends on user specified value. recv_sys_t::apply(): Handle the truncation of system tablespace only if the recovered tablespace size is lesser than actual existing size.
This commit is contained in:
62
mysql-test/suite/innodb/t/sys_truncate_debug.test
Normal file
62
mysql-test/suite/innodb/t/sys_truncate_debug.test
Normal file
@@ -0,0 +1,62 @@
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_sequence.inc
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/not_windows.inc
|
||||
|
||||
call mtr.add_suppression("InnoDB: Cannot shrink the system tablespace");
|
||||
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
|
||||
call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
|
||||
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
|
||||
|
||||
SET GLOBAL INNODB_LIMIT_OPTIMISTIC_INSERT_DEBUG=2;
|
||||
SET GLOBAL INNODB_FILE_PER_TABLE= 0;
|
||||
SET UNIQUE_CHECKS=0, FOREIGN_KEY_CHECKS=0;
|
||||
CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL,
|
||||
f3 INT NOT NULL, INDEX(f1),
|
||||
INDEX(f2), INDEX(f3))ENGINE=InnoDB;
|
||||
BEGIN;
|
||||
INSERT INTO t1 SELECT seq, seq, seq FROM seq_1_to_16384;
|
||||
INSERT INTO t1 SELECT seq, seq, seq FROM seq_1_to_16384;
|
||||
COMMIT;
|
||||
DROP TABLE t1;
|
||||
--source include/wait_all_purged.inc
|
||||
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE = 0;
|
||||
|
||||
# Ran out of buffer pool
|
||||
let $restart_parameters=--debug_dbug="+d,sys_shrink_buffer_pool_full";
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--let SEARCH_PATTERN= \[Warning\] InnoDB: Cannot shrink the system tablespace
|
||||
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
|
||||
--source include/search_pattern_in_file.inc
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.ENGINES
|
||||
WHERE engine = 'innodb'
|
||||
AND support IN ('YES', 'DEFAULT', 'ENABLED');
|
||||
|
||||
# Ran out of mtr log size
|
||||
let $restart_parameters=--debug_dbug="+d,mtr_log_max_size";
|
||||
--source include/restart_mysqld.inc
|
||||
|
||||
--let SEARCH_PATTERN= \[ERROR\] InnoDB: Cannot shrink the system tablespace
|
||||
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
|
||||
--source include/search_pattern_in_file.inc
|
||||
|
||||
SELECT * FROM INFORMATION_SCHEMA.ENGINES
|
||||
WHERE engine = 'innodb'
|
||||
AND support IN ('YES', 'DEFAULT', 'ENABLED');
|
||||
|
||||
# Crash after shrinking the system tablespace
|
||||
let $restart_parameters=--debug_dbug="+d,crash_after_sys_truncate";
|
||||
--source include/restart_mysqld.inc
|
||||
SELECT * FROM INFORMATION_SCHEMA.ENGINES
|
||||
WHERE engine = 'innodb'
|
||||
AND support IN ('YES', 'DEFAULT', 'ENABLED');
|
||||
|
||||
let $restart_parameters=--innodb_buffer_pool_size=5M;
|
||||
--source include/restart_mysqld.inc
|
||||
SELECT * FROM INFORMATION_SCHEMA.ENGINES
|
||||
WHERE engine = 'innodb'
|
||||
AND support IN ('YES', 'DEFAULT', 'ENABLED');
|
||||
SELECT NAME, FILE_SIZE FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESPACES WHERE SPACE=0;
|
Reference in New Issue
Block a user