From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 8430342EF61 for ; Tue, 30 Jun 2020 02:15:41 +0300 (MSK) From: Vladislav Shpilevoy Date: Tue, 30 Jun 2020 01:15:18 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v2 17/19] replication: delay initial join until confirmation List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org From: Serge Petrenko All the data that master sends during the join stage (both initial and final) is embedded into the first snapshot created on replica, so this data mustn't contain any unconfirmed or rolled back synchronous transactions. Make sure that master starts sending the initial data, which contains a snapshot-like dump of all the spaces only after the latest synchronous tx it has is confirmed. In case of rollback, the replica may retry joining. Part of #5097 --- src/box/applier.cc | 9 +++++++++ src/box/relay.cc | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/box/applier.cc b/src/box/applier.cc index a9baf0d69..7e63dc544 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -1194,6 +1194,15 @@ applier_f(va_list ap) applier_log_error(applier, e); applier_disconnect(applier, APPLIER_LOADING); goto reconnect; + } else if (e->errcode() == ER_SYNC_QUORUM_TIMEOUT || + e->errcode() == ER_SYNC_ROLLBACK) { + /* + * Join failure due to synchronous + * transaction rollback. + */ + applier_log_error(applier, e); + applier_disconnect(applier, APPLIER_LOADING); + goto reconnect; } else if (e->errcode() == ER_CFG || e->errcode() == ER_ACCESS_DENIED || e->errcode() == ER_NO_SUCH_USER || diff --git a/src/box/relay.cc b/src/box/relay.cc index 29588b6ca..a7843a8c2 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -321,6 +321,13 @@ relay_initial_join(int fd, uint64_t sync, struct vclock *vclock) if (wal_sync(vclock) != 0) diag_raise(); + /* + * Start sending data only when the latest sync + * transaction is confirmed. + */ + if (txn_limbo_wait_confirm(&txn_limbo) != 0) + diag_raise(); + /* Respond to the JOIN request with the current vclock. */ struct xrow_header row; xrow_encode_vclock_xc(&row, vclock); -- 2.21.1 (Apple Git-122.3)