From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E223E42EF60 for ; Fri, 3 Jul 2020 09:33:27 +0300 (MSK) Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1jrFGJ-0003jC-HV for tarantool-patches@dev.tarantool.org; Fri, 03 Jul 2020 09:33:27 +0300 From: Aleksandr Lyapunov Date: Fri, 3 Jul 2020 09:33:11 +0300 Message-Id: <1593757997-4145-10-git-send-email-alyapunov@tarantool.org> In-Reply-To: <1593757997-4145-1-git-send-email-alyapunov@tarantool.org> References: <1593757997-4145-1-git-send-email-alyapunov@tarantool.org> Subject: [Tarantool-patches] [PATCH 09/15] tx: introduce prepare sequence number List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org --- src/box/txn.c | 4 ++++ src/box/txn.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/box/txn.c b/src/box/txn.c index 08293a1..8a935d7 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -38,6 +38,8 @@ struct tx_manager { + /** Last prepare-sequence-number that was assigned to preped TX. */ + int64_t last_psn; }; static struct tx_manager txm; @@ -539,6 +541,8 @@ txn_journal_entry_new(struct txn *txn) static int txn_prepare(struct txn *txn) { + txn->psn = ++txm.last_psn; + if (txn_has_flag(txn, TXN_IS_ABORTED_BY_YIELD)) { assert(!txn_has_flag(txn, TXN_CAN_YIELD)); diag_set(ClientError, ER_TRANSACTION_YIELD); diff --git a/src/box/txn.h b/src/box/txn.h index e2194b6..cd1665f 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -214,6 +214,11 @@ struct txn { * Valid IDs start from 1. */ int64_t id; + /** + * A sequential ID that is assigned when the TX become prepared. + * Transactions are committed on in that order. + */ + int64_t psn; /** Status of the TX */ enum txn_status status; /** List of statements in a transaction. */ -- 2.7.4