-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 5.0.19, 5.0.20, 5.0.21
-
Component/s: None
-
Environment:Windows 10 Enterprise 12H2
-
ALL
-
When running integration tests in a NodeJs project that integrates with mongoDB via mongoose I receive a timeout error after a short while because the mongoDB database that has been started with mongodb-memory-server crashed after an access violation error.
This is a copy of this issue I created on the mongodb-memory-server project https://github.com/nodkz/mongodb-memory-server/issues/798
It occurs with all v5 Versions of mongoDB and is fixed with v6.
Versions
- NodeJS: 16.20.2
- mongodb-memory-server-*: 8.15.1
- mongodb(the binary version): 5.0.20
- mongoose: 7.4.3
- system: Windows 10 Enterprise 12H2
package: mongo-memory-server
What is the Problem?
Testcases time out after 2000ms. The debug output of memory-server shows
Unhandled exception","attr":{"exceptionString":"(access violation)","addressString":"0x00007FF6215CC4D4
(full log below)
Mongod is started in mochaGlobalSetup with:
mongod = await MongoMemoryReplSet.create({ replSet: { count: 3, args: ['--notablescan'], }, binary: { version: '5.0.20', }, });
The error occurs consistently but not always in the same testmethod. But it can be traced back to a particular line in the code under test, which is:
await Promise.all(
task.countingScopes.map(countingScope => this._shelfStockLockDao.findOneAndDelete({
lock: countingScope.lock,
requester: countingScope.lockRequester,
outletId: countingScope.outletId
});
Commenting this code snippet resolves the error.
Also executing it in series resolves this error with:
for (const countingScope of task.countingScope) { await this._shelfStockLockDao.findOneAndDelete({ lock: countingScope.lock, requester: countingScope.lockRequester, outletId: countingScope.outletId }
Setting the option `writeConcern` to `1` also resolves the error but leads to other issues. As soon as `writeConcern` is `2, 3 or majority` the error occurs again.
`task.countingScope` is right now an array of length 3. Reducing it to length 2 also solves the issue.
Executing the tests agains a local cluster started with `run-rs` of the same version also resolves the error.
The only thing even close to the error I've found is https://github.com/Automattic/mongoose/issues/5376. An issue from 2017 and for mongoose v4 which recommends setting `useMongoClient`, an option which is the default by now.
Debug Output
I anonymized the debug output. If that leads to missing information please inform me and I'll fix it.
The file startup_debug.txt shows the debug output of mongodb-memory-server on startup
The file Error-output.txt shows the access violation error with the entire stacktrace