Skip to content

Commit 340753e

Browse files
committed
MDEV-37753 lock_sec_rec_some_has_impl() unnecessarily fetches history
row_vers_impl_x_locked_low(): If a secondary index record points to a clustered index record that carries the current transaction identifier, then there cannot possibly be any implicit locks to that secondary index record, because those would have been checked before the current transaction got the implicit lock (modified the clustered index record) in the first place. This fix will avoid unnecessary access to undo log and possible BLOB pages, which may already have been freed in a purge operation. buf_page_get_zip(): Assert that the page is not marked as freed in the tablespace. This assertion could fire in a scenario like the test case when the table is created in ROW_FORMAT=COMPRESSED. This is a 10.6 version of commit be0e3b2 without a test case.
1 parent 2e89b93 commit 340753e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,7 @@ buf_page_t *buf_page_get_zip(const page_id_t page_id) noexcept
22872287
#ifdef UNIV_DEBUG
22882288
if (!(++buf_dbg_counter % 5771)) buf_pool.validate();
22892289
#endif /* UNIV_DEBUG */
2290+
ut_ad(bpage->state() >= buf_page_t::UNFIXED);
22902291
return bpage;
22912292
}
22922293

storage/innobase/row/row0vers.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,21 @@ row_vers_impl_x_locked_low(
122122
clust_index->n_core_fields,
123123
ULINT_UNDEFINED, &heap);
124124

125+
trx_t* trx = nullptr;
125126
trx_id = row_get_rec_trx_id(clust_rec, clust_index, clust_offsets);
126127
if (trx_id == 0) {
127128
/* The transaction history was already purged. */
129+
done:
128130
mem_heap_free(heap);
129-
DBUG_RETURN(0);
131+
DBUG_RETURN(trx);
130132
}
131133

132134
ut_ad(!clust_index->table->is_temporary());
133135

134-
trx_t* trx;
135-
136136
if (trx_id == caller_trx->id) {
137137
trx = caller_trx;
138138
trx->reference();
139+
goto done;
139140
} else {
140141
trx = trx_sys.find(caller_trx, trx_id);
141142
if (trx == 0) {

0 commit comments

Comments
 (0)