Hello,
We recently updated from Meteor 3.0.3 to Meteor 3.2.2 and we found a bit of a worrying thing - every 30 seconds a new Mongo cursor is being created for OP Log tailing purposes and the old one is never closed on Mongo server side.
After a bit of an investigation I got to the part where I think I see two problems:
- first of all, promise returned by the Mongo driver’s cursor method
close
is ignored here: meteor/packages/mongo/asynchronous_cursor.js at 041c72520181905c56b0a0612d81d291bf60f6f5 · meteor/meteor · GitHub - secondly, there’s a race condition within the race condition, i.e. here: meteor/packages/mongo/asynchronous_cursor.js at 041c72520181905c56b0a0612d81d291bf60f6f5 · meteor/meteor · GitHub - the timeout may happen, but the
nextObjectPromise
is still trying to fetch data, which ends up throwing an error (MongoExpiredSessionError: Cannot use a session that has ended
), because we already start the closing procedure of the cursor, which sets the cursor toisDead
, and that breaks the retrieval of data by cursor’snext
method in the most inopportune moment possible, because that exception leads to stoppage of the cursor killing procedure, which means that the Mongo driver considers given cursor killed, but the actual kill command is never sent to Mongo
All in all this results in a new cursor being added to Mongo every 30s and it grows and grows and slowly kills the database, which makes the release unusable.
Now, I know that I am asking for trouble even with using the OPLog tailing, but we do not have time/resources to implement Redis OPLog currently so we’re stuck with OPLog tailing. In Meteor 3.0.3 everything worked correctly, because Mongo 4.17 driver had a completely different mechanism of cleaning up cursors and session management.
If more details are needed, I am happy to provide them.
Looking for advice on how to proceed (other than downgrading back to Meteor 3.0.3).