Skip to content

Commit

Permalink
storage: fix assertion failure in conn_manager
Browse files Browse the repository at this point in the history
conn_manager_collect_idle_conns is used in order to close connections,
which have not been used by a storage for a period of time. Currently,
it has an assertion, which checks, that node never connects to self.

However, storage establishes connection to self, e.g. during
downloading of bucket states for rebalancer. As this is expected
behavior, this commit deletes this assertion.

Closes #446

NO_DOC=bugfix
  • Loading branch information
Serpentian committed Nov 23, 2023
1 parent f386a77 commit 2cf393d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
33 changes: 33 additions & 0 deletions test/storage-luatest/auto_master_2_2_2_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,36 @@ test_group.test_noactivity_timeout_for_auto_master = function(g)
_G.bucket_gc_wait()
end, {g.replica_1_a:replicaset_uuid(), bid1, bid2})
end

test_group.test_conn_manager_connect_self = function(g)
vtest.cluster_rebalancer_enable(g)
t.assert_equals(vtest.cluster_rebalancer_find(g), 'replica_1_a')

g.replica_1_a:exec(function(uuid)
-- Create connections using rebalancer
local rebalancer = ivshard.storage.internal.rebalancer_service
ivtest.service_wait_for_new_ok(rebalancer,
{on_yield = ivshard.storage.rebalancer_wakeup})

-- Assert, that connection to self is created.
local replicaset = ivshard.storage.internal.replicasets[uuid]
ilt.assert_not_equals(replicaset.master, nil)

local old_timeout = ivconst.REPLICA_NOACTIVITY_TIMEOUT
ivconst.REPLICA_NOACTIVITY_TIMEOUT = 0.01
ifiber.sleep(ivconst.REPLICA_NOACTIVITY_TIMEOUT)
local conn_manager = ivshard.storage.internal.conn_manager_service
ivtest.service_wait_for_new_ok(conn_manager, {on_yield = function()
ivshard.storage.internal.conn_manager_fiber:wakeup()
end})
ilt.assert_equals(replicaset.master, nil)
ivconst.REPLICA_NOACTIVITY_TIMEOUT = old_timeout
end, {g.replica_1_a:replicaset_uuid()})

-- Check, that assert not fails
local err_msg = 'conn_manager_f has been failed'
t.assert_equals(g.replica_1_a:grep_log(err_msg), nil)

-- Cleanup
vtest.cluster_rebalancer_disable(g)
end
1 change: 0 additions & 1 deletion vshard/storage/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3659,7 +3659,6 @@ local function conn_manager_collect_idle_conns()
if c and replica.activity_ts and
replica.activity_ts + consts.REPLICA_NOACTIVITY_TIMEOUT < ts then
if replica == rs.master and rs.is_master_auto then
assert(rs ~= M.this_replicaset)
rs.master = nil
end
replica.conn = nil
Expand Down

0 comments on commit 2cf393d

Please sign in to comment.