From 4b123e37277bb68c46e44582ce0f5c537f79d285 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 --- 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 2f8fd4f8fb81..5444e346238f 100644 --- a/src/box/memtx_tx.c +++ b/src/box/memtx_tx.c @@ -2018,7 +2018,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 || !tuple_has_flag(new_tuple, TUPLE_IS_DIRTY)); @@ -2659,11 +2659,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); @@ -2708,11 +2704,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_has_flag(tuple, TUPLE_IS_DIRTY)) { diff --git a/src/box/memtx_tx.h b/src/box/memtx_tx.h index 9f2dfeb01bb6..2c03c98cf6f9 100644 --- a/src/box/memtx_tx.h +++ b/src/box/memtx_tx.h @@ -282,10 +282,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); } @@ -315,10 +312,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); @@ -346,10 +340,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); }