Skip to content

Commit 792972a

Browse files
committed
MDEV-27234 fixup with MDEV-27557
Whenever we retrieve an older version for READ COMMITTED, it is better to release the undo page latches so that we can freely move to the next clustered index record without potentially violating any latching order.
1 parent b242c31 commit 792972a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

storage/innobase/dict/dict0load.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ dict_sys_tables_rec_read(
668668
ut_ad(len == 6 || len == UNIV_SQL_NULL);
669669
trx_id_t id = len == 6 ? trx_read_trx_id(field) : 0;
670670
if (id && trx_sys.find(nullptr, id, false)) {
671+
const auto savepoint = mtr->get_savepoint();
671672
heap = mem_heap_create(1024);
672673
dict_index_t* index = UT_LIST_GET_FIRST(
673674
dict_sys.sys_tables->indexes);
@@ -677,6 +678,7 @@ dict_sys_tables_rec_read(
677678
row_vers_build_for_semi_consistent_read(
678679
nullptr, rec, mtr, index, &offsets, &heap,
679680
heap, &old_vers, nullptr);
681+
mtr->rollback_to_savepoint(savepoint);
680682
rec = old_vers;
681683
if (!rec) {
682684
mem_heap_free(heap);
@@ -1074,6 +1076,7 @@ dict_load_column_low(
10741076
const trx_id_t trx_id = trx_read_trx_id(field);
10751077

10761078
if (trx_id && mtr && trx_sys.find(nullptr, trx_id, false)) {
1079+
const auto savepoint = mtr->get_savepoint();
10771080
dict_index_t* index = UT_LIST_GET_FIRST(
10781081
dict_sys.sys_columns->indexes);
10791082
rec_offs* offsets = rec_get_offsets(
@@ -1082,6 +1085,7 @@ dict_load_column_low(
10821085
row_vers_build_for_semi_consistent_read(
10831086
nullptr, rec, mtr, index, &offsets, &heap,
10841087
heap, &old_vers, nullptr);
1088+
mtr->rollback_to_savepoint(savepoint);
10851089
rec = old_vers;
10861090
if (!old_vers) {
10871091
return dict_load_column_none;
@@ -1618,6 +1622,7 @@ dict_load_field_low(
16181622
if (!trx_id) {
16191623
ut_ad(!rec_get_deleted_flag(rec, 0));
16201624
} else if (mtr && trx_sys.find(nullptr, trx_id, false)) {
1625+
const auto savepoint = mtr->get_savepoint();
16211626
dict_index_t* sys_field = UT_LIST_GET_FIRST(
16221627
dict_sys.sys_fields->indexes);
16231628
rec_offs* offsets = rec_get_offsets(
@@ -1626,6 +1631,7 @@ dict_load_field_low(
16261631
row_vers_build_for_semi_consistent_read(
16271632
nullptr, rec, mtr, sys_field, &offsets, &heap,
16281633
heap, &old_vers, nullptr);
1634+
mtr->rollback_to_savepoint(savepoint);
16291635
rec = old_vers;
16301636
if (!old_vers || rec_get_deleted_flag(rec, 0)) {
16311637
return dict_load_field_none;
@@ -1828,6 +1834,7 @@ dict_load_index_low(
18281834
ut_ad(!rec_get_deleted_flag(rec, 0));
18291835
} else if (!mtr) {
18301836
} else if (trx_sys.find(nullptr, trx_id, false)) {
1837+
const auto savepoint = mtr->get_savepoint();
18311838
dict_index_t* sys_index = UT_LIST_GET_FIRST(
18321839
dict_sys.sys_indexes->indexes);
18331840
rec_offs* offsets = rec_get_offsets(
@@ -1836,6 +1843,7 @@ dict_load_index_low(
18361843
row_vers_build_for_semi_consistent_read(
18371844
nullptr, rec, mtr, sys_index, &offsets, &heap,
18381845
heap, &old_vers, nullptr);
1846+
mtr->rollback_to_savepoint(savepoint);
18391847
rec = old_vers;
18401848
if (!old_vers || rec_get_deleted_flag(rec, 0)) {
18411849
return dict_load_index_none;
@@ -2700,13 +2708,15 @@ static void dict_load_foreign_cols(dict_foreign_t *foreign, trx_id_t trx_id)
27002708
const trx_id_t id = trx_read_trx_id(field);
27012709
if (!id) {
27022710
} else if (id != trx_id && trx_sys.find(nullptr, id, false)) {
2711+
const auto savepoint = mtr.get_savepoint();
27032712
rec_offs* offsets = rec_get_offsets(
27042713
rec, sys_index, nullptr, true, ULINT_UNDEFINED,
27052714
&heap);
27062715
const rec_t* old_vers;
27072716
row_vers_build_for_semi_consistent_read(
27082717
nullptr, rec, &mtr, sys_index, &offsets, &heap,
27092718
heap, &old_vers, nullptr);
2719+
mtr.rollback_to_savepoint(savepoint);
27102720
rec = old_vers;
27112721
if (!rec || rec_get_deleted_flag(rec, 0)) {
27122722
goto next;
@@ -2874,12 +2884,14 @@ dict_load_foreign(
28742884
const trx_id_t tid = trx_read_trx_id(field);
28752885

28762886
if (tid && tid != trx_id && trx_sys.find(nullptr, tid, false)) {
2887+
const auto savepoint = mtr.get_savepoint();
28772888
rec_offs* offsets = rec_get_offsets(
28782889
rec, sys_index, nullptr, true, ULINT_UNDEFINED, &heap);
28792890
const rec_t* old_vers;
28802891
row_vers_build_for_semi_consistent_read(
28812892
nullptr, rec, &mtr, sys_index, &offsets, &heap,
28822893
heap, &old_vers, nullptr);
2894+
mtr.rollback_to_savepoint(savepoint);
28832895
rec = old_vers;
28842896
if (!rec) {
28852897
goto not_found;

0 commit comments

Comments
 (0)