From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 844D82B839 for ; Thu, 29 Mar 2018 12:15:21 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HgC-fmebRjqn for ; Thu, 29 Mar 2018 12:15:20 -0400 (EDT) Received: from smtp58.i.mail.ru (smtp58.i.mail.ru [217.69.128.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C14DD2B019 for ; Thu, 29 Mar 2018 12:15:19 -0400 (EDT) Received: by smtp58.i.mail.ru with esmtpa (envelope-from ) id 1f1aCr-0003v5-JB for tarantool-patches@freelists.org; Thu, 29 Mar 2018 19:15:17 +0300 From: Konstantin Belyavskiy Subject: [tarantool-patches] [PATCH 1/2] [replication] [recovery] recover missing data Date: Thu, 29 Mar 2018 19:15:15 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Part 1 of 2. Add vclock comparison as a new synchronization condition. And update catch test as now it works as expected. Closes #3210 --- branch: gh-3210-recover-missing-local-data-master-master src/box/applier.cc | 16 +++++++++++----- test/replication/catch.result | 5 +++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/box/applier.cc b/src/box/applier.cc index 6bfe5a99a..12bf1f0d2 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -305,7 +305,7 @@ applier_join(struct applier *applier) * server is 1.6. Since we have * not initialized replication * vclock yet, do it now. In 1.7+ - * this vlcock is not used. + * this vclock is not used. */ xrow_decode_vclock_xc(&row, &replicaset.vclock); } @@ -370,6 +370,7 @@ applier_subscribe(struct applier *applier) struct ev_io *coio = &applier->io; struct ibuf *ibuf = &applier->ibuf; struct xrow_header row; + struct vclock remote_vclock_at_subscribe; xrow_encode_subscribe_xc(&row, &REPLICASET_UUID, &INSTANCE_UUID, &replicaset.vclock); @@ -411,9 +412,8 @@ applier_subscribe(struct applier *applier) * In case of successful subscribe, the server * responds with its current vclock. */ - struct vclock vclock; - vclock_create(&vclock); - xrow_decode_vclock_xc(&row, &vclock); + vclock_create(&remote_vclock_at_subscribe); + xrow_decode_vclock_xc(&row, &remote_vclock_at_subscribe); } /** * Tarantool < 1.6.7: @@ -452,8 +452,14 @@ applier_subscribe(struct applier *applier) applier_set_state(applier, APPLIER_FOLLOW); } + /* + * Must stay in read-only mode, until it synchronized. + * Check lag and compare local vclock with remote one. + */ if (applier->state == APPLIER_SYNC && - applier->lag <= replication_sync_lag) { + applier->lag <= replication_sync_lag && + vclock_compare(&remote_vclock_at_subscribe, + &replicaset.vclock) <= 0) { /* Applier is synced, switch to "follow". */ applier_set_state(applier, APPLIER_FOLLOW); } diff --git a/test/replication/catch.result b/test/replication/catch.result index 7d61ad26f..05c1c243e 100644 --- a/test/replication/catch.result +++ b/test/replication/catch.result @@ -99,10 +99,11 @@ box.space.test ~= nil ... d = box.space.test:delete{1} --- +- error: Can't modify data because this instance is in read-only mode. ... box.space.test:get(1) == nil --- -- true +- false ... -- case #2: delete tuple by net.box test_run:cmd("switch default") @@ -118,7 +119,7 @@ c = net_box.connect(r_uri) ... c.space.test:get(1) == nil --- -- true +- false ... -- check sync errinj.set("ERRINJ_RELAY_TIMEOUT", 0) -- 2.14.3 (Apple Git-98)