From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 6890944643A for ; Thu, 12 Nov 2020 22:52:50 +0300 (MSK) Received: by mail-lj1-f172.google.com with SMTP id p12so7645645ljc.9 for ; Thu, 12 Nov 2020 11:52:50 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 12 Nov 2020 22:51:17 +0300 Message-Id: <20201112195121.191366-8-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 07/11] qsync: move limbo owner transition into separate helper List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy This makes transition more explicit since owner_id persistence while processing limbo queue is a key moment. Same time we don't need to check for owner_id == REPLICA_ID_NIL since it can't be nil with nonempty queue. Signed-off-by: Cyrill Gorcunov --- src/box/txn_limbo.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 674dcad28..b58b9647d 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -48,6 +48,24 @@ txn_limbo_create(struct txn_limbo *limbo) limbo->is_in_rollback = false; } +static bool +txn_limbo_change_owner(struct txn_limbo *limbo, uint32_t owner_id) +{ + /* + * Owner transition is allowed for empty txn queue only + * since different nodes have own vclocks and LSNs won't + * be ordered in limbo context. + */ + if (rlist_empty(&limbo->queue)) { + limbo->owner_id = owner_id; + limbo->confirmed_lsn = 0; + return true; + } + + diag_set(ClientError, ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, limbo->owner_id); + return false; +} + struct txn_limbo_entry * txn_limbo_append(struct txn_limbo *limbo, uint32_t owner_id, struct txn *txn) { @@ -77,17 +95,12 @@ txn_limbo_append(struct txn_limbo *limbo, uint32_t owner_id, struct txn *txn) */ owner_id = instance_id; } + if (limbo->owner_id != owner_id) { - if (limbo->owner_id == REPLICA_ID_NIL || - rlist_empty(&limbo->queue)) { - limbo->owner_id = owner_id; - limbo->confirmed_lsn = 0; - } else { - diag_set(ClientError, ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, - limbo->owner_id); + if (!txn_limbo_change_owner(limbo, owner_id)) return NULL; - } } + size_t size; struct txn_limbo_entry *e = region_alloc_object(&txn->region, typeof(*e), &size); -- 2.26.2