From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (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 3686445C305 for ; Tue, 9 Jun 2020 15:20:50 +0300 (MSK) From: Serge Petrenko Date: Tue, 9 Jun 2020 15:20:18 +0300 Message-Id: <461deb567c698a6222aa429aedcf85beba3256ad.1591701695.git.sergepetrenko@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 6/8] txn_limbo: fix instance id assignment List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, sergos@tarantool.org, gorcunov@gmail.com Cc: tarantool-patches@dev.tarantool.org When a txn_limbo is running on a replica, it holds changes from a remote master. Reflect it by assigning libmo instance id accordingly. Follow-up #4844 Part-of #4847 --- src/box/txn.c | 8 +++++++- src/box/txn_limbo.c | 8 +++++--- src/box/txn_limbo.h | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index f30e20944..a65100b31 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -673,12 +673,18 @@ txn_commit(struct txn *txn) bool is_sync = txn_has_flag(txn, TXN_WAIT_ACK); if (is_sync) { + /* + * Remote rows, if any, come before local rows, so + * check for originating instance id here. + */ + uint32_t origin_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, txn); + limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); if (limbo_entry == NULL) { txn_rollback(txn); txn_free(txn); diff --git a/src/box/txn_limbo.c b/src/box/txn_limbo.c index 47c1bd249..efb97a591 100644 --- a/src/box/txn_limbo.c +++ b/src/box/txn_limbo.c @@ -43,13 +43,15 @@ txn_limbo_create(struct txn_limbo *limbo) } struct txn_limbo_entry * -txn_limbo_append(struct txn_limbo *limbo, struct txn *txn) +txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn) { assert(txn_has_flag(txn, TXN_WAIT_ACK)); - if (limbo->instance_id != instance_id) { + if (id == 0) + id = instance_id; + if (limbo->instance_id != id) { if (limbo->instance_id == REPLICA_ID_NIL || rlist_empty(&limbo->queue)) { - limbo->instance_id = instance_id; + limbo->instance_id = id; } else { diag_set(ClientError, ER_UNCOMMITTED_FOREIGN_SYNC_TXNS, limbo->instance_id); diff --git a/src/box/txn_limbo.h b/src/box/txn_limbo.h index 112fa8902..1ad1c567a 100644 --- a/src/box/txn_limbo.h +++ b/src/box/txn_limbo.h @@ -131,7 +131,7 @@ extern struct txn_limbo txn_limbo; * The limbo entry is allocated on the transaction's region. */ struct txn_limbo_entry * -txn_limbo_append(struct txn_limbo *limbo, struct txn *txn); +txn_limbo_append(struct txn_limbo *limbo, uint32_t id, struct txn *txn); /** Remove the entry from the limbo, mark as rolled back. */ void -- 2.24.3 (Apple Git-128)