if replica == rs.master and rs.is_master_auto then
assert(rs ~= M.this_replicaset)
rs.master = nil
end
the assert is not needed. It was for checking that the node never establishes connection to self. But it can actually happen. For example, the rebalancer asks all masters for data via iproto, including self if it is running on master. This is not perf critical anyway.
The patch should
Drop the assert;
Add a test (in the test the noactivity timeout constant could be decreased to a few milliseconds for speed);
Make sure the errors from service functions are propagated. The error was so hard to debug, because each <service>_f function wraps its functional part info pcall and never raises the returned error. This needs to be done for all services:
local function conn_manager_f()
assert(not M.conn_manager_service)
local service = lservice_info.new('conn_manager')
M.conn_manager_service = service
local ok, err = pcall(conn_manager_service_f, service)
assert(M.conn_manager_service == service)
M.conn_manager_service = nil
In its code
the assert is not needed. It was for checking that the node never establishes connection to self. But it can actually happen. For example, the rebalancer asks all masters for data via iproto, including self if it is running on master. This is not perf critical anyway.
The patch should
<service>_f
function wraps its functional part infopcall
and never raises the returned error. This needs to be done for all services: