Running commands against un-initialized replica set

161 views
Skip to first unread message

Sam Weisberg

unread,
Jun 1, 2016, 1:41:20 PM6/1/16
to reacti...@googlegroups.com
Hi Guys,

I am trying to figure out how to run commands like serverStatus,
replSetInitiate and replSetGetStatus against a mongo cluster that has
not been initialized with a replica set.

The serverStatus command should return a proper result document whereas
the replSetGetStatus command should return a proper command error (code
94).

However, when I try using these with reactivemongo, I only and always
receive the error "The node set can not be reached! Please check your
network connectivity.".

It seams the actor system cannot properly initialize without an active
replica set, which in return I cannot initialize without a working
client.

Can someone please point out how to work around this issue to get these
command working as they should?

Thanks you kindly.

-- Sam

Cédric Chantepie

unread,
Jun 1, 2016, 1:44:04 PM6/1/16
to ReactiveMongo - http://reactivemongo.org
What's your code ?

Sam Weisberg

unread,
Jun 1, 2016, 3:05:19 PM6/1/16
to reacti...@googlegroups.com, Cédric Chantepie
On 2016-06-01 19:44, Cédric Chantepie wrote:
> What's your code ?

This is a simplified example:

implicit val context = scala.concurrent.ExecutionContext.global
val driver = MongoDriver()
val con = driver.connection(Seq("127.0.0.1:2708"))
val serverStatus =
Await.result(con.database("admin").flatMap(_.serverStatus),10.seconds)

I would expect the call to succeed (the server is up and running), but
instead I get

reactivemongo.core.actors.Exceptions$NodeSetNotReachable$:
MongoError['The node set can not be reached! Please check your network
connectivity.']
at
reactivemongo.core.actors.Exceptions$NodeSetNotReachable$.<clinit>(actors.scala)
at
reactivemongo.api.MongoConnection.reactivemongo$api$MongoConnection$$wait$1(api.scala:331)
at
reactivemongo.api.MongoConnection$$anonfun$reactivemongo$api$MongoConnection$$wait$1$2.applyOrElse(api.scala:359)
at
reactivemongo.api.MongoConnection$$anonfun$reactivemongo$api$MongoConnection$$wait$1$2.applyOrElse(api.scala:356)
at
scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
at
scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at
scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
at
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
at
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

I am using reactivemongo 0.11.11.


Kind regards,
-- Sam

Cédric Chantepie

unread,
Jun 2, 2016, 3:14:50 AM6/2/16
to ReactiveMongo - http://reactivemongo.org
I suggest you check the authentication.

Sam Weisberg

unread,
Jun 2, 2016, 4:00:33 AM6/2/16
to reacti...@googlegroups.com, Cédric Chantepie
On 2016-06-02 09:14, Cédric Chantepie wrote:
> I suggest you check the authentication.

There is no authentication required to against the Mongo, it is a local
test cluster (1 router, 1 config, 3 shards).
In addition, both commands work find one I initiate the replica set from
the Mongo cmd line.
Standard Mongo driver also works fine:

val client = new MongoClient("127.0.0.1", 27018)
val r = client.getDatabase("admin").runCommand(new
Document("serverStatus", 1))
println(r)


Kind regards,
-- Sam

Cédric Chantepie

unread,
Jun 2, 2016, 4:13:21 AM6/2/16
to ReactiveMongo - http://reactivemongo.org
The port between your codes is not the same.

Sam Weisberg

unread,
Jun 2, 2016, 4:37:54 AM6/2/16
to reacti...@googlegroups.com, Cédric Chantepie
On 2016-06-02 10:13, Cédric Chantepie wrote:
> The port between your codes is not the same.

True, sorry about that, I put that example together to quickly. It does
not however change the problem at all:

val host = "127.0.0.1"
val port = 27018

val client = new MongoClient(host, port)
val mgoStatus = client.getDatabase("admin").runCommand(new
Document("serverStatus", 1))

println(mgoStatus)


implicit val context = scala.concurrent.ExecutionContext.global
val driver = MongoDriver()
val con = driver.connection(Seq(s"$host:$port"))
val reactiveStatus =
Await.result(con.database("admin").flatMap(_.serverStatus),10.seconds)
println(reactiveStatus)


results in the same issue: http://paste.ubuntu.com/16916543/

-- Sam

Cédric Chantepie

unread,
Jun 2, 2016, 2:28:47 PM6/2/16
to ReactiveMongo - http://reactivemongo.org
Hard to reproduce. The unit tests don't report issue about that ( https://github.com/ReactiveMongo/ReactiveMongo/blob/master/driver/src/test/scala/admin.scala ).

Sam Weisberg

unread,
Jun 2, 2016, 3:40:25 PM6/2/16
to reacti...@googlegroups.com, Cédric Chantepie
Actually, the issue seems pretty reproducable.
I ran the tests against the following configurations:

.travis_scrips/beforeInstall.sh with MONGODB_VER="2_6" -> Tests pass
.travis_scrips/beforeInstall.sh with MONGODB_VER="3" -> Tests fail
fully installed mongo 3.2.6 cluster without initialized repl set ->
Tests fail
fully installed mongo 3.2.6 cluster with initialized repl set -> Tests
pass

Could be a mongo version issue, as it looks like your travis settings do
not include a config to actually run the tests against mongo3.

-- Sam



Cédric Chantepie

unread,
Jun 3, 2016, 4:07:51 AM6/3/16
to ReactiveMongo - http://reactivemongo.org
It does test against MongoDB 3.2.4, w/o issue.
Reply all
Reply to author
Forward
0 new messages