From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (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 9A99E44643C for ; Thu, 12 Nov 2020 22:52:26 +0300 (MSK) Received: by mail-lj1-f193.google.com with SMTP id 11so7690016ljf.2 for ; Thu, 12 Nov 2020 11:52:26 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 12 Nov 2020 22:51:15 +0300 Message-Id: <20201112195121.191366-6-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 05/11] qsync: rename txn_limbo::instance_id to owner_id List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Vladislav Shpilevoy The instance_id name is too general, we use it in node's identification while limbo simply "belongs" to those who tracks current transactions queue. Lets rename it to owner_id to distinguish from global instance_id and better grepability. Signed-off-by: Cyrill Gorcunov --- src/box/box.cc | 2 +- src/box/relay.cc | 2 +- src/box/txn.c | 2 +- src/box/txn_limbo.c | 34 +++++++++++++++++----------------- src/box/txn_limbo.h | 2 +- test/unit/snap_quorum_delay.cc | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/box/box.cc b/src/box/box.cc index 1f7dec362..9ff4545e1 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1014,7 +1014,7 @@ box_clear_synchro_queue(bool try_wait) { if (!is_box_configured || txn_limbo_is_empty(&txn_limbo)) return; - uint32_t former_leader_id = txn_limbo.instance_id; + uint32_t former_leader_id = txn_limbo.owner_id; assert(former_leader_id != REPLICA_ID_NIL); if (former_leader_id == instance_id) return; diff --git a/src/box/relay.cc b/src/box/relay.cc index 1e77e0d9b..fa3dc3a75 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -419,7 +419,7 @@ tx_status_update(struct cmsg *msg) * the single master in 100% so far). Other instances wait * for master's CONFIRM message instead. */ - if (txn_limbo.instance_id == instance_id) { + if (txn_limbo.owner_id == instance_id) { txn_limbo_ack(&txn_limbo, status->relay->replica->id, vclock_get(&status->vclock, instance_id)); } diff --git a/src/box/txn.c b/src/box/txn.c index 64f01f4e0..f8726026b 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -931,7 +931,7 @@ txn_commit(struct txn *txn) txn_limbo_assign_local_lsn(&txn_limbo, limbo_entry, lsn); /* Local WAL write is a first 'ACK'. */ - txn_limbo_ack(&txn_limbo, txn_limbo.instance_id, lsn); + txn_limbo_ack(&txn_limbo, txn_limbo.owner_id, lsn); } if (txn_limbo_wait_complete(&txn_limbo, limbo_entry) < 0) goto rollback; diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index c94678885..2c35cd785 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -40,7 +40,7 @@ static inline void txn_limbo_create(struct txn_limbo *limbo) { rlist_create(&limbo->queue); - limbo->instance_id = REPLICA_ID_NIL; + limbo->owner_id = REPLICA_ID_NIL; fiber_cond_create(&limbo->wait_cond); vclock_create(&limbo->vclock); limbo->confirmed_lsn = 0; @@ -72,14 +72,14 @@ txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) } if (id == 0) id = instance_id; - if (limbo->instance_id != id) { - if (limbo->instance_id == REPLICA_ID_NIL || + if (limbo->owner_id != id) { + if (limbo->owner_id == REPLICA_ID_NIL || rlist_empty(&limbo->queue)) { - limbo->instance_id = id; + limbo->owner_id = id; limbo->confirmed_lsn = 0; } else { diag_set(ClientError, ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, - limbo->instance_id); + limbo->owner_id); return NULL; } } @@ -136,8 +136,8 @@ void txn_limbo_assign_remote_lsn(struct txn_limbo *limbo, struct txn_limbo_entry *entry, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL); - assert(limbo->instance_id != instance_id); + assert(limbo->owner_id != REPLICA_ID_NIL); + assert(limbo->owner_id != instance_id); assert(entry->lsn == -1); assert(lsn > 0); assert(txn_has_flag(entry->txn, TXN_WAIT_ACK)); @@ -149,8 +149,8 @@ void txn_limbo_assign_local_lsn(struct txn_limbo *limbo, struct txn_limbo_entry *entry, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL); - assert(limbo->instance_id == instance_id); + assert(limbo->owner_id != REPLICA_ID_NIL); + assert(limbo->owner_id == instance_id); assert(entry->lsn == -1); assert(lsn > 0); assert(txn_has_flag(entry->txn, TXN_WAIT_ACK)); @@ -175,7 +175,7 @@ void txn_limbo_assign_lsn(struct txn_limbo *limbo, struct txn_limbo_entry *entry, int64_t lsn) { - if (limbo->instance_id == instance_id) + if (limbo->owner_id == instance_id) txn_limbo_assign_local_lsn(limbo, entry, lsn); else txn_limbo_assign_remote_lsn(limbo, entry, lsn); @@ -293,7 +293,7 @@ txn_limbo_write_synchro(struct txn_limbo *limbo, uint32_t type, int64_t lsn) struct synchro_request req = { .type = type, - .replica_id = limbo->instance_id, + .replica_id = limbo->owner_id, .lsn = lsn, }; @@ -348,7 +348,7 @@ txn_limbo_write_confirm(struct txn_limbo *limbo, int64_t lsn) static void txn_limbo_read_confirm(struct txn_limbo *limbo, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL); + assert(limbo->owner_id != REPLICA_ID_NIL); struct txn_limbo_entry *e, *tmp; rlist_foreach_entry_safe(e, &limbo->queue, in_queue, tmp) { /* @@ -409,7 +409,7 @@ txn_limbo_write_rollback(struct txn_limbo *limbo, int64_t lsn) static void txn_limbo_read_rollback(struct txn_limbo *limbo, int64_t lsn) { - assert(limbo->instance_id != REPLICA_ID_NIL); + assert(limbo->owner_id != REPLICA_ID_NIL); struct txn_limbo_entry *e, *tmp; struct txn_limbo_entry *last_rollback = NULL; rlist_foreach_entry_reverse(e, &limbo->queue, in_queue) { @@ -471,7 +471,7 @@ txn_limbo_ack(struct txn_limbo *limbo, uint32_t replica_id, int64_t lsn) */ if (limbo->is_in_rollback) return; - assert(limbo->instance_id != REPLICA_ID_NIL); + assert(limbo->owner_id != REPLICA_ID_NIL); int64_t prev_lsn = vclock_get(&limbo->vclock, replica_id); /* * One of the reasons why can happen - the remote instance is not @@ -600,9 +600,9 @@ txn_limbo_wait_confirm(struct txn_limbo *limbo) int txn_limbo_process(struct txn_limbo *limbo, const struct synchro_request *req) { - if (req->replica_id != limbo->instance_id) { - diag_set(ClientError, ER_SYNC_MASTER_MISMATCH, req->replica_id, - limbo->instance_id); + if (req->replica_id != limbo->owner_id) { + diag_set(ClientError, ER_SYNC_MASTER_MISMATCH, + req->replica_id, limbo->owner_id); return -1; } switch (req->type) { diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index 3685164a9..c7e70ba64 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -103,7 +103,7 @@ struct txn_limbo { * won't make sense - different nodes have own independent * LSNs in their vclock components. */ - uint32_t instance_id; + uint32_t owner_id; /** * Condition to wait for completion. It is supposed to be * signaled when the synchro parameters change. Allowing diff --git a/test/unit/snap_quorum_delay.cc b/test/unit/snap_quorum_delay.cc index ad0563345..b9d4cc6c4 100644 --- a/test/unit/snap_quorum_delay.cc +++ b/test/unit/snap_quorum_delay.cc @@ -131,7 +131,7 @@ txn_process_func(va_list ap) } txn_limbo_assign_local_lsn(&txn_limbo, entry, fake_lsn); - txn_limbo_ack(&txn_limbo, txn_limbo.instance_id, fake_lsn); + txn_limbo_ack(&txn_limbo, txn_limbo.owner_id, fake_lsn); txn_limbo_wait_complete(&txn_limbo, entry); switch (process_type) { -- 2.26.2