mongodb-erlang
mongodb-erlang copied to clipboard
Failure to start if list of replicaSet seeds needs to be resolved to hostnames
Hi,
We've encountered an issue in which if we provide a list of seeds as ip addresses, the application will fail to start. I believe this is because mongo will provide the list of nodes as hostnames, and it seems the application will try to reinitialise the seeds after a node's process has been killed (and a seed's process is killed because it is not contained on the list of servers returned by mongo).
Here's a stacktrace:
7:15:05.999 [error] GenServer #PID<0.8895.4> terminating
** (MatchError) no match of right hand side value: []
(mongodb) /examples/ex_collector/deps/mongodb/src/mongoc/mc_topology.erl:204: :mc_topology.parse_ismaster/4
(mongodb) /examples/ex_collector/deps/mongodb/src/mongoc/mc_topology.erl:145: :mc_topology.handle_cast/2
(stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:681: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:DOWN, #Reference<0.0.1.39789>, :process, #PID<0.8880.4>, {{:badmatch, []}, [{:mc_topology, :parse_ismaster, 4, [file: '/examples/ex_collector/deps/mongodb/src/mongoc/mc_topology.erl', line: 204]}, {:mc_topology, :handle_cast, 2, [file: '/examples/ex_collector/deps/mongodb/src/mongoc/mc_topology.erl', line: 145]}, {:gen_server, :try_dispatch, 4, [file: 'gen_server.erl', line: 615]}, {:gen_server, :handle_msg, 5, [file: 'gen_server.erl', line: 681]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}
State: {:state, 'localhost', 27018, :undefined, :rsSecondary, :undefined, [size: 1, max_overflow: 10, overflow_ttl: 0, overflow_check_period: :undefined], 20000, 100, #PID<0.8880.4>, #Reference<0.0.1.39789>, [pool_size: 1], [database: "dataloop_app_dev"], {:mc_server, #PID<0.8895.4>, #Reference<0.0.8.35576>, "localhost:27018", :rsSecondary, "localhost:27018", 1864, 1864, "foo", 10790, [], 0, 4, ["localhost:27017", "localhost:27018", "localhost:27019"], [], [], :undefined, "localhost:27017", false, true}, #PID<0.8897.4>, :undefined}
A good example of a use case that will cause this is running a mongo replica set under docker.
I have a commit that will prevent a seed from being reinitialised if it has been deleted: https://github.com/outlyerapp/mongodb-erlang/commit/f167e1357665682a3c92e246dcb29e2691103e1f
Is that a workable solution?
Thanks!
Hi, @alexdias I'll investigate it, thanks for the issue. I am in a process of refactoring mongoc and I'll pay attention to it.
I suffer the same. Hope you can solve it one day.
@alexdias and @Ami-Kawashima please try again from the latest master
now that #236 has merged. I think there's a good chance it fixed your problems too.