Skip to content

Commit d5bd704

Browse files
committed
Merge 10.3 into 10.4
2 parents 9c2d923 + 4bfdba2 commit d5bd704

File tree

7 files changed

+34
-37
lines changed

7 files changed

+34
-37
lines changed

mysql-test/suite/innodb/r/undo_truncate.result

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
SET @save_undo_logs = @@GLOBAL.innodb_undo_logs;
2-
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
3-
SET @save_truncate = @@GLOBAL.innodb_undo_log_truncate;
41
SET GLOBAL innodb_undo_log_truncate = 0;
5-
SET GLOBAL innodb_undo_logs = 4;
62
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
7-
SET @trunc_start=
8-
(SELECT variable_value FROM information_schema.global_status
9-
WHERE variable_name = 'innodb_undo_truncations');
103
create table t1(keyc int primary key, c char(100)) engine = innodb;
114
create table t2(keyc int primary key, c char(100)) engine = innodb;
125
connect con1,localhost,root,,;
@@ -35,8 +28,6 @@ connection con2;
3528
commit;
3629
disconnect con2;
3730
connection default;
31+
set global innodb_fast_shutdown=0;
32+
# restart
3833
drop table t1, t2;
39-
InnoDB 0 transactions not purged
40-
SET GLOBAL innodb_undo_logs = @save_undo_logs;
41-
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
42-
SET GLOBAL innodb_undo_log_truncate = @save_truncate;

mysql-test/suite/innodb/t/undo_truncate.test

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
--source include/have_innodb.inc
22
--source include/innodb_page_size.inc
33
--source include/have_undo_tablespaces.inc
4+
--source include/not_embedded.inc
45
--source include/have_sequence.inc
56

6-
SET @save_undo_logs = @@GLOBAL.innodb_undo_logs;
7-
SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency;
8-
SET @save_truncate = @@GLOBAL.innodb_undo_log_truncate;
97
SET GLOBAL innodb_undo_log_truncate = 0;
10-
SET GLOBAL innodb_undo_logs = 4;
118
SET GLOBAL innodb_purge_rseg_truncate_frequency = 1;
129

13-
SET @trunc_start=
14-
(SELECT variable_value FROM information_schema.global_status
15-
WHERE variable_name = 'innodb_undo_truncations');
16-
1710
#-----------------------------------------------------------------------------
1811
#
1912
# Perform DML action using multiple clients and multiple undo tablespace.
@@ -44,21 +37,20 @@ commit; disconnect con1;
4437
connection con2; commit; disconnect con2;
4538

4639
connection default;
47-
drop table t1, t2;
4840

49-
--source include/wait_all_purged.inc
41+
--replace_regex /.*Trx id counter ([0-9]+).*/\1/
42+
let $trx_before= `SHOW ENGINE INNODB STATUS`;
43+
let $trx_before= `select substr('$trx_before',9)+2`;
44+
45+
set global innodb_fast_shutdown=0;
46+
--source include/restart_mysqld.inc
47+
--replace_regex /.*Trx id counter ([0-9]+).*/\1/
48+
let $trx_after= `SHOW ENGINE INNODB STATUS`;
49+
let $trx_after= `select substr('$trx_after',9)`;
5050

51-
# Truncation will normally not occur with innodb_page_size=64k,
52-
# and occasionally not with innodb_page_size=32k,
53-
# because the undo log will not grow enough.
54-
if (`select @@innodb_page_size IN (4096,8192,16384)`)
51+
drop table t1, t2;
52+
53+
if ($trx_before != $trx_after)
5554
{
56-
let $wait_condition = (SELECT variable_value!=@trunc_start
57-
FROM information_schema.global_status
58-
WHERE variable_name = 'innodb_undo_truncations');
59-
source include/wait_condition.inc;
55+
echo Transaction sequence mismatch: $trx_before != $trx_after;
6056
}
61-
62-
SET GLOBAL innodb_undo_logs = @save_undo_logs;
63-
SET GLOBAL innodb_purge_rseg_truncate_frequency = @save_frequency;
64-
SET GLOBAL innodb_undo_log_truncate = @save_truncate;

storage/innobase/include/trx0rseg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ trx_rsegf_undo_find_free(const trx_rsegf_t* rsegf);
7171
/** Create a rollback segment header.
7272
@param[in,out] space system, undo, or temporary tablespace
7373
@param[in] rseg_id rollback segment identifier
74+
@param[in] max_trx_id new value of TRX_RSEG_MAX_TRX_ID
7475
@param[in,out] sys_header the TRX_SYS page (NULL for temporary rseg)
7576
@param[in,out] mtr mini-transaction
7677
@return the created rollback segment
@@ -79,6 +80,7 @@ buf_block_t*
7980
trx_rseg_header_create(
8081
fil_space_t* space,
8182
ulint rseg_id,
83+
trx_id_t max_trx_id,
8284
buf_block_t* sys_header,
8385
mtr_t* mtr);
8486

storage/innobase/srv/srv0srv.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,6 +2614,8 @@ static uint32_t srv_do_purge(ulint* n_total_purged
26142614
n_use_threads,
26152615
!(++count % srv_purge_rseg_truncate_frequency)
26162616
|| purge_sys.truncate.current
2617+
|| (srv_shutdown_state != SRV_SHUTDOWN_NONE
2618+
&& srv_fast_shutdown == 0)
26172619
#ifdef UNIV_DEBUG
26182620
, slot
26192621
#endif

storage/innobase/trx/trx0purge.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ static void trx_purge_truncate_history()
715715

716716
buf_block_t* rblock = trx_rseg_header_create(
717717
purge_sys.truncate.current,
718-
rseg->id, sys_header, &mtr);
718+
rseg->id, trx_sys.get_max_trx_id(),
719+
sys_header, &mtr);
719720
ut_ad(rblock);
720721
rseg->page_no = rblock
721722
? rblock->page.id.page_no() : FIL_NULL;

storage/innobase/trx/trx0rseg.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ void trx_rseg_format_upgrade(trx_rsegf_t* rseg_header, mtr_t* mtr)
295295
/** Create a rollback segment header.
296296
@param[in,out] space system, undo, or temporary tablespace
297297
@param[in] rseg_id rollback segment identifier
298+
@param[in] max_trx_id new value of TRX_RSEG_MAX_TRX_ID
298299
@param[in,out] sys_header the TRX_SYS page (NULL for temporary rseg)
299300
@param[in,out] mtr mini-transaction
300301
@return the created rollback segment
@@ -303,6 +304,7 @@ buf_block_t*
303304
trx_rseg_header_create(
304305
fil_space_t* space,
305306
ulint rseg_id,
307+
trx_id_t max_trx_id,
306308
buf_block_t* sys_header,
307309
mtr_t* mtr)
308310
{
@@ -325,8 +327,15 @@ trx_rseg_header_create(
325327
+ block->frame));
326328
ut_ad(0 == mach_read_from_4(TRX_RSEG_HISTORY_SIZE + TRX_RSEG
327329
+ block->frame));
330+
ut_ad(0 == mach_read_from_4(TRX_RSEG_MAX_TRX_ID + TRX_RSEG
331+
+ block->frame));
328332

329333
/* Initialize the history list */
334+
if (max_trx_id) {
335+
mlog_write_ull(TRX_RSEG + TRX_RSEG_MAX_TRX_ID + block->frame,
336+
max_trx_id, mtr);
337+
}
338+
330339
flst_init(block, TRX_RSEG_HISTORY + TRX_RSEG, mtr);
331340

332341
/* Reset the undo log slots */
@@ -685,7 +694,7 @@ trx_rseg_create(ulint space_id)
685694
ulint rseg_id = trx_sys_rseg_find_free(sys_header);
686695
if (buf_block_t* rblock = rseg_id == ULINT_UNDEFINED
687696
? NULL
688-
: trx_rseg_header_create(space, rseg_id, sys_header,
697+
: trx_rseg_header_create(space, rseg_id, 0, sys_header,
689698
&mtr)) {
690699
ut_ad(trx_sysf_rseg_get_space(sys_header, rseg_id)
691700
== space_id);
@@ -715,7 +724,7 @@ trx_temp_rseg_create()
715724
mtr_x_lock_space(fil_system.temp_space, &mtr);
716725

717726
buf_block_t* rblock = trx_rseg_header_create(
718-
fil_system.temp_space, i, NULL, &mtr);
727+
fil_system.temp_space, i, 0, NULL, &mtr);
719728
trx_rseg_t* rseg = trx_rseg_mem_create(
720729
i, fil_system.temp_space, rblock->page.id.page_no());
721730
ut_ad(!rseg->is_persistent());

storage/innobase/trx/trx0sys.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ trx_sysf_create(
196196
/* Create the first rollback segment in the SYSTEM tablespace */
197197
slot_no = trx_sys_rseg_find_free(block);
198198
buf_block_t* rblock = trx_rseg_header_create(fil_system.sys_space,
199-
slot_no, block, mtr);
199+
slot_no, 0, block, mtr);
200200

201201
ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
202202
ut_a(rblock->page.id.page_no() == FSP_FIRST_RSEG_PAGE_NO);

0 commit comments

Comments
 (0)