0

I have configured RestHeart to get data from MongoDB. Requests that involve String, Object, Number work well and return the same results than if I use a client to query the MongoDB (RoboMongo, MongoDB Compass...). However requests that involved Date data type take longer than with MongoDB clients and Nginx closes the connection after 60s (the same query with a client takes 0.163s)

## Query in a MongoDB client
db.getCollection('collection').find({"DATE_A_FMT": {'$gte':ISODate('2017-02-21T05:00:00.000Z')}})

## Request with RestHeart
https://IP/DB/collection/?filter={'DATE_A_FMT': {'$gte':{'$date':'2017-02-20T05:00:00.000Z'}}}

The collection has an index for DATE_A_FMT field that is used when the query is executed with a client. In addition, I have tried to add sorting but I have the same result.

The configuration of RestHeart is the same as the default configuration in the documentation with the difference of the connection to MongoDB. In this case I use a cluster with 3 instances (1 Master and 2 slaves). Furthermore the RestHeart log file shows all the request that are executed except these requests so I can't see what happen with them.

Any suggestion in order to discover what and where is the issue with this queries? Thanks in advance.

  • What are the expected number of result documents for those queries? You should be careful that Robomongo doesn't fool you since it will only get the first 50 results by default... – dnickless Sep 28 '17 at 19:33
  • @dnickless I added pagesize parameter to RestHeart request but I got the same result. – J. Morales Sep 28 '17 at 20:02
  • https://stackoverflow.com/questions/15204341/mongodb-logging-all-queries – dnickless Sep 28 '17 at 20:23
  • Also, I noticed that - at least in your sample queries above you have different dates between the two calls (one day different, 21 vs 20)... – dnickless Sep 28 '17 at 20:24
  • @dnickless good eyesight, it was just that I tried with different dates but I have tried with the same date in both cases. – J. Morales Sep 28 '17 at 20:34
  • @dnickless RestHeart log is in debug mode and this request is not logged in that file. However other request that doesn't involve dates as unique filter are logged. – J. Morales Sep 28 '17 at 20:45
  • So you're saying the MongoDB log does not show any signs of this query even hitting the MongoDB server? Do you perhaps have some kind of a caching issue here? – dnickless Sep 28 '17 at 20:51
  • @dnickless I don't think so because all other queries work well and they are logged. Only requests that filter only by dates fails even if that field has an index. I have executed queries that filter by other fields plus this date fields and they works well. – J. Morales Oct 02 '17 at 15:13
  • Weird... I would try ruling out all potential sources of funkiness step by step as in: 1. reduce the number of documents in your database to one. 2. get rid of all fields except the one that you're filtering on. 3. Change the name of the field you're filtering on to something trivial. And so on... Also, I would turn on any logging that I possibly could, e.g.: https://softinstigate.atlassian.net/wiki/spaces/RH/pages/9207845/Advanced+Configuration#AdvancedConfiguration-Logging And lastly, I would try upgrading all components to the latest version and see if the issue still happens. – dnickless Oct 02 '17 at 15:19

0 Answers0