-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v8.7.1 transaction freeze #14949
Comments
Can you please provide a more complete repro script, like with how you're instantiating your model and where you're calling |
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days |
This issue was closed because it has been inactive for 19 days and has been marked as stale. |
I'm experiencing the same issue. We have a test suite in which we experience this issue but each test passes in isolation so the code is difficult to reproduce. Downgrading to 8.5.5 did solve the problem for me. I can share some debug logs. We do drop all our collections between each unit test. We use the mongodb driver to drop the collection (in the after each hook) and then use mongoose to start a session at which point the process seems to freeze. I'm trying to create a reproducible example.
|
@t1bb4r can you please provide some code samples that show exactly what you mean by "We use the mongodb driver to drop the collection (in the after each hook) and then use mongoose to start a session"? |
@vkarpov15 I was finally able to reproduce this issue after trying out mongoose 8.10. Here is a link to the code that I've been using to reproduce the issue, https://github.com/t1bb4r/mongoose-issue-14949/blob/main/test.js. In mongoose 8.10, instead of my tests freezing I got a new error "Connection operation buffering timed out after 10000ms". With this new error I noticed that manipulating the clock with sinon was the root cause of the problem. Adding sinon The shared test file results with different mongoose versions: After some investigation I suspect that these heartbeat changes do not play well with sinon fake timers, maybe this PR #14812? Now that I've finally started smelling the smoke I can investigate a bit further and will let you know if I find something. |
I think that I understand the issue a lot better now after some reading. I can explain the issue that I'm having by focusing on this piece of code:
In my case the test suites will run, and most tests will finish in under 30 seconds so heartbeat will be null for the full duration of the test and the issue will not appear. The issue only appears after the first heart beat sets the date, and then date is then modified by sinon causing it to be larger than At the end of the day it is not a mongoose issue, but it's difficult to manipulate the tests and timers to get this working. Could we opt out of this check in our testing environment since the connection is still alive? |
It is worth mentioning that we recommend not using That being said, the easiest way to work around this issue is to disable |
Prerequisites
Mongoose version
v8.7.1
Node.js version
20.16.0
MongoDB server version
Atlas Latest
Typescript version (if applicable)
5.6.3
Description
const session = await this.jobModel.db.startSession();
this code freezes on v8.7.1, but works fine on v8.5.1Steps to Reproduce
try to start session
Expected Behavior
no freezes
The text was updated successfully, but these errors were encountered: