These are chat archives for Automattic/mongoose

Dec 2017
Dec 20 2017 12:44
Jenky W. Nolasco
Dec 20 2017 12:54

Good morning, everybody, I have a question:

I have an application that, when it starts, it creates a bunch of documents and saves them, then I have a service that queries those documents, pass the info to another app, gets the info modified and depending of the results, updates such documents, and the process repeats until finished. Everything works perfectly fine, up to the point where, after certain amount, mongoose stops working in the same way, it just doesn't update them at all. I have put a lot of console.logs all over the application to check that the functions with mongoose are going to be executed, and indeed they are going to, but this really had me googling on the internet for an answer...

Have you guys experienced this kind of behaviour before?

Juha Lindstedt
Dec 20 2017 13:16
Have you tried to set mongoose debug on?
Jenky W. Nolasco
Dec 20 2017 13:24
I am going to check that, so I specifically see what's going on. I'll be back and report results
Juha Lindstedt
Dec 20 2017 13:25
Jannis "Nexor" Betz
Dec 20 2017 17:11

Hi there,
any chance to update another property on update/save?'findOneAndUpdate', (doc) => {
  if (doc.count !== doc.things.length) {
    this.model.update({ _id: doc._id }, { $set: { count: doc.things.length } });

something like that?
courrently this gives me errors (Cannot read property 'update' of undefined) and I guess, i could run into an update-loop?

Andrew Lavers
Dec 20 2017 17:16

I have a question about autoReconnect (true) and bufferMaxEntries (-1). I've got an app using mongoose, pointing at a ReplSet, and have successfully tested the query queuing behavior during a primary failover (as described in this article

However, in production I occasionally see brief remote connection closures, producing a Error: read ECONNRESET at exports._errnoException MongoError. The connection is restored in seconds, however the affected queries do not get queued, and instead the web request fails.

Is query buffering supposed to work in these cases?

Am particularly curious about the comment at the end of the article from Elad Nava: "Scheduled replica set step-downs would cause outstanding queries to fail with "Could not locate any valid servers in initial seed list", "sockets closed", and "ECONNRESET" before additional queries would get buffered up even though bufferMaxEntries is correctly configured."
Andrew Lavers
Dec 20 2017 17:40
OK, in the end, I think I'm confusing two things: 1) buffering incoming queries during an outage and 2) failing queries that happen to be in flight the moment the connection is lost
I guess the follow-up question is what options could mongoose offer for catching and retrying failed queries?