Hello!
We are having an issue when using (multiple) services and our nodejs mongodb driver, (^4.2.1),
is refusing to write after working for a while on a service. (if lucky, sometimes it goes straight to this strange issue).
mongo is not throwing any errors, but when checking the response of a call like this:
this.client = await MongoClient.connect(
this.connectionString,
{ maxPoolSize: 50 }
);
const { acknowledged, upsertedCount, modifiedCount, matchedCount } =
this.client.replaceOne({ _id: doc._id}, doc);
where doc is something like:
{ _id: "123", foo: "bar" }
It gives a response of:
{
acknowledged: true,
upsertedCount: 0,
modifiedCount: 0,
matchedCount: 1,
}
and (with confirming using a gui connected to the database), the document is not being updated.
I’ve tried looking at the documentation, but I cannot seem to find anything as to why this happens.
more context / info
- service A can have this bug (seemingly at random), while service B operates normally,
- both services are on the same version of mongo with the same code (the code is wrapped into a private library)
- both services can be working with the same document (potentially? at the same time (unlikely, but possible)) with different writes to that document (we know this is a potential race condition)