MongoError: Given transaction number 60 does not match any in-progress transactions. The active transaction number is 59

Getting the above error with different transaction number but can be replicated.

I’ve read through the post Given transaction number does not match any in-progress transactions but the proposed solution isn’t working in our case as we have try … catch statements only in two places in our code:

  • at the point of entry (we’re using Meteor framework so it’s a method call, similar to an API endpoint)
  • at MongoDb UPDATE, INSERT and REMOVE commands

The error is indicated when we’re trying to commit a transaction at a function which is 1 level down from the entry point. This is the code that gets flagged:

if (mongoSession.transaction.state === 'TRANSACTION_IN_PROGRESS') {
        await mongoSession.commitTransaction();

It points to the commitTransaction.

Is there a way to get more information from MongoDb as to which transaction exactly is causing this error and maybe see which are the last committed transactions? It mentions 59 respective 60 transactions, it would be helpful to see them in any sort of way.