Skip to content

Commit efa0be0

Browse files
committed
storage: disable alerts for non vshard replicas
Before this patch vshard throwed alerts for replicas, which are not in its config. E.g. disconnected CDC replica caused `UNREACHABLE_REPLICA` alert. This patch fixes it by skipping unknown replicas. Closes tarantool#493 NO_DOC=bugfix
1 parent adb1a50 commit efa0be0

File tree

3 files changed

+79
-1
lines changed

3 files changed

+79
-1
lines changed

test/storage-luatest/persistent_names_test.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,32 @@ test_group.test_no_unreachable_replica_alert = function(g)
136136
asserts:assert_server_no_alerts(g.replica_2_a)
137137
persistent_names_restore(g, names)
138138
end
139+
140+
--
141+
-- gh-493: vshard should not show alerts for replicas, which are not in the
142+
-- vshard's config.
143+
--
144+
test_group.test_alerts_for_named_replica = function(g)
145+
t.run_only_if(vutil.feature.persistent_names)
146+
147+
local named_replica = server:new({
148+
alias = 'named_replica_with_name_identification',
149+
box_cfg = {
150+
replication = g.replica_1_a.net_box_uri,
151+
instance_name = 'named_replica'
152+
}
153+
})
154+
155+
named_replica:start()
156+
named_replica:wait_for_vclock_of(g.replica_1_a)
157+
asserts:assert_server_no_alerts(g.replica_1_a)
158+
local instance_id = named_replica:instance_id()
159+
160+
named_replica:stop()
161+
asserts:assert_server_no_alerts(g.replica_1_a)
162+
163+
named_replica:drop()
164+
g.replica_1_a:exec(function(id)
165+
box.space._cluster:delete(id)
166+
end, {instance_id})
167+
end

test/storage-luatest/storage_1_test.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
local t = require('luatest')
22
local vtest = require('test.luatest_helpers.vtest')
33
local vutil = require('vshard.util')
4+
local server = require('test.luatest_helpers.server')
5+
local asserts = require('test.luatest_helpers.asserts')
46

57
local group_config = {{engine = 'memtx'}, {engine = 'vinyl'}}
68

@@ -588,3 +590,47 @@ test_group.test_moved_buckets_various_statuses = function(g)
588590
_G.bucket_gc_continue()
589591
end)
590592
end
593+
594+
--
595+
-- gh-493: vshard should not show alerts for replicas, which are not
596+
-- in the vshard's config.
597+
--
598+
local function test_alerts_for_non_vshard_config_template(replicaset, replica)
599+
replica:start()
600+
replica:wait_for_vclock_of(replicaset.replica_1_a)
601+
asserts:assert_server_no_alerts(replicaset.replica_1_a)
602+
local id = replica:instance_id()
603+
604+
replica:stop()
605+
asserts:assert_server_no_alerts(replicaset.replica_1_a)
606+
607+
replica:drop()
608+
replicaset.replica_1_a:exec(function(id)
609+
box.space._cluster:delete(id)
610+
end, {id})
611+
end
612+
613+
test_group.test_alerts_for_unnamed_replica = function(g)
614+
local non_config_replica = server:new({
615+
alias = 'non_config_replica',
616+
box_cfg = {
617+
replication = g.replica_1_a.net_box_uri,
618+
}
619+
})
620+
621+
test_alerts_for_non_vshard_config_template(g, non_config_replica)
622+
end
623+
624+
test_group.test_alerts_for_named_replica = function(g)
625+
t.run_only_if(vutil.feature.persistent_names)
626+
627+
local non_config_replica = server:new({
628+
alias = 'non_config_replica',
629+
box_cfg = {
630+
replication = g.replica_1_a.net_box_uri,
631+
instance_name = 'named_replica'
632+
}
633+
})
634+
635+
test_alerts_for_non_vshard_config_template(g, non_config_replica)
636+
end

vshard/storage/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4003,7 +4003,10 @@ local function storage_info(opts)
40034003
local id = box.info.id
40044004
for _, replica in pairs(box.info.replication) do
40054005
-- Alerts for other replicas.
4006-
if id ~= replica.id then
4006+
if id ~= replica.id and (
4007+
M.this_replicaset.replicas[replica.name] ~= nil or
4008+
M.this_replicaset.replicas[replica.uuid] ~= nil
4009+
) then
40074010
replica_count = replica_count + 1
40084011
if replica.downstream == nil or
40094012
replica.downstream.vclock == nil then

0 commit comments

Comments
 (0)