From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 795C344643F for ; Thu, 12 Nov 2020 22:52:38 +0300 (MSK) Received: by mail-lf1-f65.google.com with SMTP id l2so10284669lfk.0 for ; Thu, 12 Nov 2020 11:52:38 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 12 Nov 2020 22:51:16 +0300 Message-Id: <20201112195121.191366-7-gorcunov@gmail.com> In-Reply-To: <20201112195121.191366-1-gorcunov@gmail.com> References: <20201112195121.191366-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 06/11] qsync: txn_limbo_append -- use owner_id in argument name List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy And change the callers. This id is needed to test for foreign keys and to set limbo owner on demand. Signed-off-by: Cyrill Gorcunov --- src/box/txn.c | 8 ++++---- src/box/txn_limbo.c | 15 ++++++++++----- src/box/txn_limbo.h | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index f8726026b..d608f6989 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -832,8 +832,8 @@ txn_commit_async(struct txn *txn) } /* See txn_commit(). */ - uint32_t origin_id = req->rows[0]->replica_id; - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + uint32_t owner_id = req->rows[0]->replica_id; + limbo_entry = txn_limbo_append(&txn_limbo, owner_id, txn); if (limbo_entry == NULL) goto rollback; @@ -900,14 +900,14 @@ txn_commit(struct txn *txn) * Remote rows, if any, come before local rows, so * check for originating instance id here. */ - uint32_t origin_id = req->rows[0]->replica_id; + uint32_t owner_id = req->rows[0]->replica_id; /* * Append now. Before even WAL write is done. * After WAL write nothing should fail, even OOM * wouldn't be acceptable. */ - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + limbo_entry = txn_limbo_append(&txn_limbo, owner_id, txn); if (limbo_entry == NULL) goto rollback; } diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 2c35cd785..674dcad28 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -49,7 +49,7 @@ txn_limbo_create(struct txn_limbo *limbo) } struct txn_limbo_entry * -txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) +txn_limbo_append(struct txn_limbo *limbo, uint32_t owner_id, struct txn *txn) { assert(txn_has_flag(txn, TXN_WAIT_SYNC)); /* @@ -70,12 +70,17 @@ txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) diag_set(ClientError, ER_SYNC_ROLLBACK); return NULL; } - if (id == 0) - id = instance_id; - if (limbo->owner_id != id) { + if (owner_id == REPLICA_ID_NIL) { + /* + * Transactionis initiated on the local node, + * thus we're the owner of the transaction. + */ + owner_id = instance_id; + } + if (limbo->owner_id != owner_id) { if (limbo->owner_id == REPLICA_ID_NIL || rlist_empty(&limbo->queue)) { - limbo->owner_id = id; + limbo->owner_id = owner_id; limbo->confirmed_lsn = 0; } else { diag_set(ClientError, ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index c7e70ba64..1b56903b7 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -191,7 +191,7 @@ txn_limbo_last_entry(struct txn_limbo *limbo) * The limbo entry is allocated on the transaction's region. */ struct txn_limbo_entry * -txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn); +txn_limbo_append(struct txn_limbo *limbo, uint32_t owner_id, struct txn *txn); /** Remove the entry from the limbo, mark as rolled back. */ void -- 2.26.2