From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (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 86A9C469719 for ; Fri, 13 Nov 2020 12:48:00 +0300 (MSK) References: <20201112195121.191366-1-gorcunov@gmail.com> <20201112195121.191366-8-gorcunov@gmail.com> From: Serge Petrenko Message-ID: <025b90cb-64ae-8525-82d5-1fdc20ee3ff7@tarantool.org> Date: Fri, 13 Nov 2020 12:47:59 +0300 MIME-Version: 1.0 In-Reply-To: <20201112195121.191366-8-gorcunov@gmail.com> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [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: Cyrill Gorcunov , tml Cc: Vladislav Shpilevoy 12.11.2020 22:51, Cyrill Gorcunov пишет: > 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; > +} > + AFAIK we use `return 0/-1` for such functions. bool is only used for something that really returns true or false, like `field_mp_type_is_compatible()`. Other than that the patch looks good. > 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); -- Serge Petrenko