Skip to content

Commit d04de1a

Browse files
committed
Merge 10.6 into 10.9
2 parents 8e2b20b + 3e89b4f commit d04de1a

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
22
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
3-
CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB;
3+
CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000))
4+
ENGINE=InnoDB STATS_PERSISTENT=0;
45
INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023;
56
connect con1,localhost,root,,;
67
InnoDB 0 transactions not purged
78
START TRANSACTION WITH CONSISTENT SNAPSHOT;
89
connection default;
910
DELETE FROM t1 WHERE id=1788;
11+
SET @saved_dbug = @@GLOBAL.debug_dbug;
12+
SET @@GLOBAL.debug_dbug="d,enable_row_purge_del_mark_exit_sync_point";
1013
BEGIN;
1114
SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
1215
id val
1316
connection con1;
1417
COMMIT;
15-
InnoDB 0 transactions not purged
18+
SET DEBUG_SYNC = 'now WAIT_FOR row_purge_del_mark_finished';
19+
SET @@GLOBAL.debug_dbug = @saved_dbug;
1620
connection default;
1721
INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000));
1822
connection con1;

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
--source include/have_innodb.inc
22
--source include/have_sequence.inc
33
--source include/have_debug.inc
4+
--source include/have_debug_sync.inc
45

56
SET @save_frequency=@@GLOBAL.innodb_purge_rseg_truncate_frequency;
67
SET GLOBAL innodb_purge_rseg_truncate_frequency=1;
78

8-
CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000)) ENGINE=InnoDB;
9+
CREATE TABLE t1(id INT PRIMARY key, val VARCHAR(16000))
10+
ENGINE=InnoDB STATS_PERSISTENT=0;
911
INSERT INTO t1 (id,val) SELECT 2*seq,'x' FROM seq_0_to_1023;
1012

1113
connect(con1,localhost,root,,);
@@ -16,13 +18,18 @@ connection default;
1618

1719
DELETE FROM t1 WHERE id=1788;
1820

21+
SET @saved_dbug = @@GLOBAL.debug_dbug;
22+
SET @@GLOBAL.debug_dbug="d,enable_row_purge_del_mark_exit_sync_point";
23+
1924
BEGIN;
2025
# This will return no result, but should acquire a gap lock.
2126
SELECT * FROM t1 WHERE id=1788 FOR UPDATE;
2227

2328
connection con1;
2429
COMMIT;
25-
source include/wait_all_purged.inc;
30+
SET DEBUG_SYNC = 'now WAIT_FOR row_purge_del_mark_finished';
31+
SET @@GLOBAL.debug_dbug = @saved_dbug;
32+
2633
connection default;
2734

2835
INSERT INTO t1 (id,val) VALUES (1787, REPEAT('x',2000));

storage/innobase/btr/btr0cur.cc

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,8 +4991,6 @@ class btr_est_cur_t
49914991
page_id_t m_page_id;
49924992
/** Current block */
49934993
buf_block_t *m_block;
4994-
/** mtr savepoint of the current block */
4995-
ulint m_savepoint;
49964994
/** Page search mode, can differ from m_mode for non-leaf pages, see c-tor
49974995
comments for details */
49984996
page_cur_mode_t m_page_mode;
@@ -5051,17 +5049,17 @@ class btr_est_cur_t
50515049
bool fetch_child(ulint level, mtr_t &mtr, const buf_block_t *right_parent)
50525050
{
50535051
buf_block_t *parent_block= m_block;
5054-
ulint parent_savepoint= m_savepoint;
50555052

50565053
m_block= btr_block_get(*index(), m_page_id.page_no(), RW_S_LATCH, !level,
50575054
&mtr, nullptr);
50585055
if (!m_block)
50595056
return false;
50605057

50615058
if (parent_block && parent_block != right_parent)
5062-
mtr.rollback_to_savepoint(parent_savepoint, parent_savepoint + 1);
5063-
5064-
m_savepoint= mtr.get_savepoint() - 1;
5059+
{
5060+
ut_ad(mtr.get_savepoint() >= 2);
5061+
mtr.rollback_to_savepoint(1, 2);
5062+
}
50655063

50665064
return level == ULINT_UNDEFINED ||
50675065
btr_page_get_level(m_block->page.frame) == level;
@@ -5123,10 +5121,10 @@ class btr_est_cur_t
51235121
return true;
51245122
}
51255123

5126-
/** Gets page id of the current record child.
5124+
/** Read page id of the current record child.
51275125
@param offsets offsets array.
51285126
@param heap heap for offsets array */
5129-
void get_child(rec_offs **offsets, mem_heap_t **heap)
5127+
void read_child_page_id(rec_offs **offsets, mem_heap_t **heap)
51305128
{
51315129
const rec_t *node_ptr= page_cur_get_rec(&m_page_cur);
51325130

@@ -5196,11 +5194,7 @@ class btr_est_cur_t
51965194
/** Copies block pointer and savepoint from another btr_est_cur_t in the case
51975195
if both left and right border cursors point to the same block.
51985196
@param o reference to the other btr_est_cur_t object. */
5199-
void set_block(const btr_est_cur_t &o)
5200-
{
5201-
m_block= o.m_block;
5202-
m_savepoint= o.m_savepoint;
5203-
}
5197+
void set_block(const btr_est_cur_t &o) { m_block= o.m_block; }
52045198

52055199
/** @return current record number. */
52065200
ulint nth_rec() const { return m_nth_rec; }
@@ -5239,7 +5233,6 @@ static ha_rows btr_estimate_n_rows_in_range_on_level(
52395233
pages before reaching right_page_no, then we estimate the average from the
52405234
pages scanned so far. */
52415235
static constexpr uint n_pages_read_limit= 9;
5242-
ulint savepoint= 0;
52435236
buf_block_t *block= nullptr;
52445237
const dict_index_t *index= left_cur.index();
52455238

@@ -5269,19 +5262,18 @@ static ha_rows btr_estimate_n_rows_in_range_on_level(
52695262
{
52705263
page_t *page;
52715264
buf_block_t *prev_block= block;
5272-
ulint prev_savepoint= savepoint;
5273-
5274-
savepoint= mtr.get_savepoint();
52755265

52765266
/* Fetch the page. */
52775267
block= btr_block_get(*index, page_id.page_no(), RW_S_LATCH, !level, &mtr,
52785268
nullptr);
52795269

52805270
if (prev_block)
52815271
{
5282-
mtr.rollback_to_savepoint(prev_savepoint, prev_savepoint + 1);
5283-
if (block)
5284-
savepoint--;
5272+
ulint savepoint = mtr.get_savepoint();
5273+
/* Index s-lock, p1, p2 latches, can also be p1 and p2 parent latch if
5274+
they are not diverged */
5275+
ut_ad(savepoint >= 3);
5276+
mtr.rollback_to_savepoint(savepoint - 2, savepoint - 1);
52855277
}
52865278

52875279
if (!block || btr_page_get_level(buf_block_get_frame(block)) != level)
@@ -5312,8 +5304,8 @@ static ha_rows btr_estimate_n_rows_in_range_on_level(
53125304

53135305
if (block)
53145306
{
5315-
ut_ad(block == mtr.at_savepoint(savepoint));
5316-
mtr.rollback_to_savepoint(savepoint, savepoint + 1);
5307+
ut_ad(block == mtr.at_savepoint(mtr.get_savepoint() - 1));
5308+
mtr.rollback_to_savepoint(mtr.get_savepoint() - 1);
53175309
}
53185310

53195311
return (n_rows);
@@ -5322,8 +5314,8 @@ static ha_rows btr_estimate_n_rows_in_range_on_level(
53225314

53235315
if (block)
53245316
{
5325-
ut_ad(block == mtr.at_savepoint(savepoint));
5326-
mtr.rollback_to_savepoint(savepoint, savepoint + 1);
5317+
ut_ad(block == mtr.at_savepoint(mtr.get_savepoint() - 1));
5318+
mtr.rollback_to_savepoint(mtr.get_savepoint() - 1);
53275319
}
53285320

53295321
is_n_rows_exact= false;
@@ -5517,8 +5509,12 @@ ha_rows btr_estimate_n_rows_in_range(dict_index_t *index,
55175509
{
55185510
ut_ad(height > 0);
55195511
height--;
5520-
p1.get_child(&offsets, &heap);
5521-
p2.get_child(&offsets, &heap);
5512+
ut_ad(mtr.memo_contains(p1.index()->lock, MTR_MEMO_S_LOCK));
5513+
ut_ad(mtr.memo_contains_flagged(p1.block(), MTR_MEMO_PAGE_S_FIX));
5514+
p1.read_child_page_id(&offsets, &heap);
5515+
ut_ad(mtr.memo_contains(p2.index()->lock, MTR_MEMO_S_LOCK));
5516+
ut_ad(mtr.memo_contains_flagged(p2.block(), MTR_MEMO_PAGE_S_FIX));
5517+
p2.read_child_page_id(&offsets, &heap);
55225518
goto search_loop;
55235519
}
55245520

0 commit comments

Comments
 (0)