Skip to content

Commit 028d253

Browse files
committed
MDEV-13980 InnoDB fails to discard record lock when discarding an index page
btr_cur_pessimistic_delete(): Discard a possible record lock also in the case when the record was the only one in the page. Failure to do this would corrupt the record lock data structures in a partial rollback (ROLLBACK TO SAVEPOINT or rolling back a row operation due to some error, such as a duplicate key in a unique secondary index).
1 parent a47d169 commit 028d253

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

storage/innobase/btr/btr0cur.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2008, Google Inc.
5+
Copyright (c) 2017, MariaDB Corporation.
56
67
Portions of this file contain modifications contributed and copyrighted by
78
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -3193,7 +3194,6 @@ btr_cur_pessimistic_delete(
31933194
ulint n_reserved;
31943195
ibool success;
31953196
ibool ret = FALSE;
3196-
ulint level;
31973197
mem_heap_t* heap;
31983198
ulint* offsets;
31993199

@@ -3240,6 +3240,8 @@ btr_cur_pessimistic_delete(
32403240
#endif /* UNIV_ZIP_DEBUG */
32413241
}
32423242

3243+
lock_update_delete(block, rec);
3244+
32433245
if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
32443246
&& UNIV_UNLIKELY(dict_index_get_page(index)
32453247
!= buf_block_get_page_no(block))) {
@@ -3255,10 +3257,7 @@ btr_cur_pessimistic_delete(
32553257
goto return_after_reservations;
32563258
}
32573259

3258-
lock_update_delete(block, rec);
3259-
level = btr_page_get_level(page, mtr);
3260-
3261-
if (level > 0
3260+
if (!page_is_leaf(page)
32623261
&& UNIV_UNLIKELY(rec == page_rec_get_next(
32633262
page_get_infimum_rec(page)))) {
32643263

@@ -3281,6 +3280,7 @@ btr_cur_pessimistic_delete(
32813280
on a page, we have to change the father node pointer
32823281
so that it is equal to the new leftmost node pointer
32833282
on the page */
3283+
ulint level = btr_page_get_level(page, mtr);
32843284

32853285
btr_node_ptr_delete(index, block, mtr);
32863286

storage/xtradb/btr/btr0cur.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2008, Google Inc.
5+
Copyright (c) 2017, MariaDB Corporation.
56
67
Portions of this file contain modifications contributed and copyrighted by
78
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -3376,7 +3377,6 @@ btr_cur_pessimistic_delete(
33763377
ulint n_reserved;
33773378
ibool success;
33783379
ibool ret = FALSE;
3379-
ulint level;
33803380
mem_heap_t* heap;
33813381
ulint* offsets;
33823382

@@ -3425,6 +3425,8 @@ btr_cur_pessimistic_delete(
34253425
#endif /* UNIV_ZIP_DEBUG */
34263426
}
34273427

3428+
lock_update_delete(block, rec);
3429+
34283430
if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
34293431
&& UNIV_UNLIKELY(dict_index_get_page(index)
34303432
!= buf_block_get_page_no(block))) {
@@ -3440,10 +3442,7 @@ btr_cur_pessimistic_delete(
34403442
goto return_after_reservations;
34413443
}
34423444

3443-
lock_update_delete(block, rec);
3444-
level = btr_page_get_level(page, mtr);
3445-
3446-
if (level > 0
3445+
if (!page_is_leaf(page)
34473446
&& UNIV_UNLIKELY(rec == page_rec_get_next(
34483447
page_get_infimum_rec(page)))) {
34493448

@@ -3466,6 +3465,7 @@ btr_cur_pessimistic_delete(
34663465
on a page, we have to change the father node pointer
34673466
so that it is equal to the new leftmost node pointer
34683467
on the page */
3468+
ulint level = btr_page_get_level(page, mtr);
34693469

34703470
btr_node_ptr_delete(index, block, mtr);
34713471

0 commit comments

Comments
 (0)