mariadb/mysql-test/suite/innodb/t/sys_truncate_large.test
Thirunarayanan Balathandayuthapani f9003c73a1 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.
2023-08-01 19:43:04 +05:30

31 lines
893 B
Text

--source include/big_test.inc
--source include/have_innodb.inc
--source include/have_sequence.inc
--source include/not_valgrind.inc
--source include/have_debug.inc
set global innodb_file_per_table=0;
set global innodb_limit_optimistic_insert_debug=2;
set unique_checks=0, foreign_key_checks=0;
create table t1(f1 int not null)engine=innodb;
begin;
insert into t1 select * from seq_1_to_8192;
insert into t1 select * from seq_1_to_8192;
insert into t1 select * from seq_1_to_65536;
commit;
create table t2(f1 int not null)engine=innodb;
insert into t2 select * from seq_1_to_65536;
create table t3(f1 int not null)engine=innodb;
insert into t3 select * from seq_1_to_65536;
CREATE TABLE t4(f1 int not null)engine=innodb;
insert into t4 select * from seq_1_to_65536;
drop table t2;
drop table t4;
--source include/wait_all_purged.inc
--source include/restart_mysqld.inc
drop table t3, t1;