Mongoose: Upgrade issue : Transaction numbers are only allowed on storage engines that support document-level locking

Created on 13 Sep 2019  路  7Comments  路  Source: Automattic/mongoose

bug*?

What is the current behavior?

After installing this morning the new version 5.7.0 (from 5.6.13) i'm now getting the following error on a until now perfectly working system

Transaction numbers are only allowed on storage engines that support document-level locking

must be linked to use MongoDB driver 3.3.x for MongoDB 4.2 support #8083 #8078

has this upgrade of the driver been tested ?

underlying library issue

Most helpful comment

Yep - 3.7.x upgrades the the driver and turns on retryWrites automatically. Add ?retryWrites=false to end of connection string and you are square.

Ticket can be closed i think?

All 7 comments

Having a similar issue. Just had to roll a production server back on mLabs.

Seems to be a backwards compatability with the 3.6.X on the 5.7.0 release

Feedback from mlabs. So, the driver is kicking it on automatically and you need to toggle it off in the connection string.

That error message is the indication of a version incompatibility on the storage engine. WiredTiger supports document-level locking, whereas MMAPv1 does not.

The most recent versions of drivers have been enabling retryable reads and writes by default, which can introduce these errors on deployments still using MMAPv1 since these features require the transaction numbers that are only available on WiredTiger.

Could you try disabling retryable writes and see if this resolves the issue?

Yep - 3.7.x upgrades the the driver and turns on retryWrites automatically. Add ?retryWrites=false to end of connection string and you are square.

Ticket can be closed i think?

We'll look into this and see if there's something we can do to improve this. This does seem like a surprising backwards breaking change - I have a few apps that still use mmapv1 in production...

I've confirmed that this is an issue. Given the below script connecting to a replica set running mmapv1:

const mongoose = require('mongoose');

run().catch(err => console.log(err));

async function run() {
  await mongoose.connect('mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs', { useNewUrlParser: true, useUnifiedTopology: true });
  await mongoose.connection.dropDatabase();

  const Model = mongoose.model('Test', mongoose.Schema({ name: String }));

  await Model.create({ name: 'foo' });
  await Model.findOne();

  console.log('done');
}

I get the below error message:

MongoError: This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.

I've reached out to the mongodb driver team via email to see what's going on with this. In the meantime, setting retryWrites=false in the connection string is the way to fix this.

Did they respond back with a solution?

@LukeXF their response was to just disable retryWrites in the connection string. The rationale is that this change is to aid users of Atlas, which doesn't support mmapv1.

Was this page helpful?
0 / 5 - 0 ratings