From 14325a6f5e3f58c380b5d171216613dae54b6a51 Mon Sep 17 00:00:00 2001 From: Aleksandr Lyapunov Date: Sun, 19 Feb 2023 18:13:40 +0300 Subject: [PATCH] memtx: check for ephemeral spaces in a uniform way In our SQL implementation temporary spaces are used. They come to MVCC engine in two variants - NULL or ephemeral. In both cases MVCC engine must not do anything, there are several checks for that in different parts of code. Normalize these checks and make them similar to each other. Part of #8648 Part of #8654 NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring (cherry picked from commit 86a8155c2fb677120a8c99c5c40eeb9f82ec4f00) --- src/box/memtx_tx.c | 14 +++----------- src/box/memtx_tx.h | 15 +++------------ 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c index 8382b9eb0ddd..f3b043b81396 100644 --- a/src/box/memtx_tx.c +++ b/src/box/memtx_tx.c @@ -2023,7 +2023,7 @@ memtx_tx_history_add_stmt(struct txn_stmt *stmt, struct tuple *old_tuple, struct tuple **result) { assert(stmt != NULL); - assert(stmt->space != NULL); + assert(stmt->space != NULL && !stmt->space->def->opts.is_ephemeral); assert(new_tuple != NULL || old_tuple != NULL); assert(new_tuple == NULL || !new_tuple->is_dirty); @@ -2666,11 +2666,7 @@ static void memtx_tx_track_read_story(struct txn *txn, struct space *space, struct memtx_story *story, uint64_t index_mask) { - if (txn == NULL) - return; - if (space == NULL) - return; - if (space->def->opts.is_ephemeral) + if (txn == NULL || space == NULL || space->def->opts.is_ephemeral) return; (void)space; assert(story != NULL); @@ -2715,11 +2711,7 @@ memtx_tx_track_read(struct txn *txn, struct space *space, struct tuple *tuple) { if (tuple == NULL) return; - if (txn == NULL) - return; - if (space == NULL) - return; - if (space->def->opts.is_ephemeral) + if (txn == NULL || space == NULL || space->def->opts.is_ephemeral) return; if (tuple->is_dirty) { diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h index cfbad3240980..5ab55817d5f3 100644 --- a/src/box/memtx_tx.h +++ b/src/box/memtx_tx.h @@ -283,10 +283,7 @@ memtx_tx_track_point(struct txn *txn, struct space *space, { if (!memtx_tx_manager_use_mvcc_engine) return; - if (txn == NULL) - return; - /* Skip ephemeral spaces. */ - if (space == NULL || space->def->id == 0) + if (txn == NULL || space == NULL || space->def->opts.is_ephemeral) return; memtx_tx_track_point_slow(txn, index, key); } @@ -316,10 +313,7 @@ memtx_tx_track_gap(struct txn *txn, struct space *space, struct index *index, { if (!memtx_tx_manager_use_mvcc_engine) return; - if (txn == NULL) - return; - /* Skip ephemeral spaces. */ - if (space == NULL || space->def->id == 0) + if (txn == NULL || space == NULL || space->def->opts.is_ephemeral) return; memtx_tx_track_gap_slow(txn, space, index, successor, type, key, part_count); @@ -347,10 +341,7 @@ memtx_tx_track_full_scan(struct txn *txn, struct space *space, { if (!memtx_tx_manager_use_mvcc_engine) return; - if (txn == NULL) - return; - /* Skip ephemeral spaces. */ - if (space == NULL || space->def->id == 0) + if (txn == NULL || space == NULL || space->def->opts.is_ephemeral) return; memtx_tx_track_full_scan_slow(txn, index); }