0

Have successfully used the play (2.3.8) reactive Scala sample code to connect and create/read from mongo instance but cannot shake LastError which haunts me as I initially misconfigured host name. Enabling debugging: logger.reactivemongo=DEBUG shows details:

[debug] r.c.a.MongoDBSystem - received a checked write request                          
[debug] r.api.Failover - Got an error, retrying... (try #1 is scheduled in 500 ms)      
reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$: MongoError['No primary node is available!']
        at reactivemongo.core.actors.Exceptions$PrimaryUnavailableException$.<clinit>(actors.scala) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]
        at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]  
        at reactivemongo.core.actors.MongoDBSystem$$anonfun$pickChannel$4.apply(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]  
        at scala.Option.getOrElse(Option.scala:120) ~[scala-library-2.11.4.jar:na]                                                                           
        at reactivemongo.core.actors.MongoDBSystem.pickChannel(actors.scala:508) ~[reactivemongo_2.11-0.10.5.0.akka23.jar:0.10.5.0.akka23]                   
[debug] r.c.a.MongoDBSystem - ConnectAll Job running... Status: Node[wengen:27017: Unknown (1/10 available connections), latency=0], auth=Set()              
[debug] r.c.a.MongoDBSystem - ConnectAll Job running... Status: Node[wengen:27017: Unknown (1/10 available connections), latency=0], auth=Set()              
[debug] r.c.a.MongoDBSystem - ConnectAll Job running... Status: Node[wengen:27017: Unknown (1/10 available connections), latency=0], auth=Set()              
[debug] r.c.a.MongoDBSystem - ConnectAll Job running... Status: Node[wengen:27017: Unknown (1/10 available connections), latency=0], auth=Set()              
[info] r.c.a.MongoDBSystem - The node set is now available                                                                                                   
[info] r.c.a.MongoDBSystem - The primary is now available                                                                                                    
[debug] r.c.a.MonitorActor - set: a primary is available                                                                   

and the insert of the POST is fine but for this lastError:

[debug] r.c.a.MongoDBSystem - Sending request expecting response Request(3001,0,Insert(0,playdb.newpersons),BufferSequence(DynamicChannelBuffer(ridx=0, widx=60, cap=64),WrappedArray()),reactivemongo.api.ReadPreference$Primary$@47979aa3,None) by connection Connection([id: 0xedfcbc47, /192.168.15.46:55680 => wengen/192.168.15.67:27017],Connected,Set(),None) of node wengen:27017                                                                                                                                                                                    
[debug] r.c.a.MongoDBSystem - Got a response from -302203833! Will give back message=Response(MessageHeader(110,45,3001,1),Reply(8,0,0,1),LittleEndianHeapChannelBuffer(ridx=36, widx=110, cap=110),ResponseInfo(-302203833)) to promise scala.concurrent.impl.Promise$DefaultPromise@bd0cdcc                                                                                       
[debug] r.c.a.MongoDBSystem - {3001} it's a getlasterror                                                                                                                                  
[debug] application - Successfully inserted with LastError: reactivemongo.core.commands.LastError: DatabaseException['empty lastError message']     

db.resetError() in mongo does not get rid of this. Inserts are confirmed from collection. Code is here: https://github.com/nanothermite/playrctmongo

Any suggestions?

styvane
  • 59,869
  • 19
  • 150
  • 156

2 Answers2

2

Override in logback with:

<logger name="reactivemongo.api.Failover2">
    <level value="INFO"/>
</logger>

<logger name="reactivemongo.core.actors">
    <level value="INFO"/>
</logger>

This will silence only the abusive DEBUG messages of reactivemongo

1

As indicated by the [debug] and [info] prefixes, that are not errors.

That's a verbose logging from the ReactiveMongo driver when it's managing the connection pool and the replicaset.

The logging level can be set to WARNING to suppress such messages.

cchantep
  • 9,118
  • 3
  • 30
  • 41