From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <avtikhon@tarantool.org>
Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37])
 (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 03F13469719
 for <tarantool-patches@dev.tarantool.org>;
 Mon,  7 Sep 2020 15:13:56 +0300 (MSK)
From: "Alexander V. Tikhonov" <avtikhon@tarantool.org>
Date: Mon,  7 Sep 2020 15:13:53 +0300
Message-Id: <0e6d058ce43dcba3b8268a1a09e71e22e287a7db.1599480747.git.avtikhon@tarantool.org>
Subject: [Tarantool-patches] [PATCH v1] test: flaky
	replication/gh-5195-qsync-*
List-Id: Tarantool development patches <tarantool-patches.dev.tarantool.org>
List-Unsubscribe: <https://lists.tarantool.org/mailman/options/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=unsubscribe>
List-Archive: <https://lists.tarantool.org/pipermail/tarantool-patches/>
List-Post: <mailto:tarantool-patches@dev.tarantool.org>
List-Help: <mailto:tarantool-patches-request@dev.tarantool.org?subject=help>
List-Subscribe: <https://lists.tarantool.org/mailman/listinfo/tarantool-patches>, 
 <mailto:tarantool-patches-request@dev.tarantool.org?subject=subscribe>
To: Kirill Yukhin <kyukhin@tarantool.org>, Serge Petrenko <sergepetrenko@tarantool.org>, Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org

On heavy loaded hosts found the following issue:

   box.cfg{replication_synchro_quorum = 2}
    | ---
  + | - error: '[string "test_run:wait_cond(function()                ..."]:1: attempt to
  + |     index field ''vclock'' (a nil value)'
    | ...
   test_run:wait_cond(function() return f:status() == 'dead' end)
    | ---
  - | - true
  + | - false
    | ...
   ok, err
    | ---
  - | - true
  - | - [2]
  + | - null
  + | - null
    | ...
   box.space.sync:select{}
    | ---

It happened because replication vclock field was not exist at the moment
of its check. To fix the issue, vclock field had to be waited to be
available using test_run:wait_cond() routine.

Closes #5230
---

Github: https://github.com/tarantool/tarantool/tree/avtikhon/gh-5230-fix-qsync-write-5195
Issue: https://github.com/tarantool/tarantool/issues/5230

 test/replication/gh-5195-qsync-replica-write.result   | 10 ++++++----
 test/replication/gh-5195-qsync-replica-write.test.lua |  7 +++----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/test/replication/gh-5195-qsync-replica-write.result b/test/replication/gh-5195-qsync-replica-write.result
index 3999e8f5e..b47359fde 100644
--- a/test/replication/gh-5195-qsync-replica-write.result
+++ b/test/replication/gh-5195-qsync-replica-write.result
@@ -96,10 +96,12 @@ test_run:wait_downstream(replica_id, {status='follow'})
  | - true
  | ...
 test_run:wait_cond(function()                                                   \
-        local info = box.info.replication[replica_id]                           \
-        local lsn = info.downstream.vclock[replica_id]                          \
-        return lsn and lsn >= replica_lsn                                       \
-end)                                                                            \
+        local lsn = box.info.replication[replica_id].downstream.vclock          \
+        return (lsn and lsn[replica_id] and lsn[replica_id] >= replica_lsn)     \
+    end) or box.info
+ | ---
+ | - true
+ | ...
 
 box.cfg{replication_synchro_quorum = 2}
  | ---
diff --git a/test/replication/gh-5195-qsync-replica-write.test.lua b/test/replication/gh-5195-qsync-replica-write.test.lua
index 2b9909e21..7843ad6c9 100644
--- a/test/replication/gh-5195-qsync-replica-write.test.lua
+++ b/test/replication/gh-5195-qsync-replica-write.test.lua
@@ -41,10 +41,9 @@ replica_id = test_run:get_server_id('replica')
 replica_lsn = test_run:get_lsn('replica', replica_id)
 test_run:wait_downstream(replica_id, {status='follow'})
 test_run:wait_cond(function()                                                   \
-        local info = box.info.replication[replica_id]                           \
-        local lsn = info.downstream.vclock[replica_id]                          \
-        return lsn and lsn >= replica_lsn                                       \
-end)                                                                            \
+        local lsn = box.info.replication[replica_id].downstream.vclock          \
+        return (lsn and lsn[replica_id] and lsn[replica_id] >= replica_lsn)     \
+    end) or box.info
 
 box.cfg{replication_synchro_quorum = 2}
 test_run:wait_cond(function() return f:status() == 'dead' end)
-- 
2.17.1