From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 7B5187030F; Fri, 22 Jan 2021 16:29:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7B5187030F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1611322180; bh=q0bU2XIk/+M2y6uP77WaZXTmm71Px5G4JjzPY/Zw0Eo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=k7oVxUxr2HUYelgWCuZJLvBdQbfvEkebD/EnUnZP+jd3KOL7VKCTuhqaEOIvQXLPR SzXeATwY11r9RWTRjI31AOYtcHIVDqShsx+c8dlLt2H3JtS0bZ2N7kmgf1K0rB8ecS Q9LP3lbapfb4QnwMjX7l3cVEzXX4P7FeRh1Vd8gY= Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E0C8882061 for ; Fri, 22 Jan 2021 16:28:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E0C8882061 Received: by mail-lj1-f172.google.com with SMTP id i17so6538039ljn.1 for ; Fri, 22 Jan 2021 05:28:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qzCR3eKfv07qGYLBugJxeP1SWryOcfZWbUz1ydOqVoo=; b=W34UhmrfqiTZvT/tdvoJQOlm5zXe4/q7+sYlYnQRV9Mk/Q5Du0uc8wWG8kJlrIyQZV Ayjwl3MNhEJodKWrkYl2/zszBjgaFxpWVFxT8ZXSqMHFbpBJ6jS2l6qVwm3W/73AvvXM ERKPKDbARnwQbnzBbhY9EtXnzzLoGMivVi3YizHm6thTbhuwfo89e4Xxf1KWYsLbaUtp sCJwHHWQUyykYgol8zYAvjoPiv7kDpNiNuXEAleJV9t37SepI3Ast1sze9IJEvVHf26C 0+pZva2e6Bx9iuF/SNhDaW9VB0758d2XBwzbQgZBRkRD6iYChn+E1IZ14by6qP4c3BQc 5p6g== X-Gm-Message-State: AOAM530T0p7gRtJzjJo+9Yeghuc8BbaPGBFJNDumHXEjUTE6vWuUZrZY oD5cdu6zIjc5rT0MrejvE6M3KNL/cfk= X-Google-Smtp-Source: ABdhPJyiRaNRctojPBTTlYyUpPTMooAllZ4VGlcGu+AKJxA5NUm3JjiZypXK1y6IcoFojYLGqOA+rQ== X-Received: by 2002:a2e:3215:: with SMTP id y21mr2292256ljy.48.1611322086788; Fri, 22 Jan 2021 05:28:06 -0800 (PST) Received: from grain.localdomain ([5.18.91.94]) by smtp.gmail.com with ESMTPSA id x25sm424386lfc.298.2021.01.22.05.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jan 2021 05:28:05 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id A6B3F5609D4; Fri, 22 Jan 2021 16:27:04 +0300 (MSK) To: tml Date: Fri, 22 Jan 2021 16:26:59 +0300 Message-Id: <20210122132700.272816-6-gorcunov@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210122132700.272816-1-gorcunov@gmail.com> References: <20210122132700.272816-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 5/6] txn: stop using txn_has_flag X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Part-of #5128 Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 39 +++++++++++++++++++-------------------- src/box/txn.h | 2 +- src/box/txn_limbo.c | 26 +++++++++++++------------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 6197cf012..d1964b5f7 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -526,7 +526,7 @@ txn_free_or_wakeup(struct txn *txn) void txn_complete_fail(struct txn *txn) { - assert(!txn_has_flag(txn, TXN_IS_DONE)); + assert(!(txn->flags & TXN_IS_DONE)); assert(txn->signature < 0); txn->status = TXN_ABORTED; struct txn_stmt *stmt; @@ -535,7 +535,7 @@ txn_complete_fail(struct txn *txn) txn_rollback_one_stmt(txn, stmt); if (txn->engine != NULL) engine_rollback(txn->engine, txn); - if (txn_has_flag(txn, TXN_HAS_TRIGGERS)) + if (txn->flags & TXN_HAS_TRIGGERS) txn_run_rollback_triggers(txn, &txn->on_rollback); txn_free_or_wakeup(txn); } @@ -543,13 +543,12 @@ txn_complete_fail(struct txn *txn) void txn_complete_success(struct txn *txn) { - assert(!txn_has_flag(txn, TXN_IS_DONE)); - assert(!txn_has_flag(txn, TXN_WAIT_SYNC)); + assert(!(txn->flags & (TXN_IS_DONE | TXN_WAIT_SYNC))); assert(txn->signature >= 0); txn->status = TXN_COMMITTED; if (txn->engine != NULL) engine_commit(txn->engine, txn); - if (txn_has_flag(txn, TXN_HAS_TRIGGERS)) + if (txn->flags & TXN_HAS_TRIGGERS) txn_run_commit_triggers(txn, &txn->on_commit); txn_free_or_wakeup(txn); } @@ -587,9 +586,9 @@ txn_on_journal_write(struct journal_entry *entry) "%.3f sec", n_rows, txn->signature - n_rows + 1, delta); } - if (txn_has_flag(txn, TXN_HAS_TRIGGERS)) + if (txn->flags & TXN_HAS_TRIGGERS) txn_run_wal_write_triggers(txn); - if (!txn_has_flag(txn, TXN_WAIT_SYNC)) + if (!(txn->flags & TXN_WAIT_SYNC)) txn_complete_success(txn); else if (txn->fiber != NULL && txn->fiber != fiber()) fiber_wakeup(txn->fiber); @@ -640,7 +639,7 @@ txn_journal_entry_new(struct txn *txn) * space can't be synchronous. So if there is at least one * synchronous space, the transaction is not local. */ - if (!txn_has_flag(txn, TXN_FORCE_ASYNC)) { + if (!(txn->flags & TXN_FORCE_ASYNC)) { if (is_sync) { txn->flags |= TXN_WAIT_SYNC | TXN_WAIT_ACK; } else if (!txn_limbo_is_empty(&txn_limbo)) { @@ -692,8 +691,8 @@ txn_prepare(struct txn *txn) { txn->psn = ++txn_last_psn; - if (txn_has_flag(txn, TXN_IS_ABORTED_BY_YIELD)) { - assert(!txn_has_flag(txn, TXN_CAN_YIELD)); + if (txn->flags & TXN_IS_ABORTED_BY_YIELD) { + assert(!(txn->flags & TXN_CAN_YIELD)); diag_set(ClientError, ER_TRANSACTION_YIELD); diag_log(); return -1; @@ -747,7 +746,7 @@ txn_prepare(struct txn *txn) assert(rlist_empty(&txn->conflicted_by_list)); trigger_clear(&txn->fiber_on_stop); - if (!txn_has_flag(txn, TXN_CAN_YIELD)) + if (!(txn->flags & TXN_CAN_YIELD)) trigger_clear(&txn->fiber_on_yield); txn->start_tm = ev_monotonic_now(loop()); @@ -814,7 +813,7 @@ txn_commit_async(struct txn *txn) if (req == NULL) goto rollback; - bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); + bool is_sync = txn->flags & TXN_WAIT_SYNC; struct txn_limbo_entry *limbo_entry; if (is_sync) { /* @@ -837,7 +836,7 @@ txn_commit_async(struct txn *txn) if (limbo_entry == NULL) goto rollback; - if (txn_has_flag(txn, TXN_WAIT_ACK)) { + if (txn->flags & TXN_WAIT_ACK) { int64_t lsn = req->rows[txn->n_applier_rows - 1]->lsn; /* * Can't tell whether it is local or not - @@ -894,7 +893,7 @@ txn_commit(struct txn *txn) if (req == NULL) goto rollback; - bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); + bool is_sync = txn->flags & TXN_WAIT_SYNC; if (is_sync) { /* * Remote rows, if any, come before local rows, so @@ -921,7 +920,7 @@ txn_commit(struct txn *txn) goto rollback; } if (is_sync) { - if (txn_has_flag(txn, TXN_WAIT_ACK)) { + if (txn->flags & TXN_WAIT_ACK) { int64_t lsn = req->rows[req->n_rows - 1]->lsn; /* * Use local LSN assignment. Because @@ -936,7 +935,7 @@ txn_commit(struct txn *txn) if (txn_limbo_wait_complete(&txn_limbo, limbo_entry) < 0) goto rollback; } - assert(txn_has_flag(txn, TXN_IS_DONE)); + assert(txn->flags & TXN_IS_DONE); assert(txn->signature >= 0); /* Synchronous transactions are freed by the calling fiber. */ @@ -945,7 +944,7 @@ txn_commit(struct txn *txn) rollback: assert(txn->fiber != NULL); - if (!txn_has_flag(txn, TXN_IS_DONE)) { + if (!(txn->flags & TXN_IS_DONE)) { fiber_set_txn(fiber(), txn); txn_rollback(txn); } else { @@ -970,7 +969,7 @@ txn_rollback(struct txn *txn) assert(txn == in_txn()); txn->status = TXN_ABORTED; trigger_clear(&txn->fiber_on_stop); - if (!txn_has_flag(txn, TXN_CAN_YIELD)) + if (!(txn->flags & TXN_CAN_YIELD)) trigger_clear(&txn->fiber_on_yield); txn->signature = TXN_SIGNATURE_ROLLBACK; txn_complete_fail(txn); @@ -991,7 +990,7 @@ bool txn_can_yield(struct txn *txn, bool set) { assert(txn == in_txn()); - bool could = txn_has_flag(txn, TXN_CAN_YIELD); + bool could = txn->flags & TXN_CAN_YIELD; if (set && !could) { txn->flags |= TXN_CAN_YIELD; trigger_clear(&txn->fiber_on_yield); @@ -1226,7 +1225,7 @@ txn_on_yield(struct trigger *trigger, void *event) (void) event; struct txn *txn = in_txn(); assert(txn != NULL); - assert(!txn_has_flag(txn, TXN_CAN_YIELD)); + assert(!(txn->flags & TXN_CAN_YIELD)); txn_rollback_to_svp(txn, NULL); txn->flags |= TXN_IS_ABORTED_BY_YIELD; return 0; diff --git a/src/box/txn.h b/src/box/txn.h index 201564000..36a413167 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -487,7 +487,7 @@ txn_commit_async(struct txn *txn); static inline void txn_init_triggers(struct txn *txn) { - if (!txn_has_flag(txn, TXN_HAS_TRIGGERS)) { + if (!(txn->flags & TXN_HAS_TRIGGERS)) { rlist_create(&txn->on_commit); rlist_create(&txn->on_rollback); rlist_create(&txn->on_wal_write); diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index d418530ad..86b3bc580 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -60,7 +60,7 @@ txn_limbo_last_synchro_entry(struct txn_limbo *limbo) { struct txn_limbo_entry *entry; rlist_foreach_entry_reverse(entry, &limbo->queue, in_queue) { - if (txn_has_flag(entry->txn, TXN_WAIT_ACK)) + if (entry->txn->flags & TXN_WAIT_ACK) return entry; } return NULL; @@ -69,7 +69,7 @@ txn_limbo_last_synchro_entry(struct txn_limbo *limbo) struct txn_limbo_entry * txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) { - assert(txn_has_flag(txn, TXN_WAIT_SYNC)); + assert(txn->flags & TXN_WAIT_SYNC); assert(limbo == &txn_limbo); /* * Transactions should be added to the limbo before WAL write. Limbo @@ -168,7 +168,7 @@ txn_limbo_assign_remote_lsn(struct txn_limbo *limbo, assert(limbo->owner_id != instance_id); assert(entry->lsn == -1); assert(lsn > 0); - assert(txn_has_flag(entry->txn, TXN_WAIT_ACK)); + assert(entry->txn->flags & TXN_WAIT_ACK); (void) limbo; entry->lsn = lsn; } @@ -181,7 +181,7 @@ txn_limbo_assign_local_lsn(struct txn_limbo *limbo, assert(limbo->owner_id == instance_id); assert(entry->lsn == -1); assert(lsn > 0); - assert(txn_has_flag(entry->txn, TXN_WAIT_ACK)); + assert(entry->txn->flags & TXN_WAIT_ACK); entry->lsn = lsn; /* @@ -215,14 +215,14 @@ txn_limbo_write_rollback(struct txn_limbo *limbo, int64_t lsn); int txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry) { - assert(entry->lsn > 0 || !txn_has_flag(entry->txn, TXN_WAIT_ACK)); + assert(entry->lsn > 0 || !(entry->txn->flags & TXN_WAIT_ACK)); bool cancellable = fiber_set_cancellable(false); if (txn_limbo_entry_is_complete(entry)) goto complete; - assert(!txn_has_flag(entry->txn, TXN_IS_DONE)); - assert(txn_has_flag(entry->txn, TXN_WAIT_SYNC)); + assert(!(entry->txn->flags & TXN_IS_DONE)); + assert(entry->txn->flags & TXN_WAIT_SYNC); double start_time = fiber_clock(); while (true) { double deadline = start_time + replication_synchro_timeout; @@ -288,7 +288,7 @@ txn_limbo_wait_complete(struct txn_limbo *limbo, struct txn_limbo_entry *entry) * installed the commit/rollback flag. */ assert(rlist_empty(&entry->in_queue)); - assert(txn_has_flag(entry->txn, TXN_IS_DONE)); + assert(entry->txn->flags & TXN_IS_DONE); fiber_set_cancellable(cancellable); /* * The first tx to be rolled back already performed all @@ -384,7 +384,7 @@ txn_limbo_read_confirm(struct txn_limbo *limbo, int64_t lsn) * it is last, it does not depend on a not finished sync * transaction anymore and can be confirmed right away. */ - if (txn_has_flag(e->txn, TXN_WAIT_ACK)) { + if (e->txn->flags & TXN_WAIT_ACK) { /* Sync transaction not covered by the confirmation. */ if (e->lsn > lsn) break; @@ -444,7 +444,7 @@ txn_limbo_read_rollback(struct txn_limbo *limbo, int64_t lsn) struct txn_limbo_entry *e, *tmp; struct txn_limbo_entry *last_rollback = NULL; rlist_foreach_entry_reverse(e, &limbo->queue, in_queue) { - if (!txn_has_flag(e->txn, TXN_WAIT_ACK)) + if (!(e->txn->flags & TXN_WAIT_ACK)) continue; if (e->lsn < lsn) break; @@ -527,7 +527,7 @@ txn_limbo_ack(struct txn_limbo *limbo, uint32_t replica_id, int64_t lsn) * transactions are automatically committed right * after all the previous sync transactions are. */ - if (!txn_has_flag(e->txn, TXN_WAIT_ACK)) { + if (!(e->txn->flags & TXN_WAIT_ACK)) { assert(e->lsn == -1); if (confirm_lsn == -1) continue; @@ -661,7 +661,7 @@ txn_limbo_force_empty(struct txn_limbo *limbo, int64_t confirm_lsn) struct txn_limbo_entry *e, *last_quorum = NULL; struct txn_limbo_entry *rollback = NULL; rlist_foreach_entry(e, &limbo->queue, in_queue) { - if (txn_has_flag(e->txn, TXN_WAIT_ACK)) { + if (e->txn->flags & TXN_WAIT_ACK) { if (e->lsn <= confirm_lsn) { last_quorum = e; } else { @@ -690,7 +690,7 @@ txn_limbo_on_parameters_change(struct txn_limbo *limbo) int64_t confirm_lsn = -1; rlist_foreach_entry(e, &limbo->queue, in_queue) { assert(e->ack_count <= VCLOCK_MAX); - if (!txn_has_flag(e->txn, TXN_WAIT_ACK)) { + if (!(e->txn->flags & TXN_WAIT_ACK)) { assert(e->lsn == -1); if (confirm_lsn == -1) continue; -- 2.29.2