Start a new topic

Inconsistent collectionAccess query inside of custom endpoint. Returning null with "Error: No repli

When querying the "user" collection using collectionAccess inside of a custom endpoint, the query occasionally (every 5-10 queries) returns null and produces the following error:



"Error: No replica set primary available for query with ReadPreference PRIMARY"



Sample code that produces this error:



function onRequest(request, response, modules){



// Module instances

var collectionAccess = modules.collectionAccess,

logger = modules.logger,

username = request.username,



collectionAccess.collection("user").findOne({"username":username}, function(err, requestingUser){

if (err){

logger.info(err);

response.error("query failed:" + err);

} else if (!requestingUser) {

response.error("didn't find user, no error");

} else {

response.body = requestingUser;

response.complete();

}

});

}



To clarify - When querying with identical parameters, this error only occurs every few attempts. Can somebody provide some insight?



Thank you.

This is a occurring issue in our backend. I am surprised you see it as often as you mention, last time I looked it was at around 1% of all requests. We are doing some architectural improvements over the next few weeks that would eliminate it. I agree it is annoying, and we are working hard to get rid of it. In the meantime, you could add retry logic either in BL or in your app, because retries succeed, and this happens only on reads, so it's safe to retry.
I'm seeing the same problem. On some operations it's at about 10-20% of operations and users are complaining. What's the status on fixing this?



Retrofitting all of our BL with retry logic is a bit daunting and I'd like to avoid it if possible.



thx

We are working on it, but a full elimination of the problem requires reworking some of the deeper layers of the platform. By the end of the month max.
Is there an update on this? This problem is still very prevalent. I am sometimes having to retry the request up to 5 times for it to succeed.
This was resolved as of several days ago.
Login or Signup to post a comment