Can't save() the same doc multiple times in parallel.

1,618 views
Skip to first unread message

Tom Krones

unread,
Sep 10, 2018, 7:12:00 PM9/10/18
to mongodb-user
I just migrated my app from a mongodb db that I was hosting on my digital ocean server to the free account on mongodb.com atlas.  As soon as I switched over (without changing the code) I started getting this error:

Can't save() the same doc multiple times in parallel.

I was able to comment out some code and it's working ok now but I'm wondering why my server didn't have that issue?  Are the free servers too slow for what I'm doing?  Is it a setting I could change?  

Thanks,
Tom

Kevin Adistambha

unread,
Sep 11, 2018, 12:27:49 AM9/11/18
to mongodb-user

Hi Tom

Can’t save() the same doc multiple times in parallel.

That error was generated by mongoose, where it was committed to the code on this pull request: https://github.com/Automattic/mongoose/pull/6511. Apparently it was created to fix bugs 6456 and 4064. The full history and discussion about the cause can be seen in the two linked mongoose issues.

I was able to comment out some code and it’s working ok

Could you elaborate what you did to avoid the error? Does the code still behave like you expect it to after this change?

Are the free servers too slow for what I’m doing? Is it a setting I could change?

I’m not sure if there’s any setting you could change since the error was generated by mongoose. I would think that the best way to avoid this error is to address the underlying issue, which is apparently the code trying to save different versions of one document at the same time.

Best regards,
Kevin

Kevin Adistambha

unread,
Sep 11, 2018, 1:55:59 AM9/11/18
to mongodb-user

Hi Tom

In addition, could you try upgrading your mongoose to the latest version? There appears to be an issue 6611 that was fixed in newer mongoose version.

Best regards
Kevin

Tom Krones

unread,
Sep 11, 2018, 6:31:14 PM9/11/18
to mongodb-user
Hi Kevin,

Thanks for the response.  I saw the same bug report and was already using the latest version of mongoose.  I ended up downgrading to 5.0.4 and everything is working again.  Do you think it's my code causing that issue if it's working on an older version or a bug with mongoose?  Maybe with the new version of mongoose there is some unnecessary delay in the write process?  I'm hoping it's just still a bug because I'm really not sure how I would try to fix the timing of my writes.  :/

To answer your question.  I originally commented out the code that was causing the issue (luckley it wasn't critical to the app) and it fixed it.  I was later able to downgrade and include the original code again.

PS.  In my frantic attempts to fix things I ended up upgrading to M10 and the tools you guys offer are really great, thanks!

Tom
Reply all
Reply to author
Forward
0 new messages