From 77ccb09c31257ed81e768c9a3611efc6715ac1f8 Mon Sep 17 00:00:00 2001 From: Alexander Turenko Date: Tue, 20 Oct 2026 16:43:45 +0200 Subject: [PATCH] test: fix flaky wait for a replica to follow The replica status check may get the `attempt to index field 'downstream' (a nil value)` error. The `downstream` field is added when the replica subscribes, a moment after registration in `_cluster`. The race in the check hits `200-master-replica.t`, `240-ro-on-disconnect.t` and `230-orphan-not-stalling-init.t`. A replica left running by a failed test may also fail the following tests. The race hits tarantool's integration workflow in CI from time to time. Drafted by an LLM, conducted and corrected by the commit author. --- t/230-orphan-not-stalling-init.t | 1 + t/tnt/init.lua | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/t/230-orphan-not-stalling-init.t b/t/230-orphan-not-stalling-init.t index d346ce19..c9eb5584 100755 --- a/t/230-orphan-not-stalling-init.t +++ b/t/230-orphan-not-stalling-init.t @@ -52,6 +52,7 @@ test:test('Check orphan mode not stalling queue', function(test) local attempts = 0 -- Wait for replica to connect. while box.info.replication[3] == nil or + box.info.replication[3].downstream == nil or box.info.replication[3].downstream.status ~= 'follow' do attempts = attempts + 1 diff --git a/t/tnt/init.lua b/t/tnt/init.lua index 94442523..f906409f 100644 --- a/t/tnt/init.lua +++ b/t/tnt/init.lua @@ -122,8 +122,11 @@ local function tnt_cluster_prepare(cfg_args) local attempts = 0 - -- Wait for replica to connect. - while box.info.replication[2] == nil or box.info.replication[2].downstream.status ~= 'follow' do + -- Wait for replica to connect. It is listed once it is registered in + -- _cluster, but has no downstream until it subscribes. + while box.info.replication[2] == nil or + box.info.replication[2].downstream == nil or + box.info.replication[2].downstream.status ~= 'follow' do attempts = attempts + 1 if attempts == 30 then error('wait for replica connection')