Mongodb-memory-server: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority

Created on 20 Aug 2020  路  12Comments  路  Source: nodkz/mongodb-memory-server

Versions

  • NodeJS: 12.18.2
  • mongodb-memory-server-*: 6.4.4
  • mongodb: 0.0.0
  • mongoose: 5.10.0
  • system: Debian 10

package: mongo-memory-server

What is your question?

Hey Guys,

since yesterday, I cant spin up a MongoMemoryServer instance anymore (without any code change from my side in the meantime). My use case pretty much boils down to unit tests with mongo-memory-server where im calling

const MongoFake = require('mongodb-memory-server');

describe('Some test', () => {
    var mongod;

    before(async() => {
        //Fake Database.
        mongod = new MongoFake.MongoMemoryServer();
        const mongoURL = await mongod.getUri();

         console.log("Establishing Database connection...");
         mongoose.connect(mongoURL, {
             useFindAndModify: true,
             useCreateIndex: true,
             useNewUrlParser: true,
             useUnifiedTopology: true,
         });

         mongoose.connection.once("open", () => {
             console.log("Connected to MongoDB!");
         }).on("error", (error) => {
             console.error(error);
         });
    });

    after(async () => {
        await mongoose.connection.close(function () {
            console.log('Mongoose connection closed');
        });

        // await mongod.stop();
    });

    it('some test case': async () => {
      //perform test
}

Problem is it fails already on the new MongoFake.MongoMemoryServer(); initialization. Running with debug option enabled, I am getting:

`` MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method: +0ms MongoMS:MongoMemoryServer - no running instance, callstart()` command +0ms
MongoMS:MongoMemoryServer Called MongoMemoryServer.start() method +1ms
MongoMS:MongoMemoryServer Starting MongoDB instance with following options: {"port":33331,"dbName":"0a7cb5d3-8942-4384-8da9-608938dadca5","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--7698-16DeV3jPVyV6","tmpDir":{"name":"/tmp/mongo-mem--7698-16DeV3jPVyV6"},"uri":"mongodb://127.0.0.1:33331/0a7cb5d3-8942-4384-8da9-608938dadca5?"} +4ms
MongoMS:MongoBinary MongoBinary options: {"downloadDir":"/home/max/DEV/pinplan-backend/node_modules/.cache/mongodb-memory-server/mongodb-binaries","platform":"linux","arch":"x64","version":"latest"} +0ms
MongoMS:MongoBinary MongoBinary: Mongod binary path: /home/max/DEV/pinplan-backend/node_modules/.cache/mongodb-memory-server/mongodb-binaries/latest/mongod +5ms
MongoMS:MongoInstance Mongo[33331]: Called MongoInstance._launchKiller(parent: 7698, child: 7709): +0ms
MongoMS:MongoBinary MongoBinary: Download lock removed +16ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T16:06:27.953Z"},"s":"I", "c":"CONTROL", "id":4788402, "ctx":"main","msg":"Lock-free reads is disabled."}
MongoMS:MongoInstance +33ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.954+02:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"main","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":10},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":10},"outgoing":{"minWireVersion":0,"maxWireVersion":10},"isInternalClient":true}}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.954+02:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
MongoMS:MongoInstance +1ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"W", "c":"ASIO", "id":22601, "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
MongoMS:MongoInstance +2ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
MongoMS:MongoInstance +0ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":7709,"port":33331,"dbPath":"/tmp/mongo-mem--7698-16DeV3jPVyV6","architecture":"64-bit","host":"debian-dev"}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.5.0-2765-gf1751ed","gitVersion":"f1751edffc6cfdb4b077760e44a37ebfc507798a","openSSLVersion":"OpenSSL 1.1.1d 10 Sep 2019","modules":[],"allocator":"tcmalloc","environment":{"distmod":"debian10","distarch":"x86_64","target_arch":"x86_64"}}}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"PRETTY_NAME=\"Debian GNU/Linux 10 (buster)\"","version":"Kernel 4.19.0-8-amd64"}}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.956+02:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"127.0.0.1","port":33331},"security":{"authorization":"disabled"},"storage":{"dbPath":"/tmp/mongo-mem--7698-16DeV3jPVyV6","engine":"ephemeralForTest"}}}}
MongoMS:MongoInstance +0ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"Location4939200: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority"}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":15000}}
MongoMS:MongoInstance +15ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"NETWORK", "id":20562, "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"-", "id":20520, "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784909, "ctx":"initandlisten","msg":"Shutting down the ReplicationCoordinator"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"SHARDING", "id":4784910, "ctx":"initandlisten","msg":"Shutting down the ShardingInitializationMongoD"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784911, "ctx":"initandlisten","msg":"Enqueuing the ReplicationStateTransitionLock for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"-", "id":4784912, "ctx":"initandlisten","msg":"Killing all operations for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"-", "id":4695300, "ctx":"initandlisten","msg":"Interrupted all currently running operations","attr":{"opsKilled":1}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"COMMAND", "id":4784913, "ctx":"initandlisten","msg":"Shutting down all open transactions"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784914, "ctx":"initandlisten","msg":"Acquiring the ReplicationStateTransitionLock for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"INDEX", "id":4784915, "ctx":"initandlisten","msg":"Shutting down the IndexBuildsCoordinator"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784916, "ctx":"initandlisten","msg":"Reacquiring the ReplicationStateTransitionLock for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"REPL", "id":4784917, "ctx":"initandlisten","msg":"Attempting to mark clean shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"NETWORK", "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"COMMAND", "id":4784923, "ctx":"initandlisten","msg":"Shutting down the ServiceEntryPoint"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"FTDC", "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784928, "ctx":"initandlisten","msg":"Shutting down the TTL monitor"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":4784930, "ctx":"initandlisten","msg":"Shutting down the storage engine"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"STORAGE", "id":20282, "ctx":"initandlisten","msg":"Deregistering all the collections"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"STORAGE", "id":22279, "ctx":"initandlisten","msg":"shutdown: removing fs lock..."}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"-", "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
MongoMS:MongoInstance {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":20565, "ctx":"initandlisten","msg":"Now exiting"}
MongoMS:MongoInstance +0ms
MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"I", "c":"CONTROL", "id":23138, "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
MongoMS:MongoInstance +0ms
MongoMS:MongoInstance Mongo[33331]: CLOSE: 100 +3ms
MongoMS:MongoInstance Mongo[33331]: [MongoKiller]: exit - [0,null] +2s


of which i found this line: 

MongoMS:MongoInstance Mongo[33331]: STDOUT: {"t":{"$date":"2020-08-20T18:06:27.971+02:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"Location4939200: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority"}}
```

interesting as its apparently the only error. I tried to use a different storage engine by passing that argument to the constructor (like in readme) but that seems to be ignored. Not sure if thats the cause of the issue though.

As I said the weird part is it used to work before and stopped out of the sudden.

PS: I realized this problem occuring on a cloud build agent and were only able to reproduce locally after clearing npm cache and deleting package-lock.json + node_modules but now it persists locally as well :D .

Thanks for any help!

question stale

Most helpful comment

After checking the available downloads, I think the v4.4-latest is stable, and it's working on both debian10 and debian9.2.

Therefore, I changed my "config.mongodbMemoryServer.version" from latest to v4.4-latest; now it's working on GitHub Actions.

All 12 comments

Same here.

Node: 14.5.0
Mongoose: 5.9.25
mongodb-memory-server: 6.6.1
Debian 10

"config": {
    "mongodbMemoryServer": {
        "version": "latest"
    }
}

My old localhost folder still work. But GitHub Actions doesn't work. It doesn't work when I cloned my repo into a new folder, either. However, nothing has changed in package*.json.

MongoMS:MongoInstance {"t":{"$date":"2020-08-21T00:33:09.823+08:00"},"s":"I", "c":"NETWORK", "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP Fa$
tOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
MongoMS:MongoInstance {"t":{"$date":"2020-08-21T00:33:09.824+08:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":112$
4,"port":35001,"dbPath":"/tmp/mongo-mem--11263-Zi9plOn1Ixi2","architecture":"64-bit","host":"penguin"}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-21T00:33:09.824+08:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"v$
rsion":"4.5.0-2765-gf1751ed","gitVersion":"f1751edffc6cfdb4b077760e44a37ebfc507798a","openSSLVersion":"OpenSSL 1.1.1d 10 Sep 2019","modules":[],"allocator":"tcmalloc","enviro$
ment":{"distmod":"debian10","distarch":"x86_64","target_arch":"x86_64"}}}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-21T00:33:09.824+08:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"na$
e":"PRETTY_NAME=\"Debian GNU/Linux 10 (buster)\"","version":"Kernel 5.4.48-06434-gd868196d13af"}}}
MongoMS:MongoInstance {"t":{"$date":"2020-08-21T00:33:09.824+08:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr"$
{"options":{"net":{"bindIp":"127.0.0.1","port":35001},"security":{"authorization":"disabled"},"storage":{"dbPath":"/tmp/mongo-mem--11263-Zi9plOn1Ixi2","engine":"ephemeralForTe$
t"}}}}
MongoMS:MongoInstance +5ms
MongoMS:MongoInstance Mongo[35001]: STDOUT: {"t":{"$date":"2020-08-21T00:33:09.867+08:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException i$
initAndListen, terminating","attr":{"error":"Location4939200: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern maj$
rity"}}
MongoMS:MongoInstance +40ms

Thats pretty much what happened here, too. I tried rolling back to 6.6.3 but that didnt help either- its probably some download or something that is supposed to happen during runtime and fails?

I think the problem is about the new release of mongodb.

I run ./node_modules/.cache/mongodb-memory-server/mongodb-binaries/latest/mongod --version on both the working and the non-working folder. The working one was 4.5.0-2289-ge1f9d52; the broken one was 4.5.0-2765-gf1751ed. I'm looking for an option to lock the mongodb version. But the problem is '4.4-latest' is not working on debian buster.

After checking the available downloads, I think the v4.4-latest is stable, and it's working on both debian10 and debian9.2.

Therefore, I changed my "config.mongodbMemoryServer.version" from latest to v4.4-latest; now it's working on GitHub Actions.

i would recommend to not use latest and pin an specific version, so that such errors not suddenly appear

Maybe this should be mentioned in #282

The same error happening to me on node:12 docker image

Is there still no solution for this problem? I just started up a project and when I turn on debug mode I get the exact same error.

MongoMS:MongoInstance Mongo[51761]: STDOUT: {"t":{"$date":"2020-09-17T08:17:43.159-05:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"Location4939200: Cannot initialize ephemeralForTest with 'enableMajorityReadConcern=true' as it does not support read concern majority"}}

the only fixes are:

  • change the engine (to wiredTiger)
  • disable that option
  • if version is latest, pin an more specific version

To disable majority read concern in jest-mongodb-config.js:

    instance: {
      dbName: 'jest',
      args: ['--enableMajorityReadConcern=false']
    }

Marking Issue as stale, will be closed in 7 days if no more activity is seen

Closing Issue because it is marked as stale

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hasezoey picture hasezoey  路  4Comments

hasezoey picture hasezoey  路  7Comments

khasburrahman picture khasburrahman  路  3Comments

baptLesta picture baptLesta  路  7Comments

alexandrulesi picture alexandrulesi  路  8Comments