Skip to content
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

Concurrency Control #5424

Closed
duncangroenewald opened this issue Jun 30, 2017 · 12 comments
Closed

Concurrency Control #5424

duncangroenewald opened this issue Jun 30, 2017 · 12 comments
Labels
new feature This change adds new functionality, like a new method or class
Milestone

Comments

@duncangroenewald
Copy link

Mongoose does not currently appear to support any form of concurrency control. So if two processes are concurrently performing updates then the last update overwrites any earlier updates. Perhaps someone could include timestamped updates in the feature list. Include the timestamp in the query predicate and fail the update if no update is performed.

@vkarpov15
Copy link
Collaborator

See comments on #4004 (comment) . We have support for plugins that do concurrency control, and are looking for community members willing to contribute plugins. Would you be willing to help?

@duncangroenewald
Copy link
Author

duncangroenewald commented Jul 6, 2017 via email

@marcospgp
Copy link

This is still a big issue for Mongoose

@vkarpov15
Copy link
Collaborator

@marcospgp there's a good plugin out there for this. Adding support for OCC is a one-liner with this plugin.

@marcospgp
Copy link

marcospgp commented Mar 6, 2019 via email

@vkarpov15
Copy link
Collaborator

@marcospgp why does it not seem up to your standards? Would it be helpful if we made this an officially supported plugin?

@marcospgp
Copy link

No, I believe using the version field is not a good idea when we can use updatedAt.

I would add an option called "optimisticallyConcurrentSave" that checks the updatedAt field, if present, on every save and if it is not the same as the document that is being attempted to be pushed to the database, throw a (descriptive) error.

It would help to add a guide to the docs that describes concurrency with mongoose or something along those lines.

@duncangroenewald
Copy link
Author

duncangroenewald commented Mar 11, 2019 via email

@lonix1
Copy link

lonix1 commented Mar 11, 2019

Being part of mongoose would be ideal, but an official plugin would be better than nothing (and that plugin linked above is a good start).

I realise many are scratching their heads and asking "what's all this fuss about concurrency... it doesn't matter to me"? But like so many others have commented here and elsewhere on StackOverflow and many blog posts over many years: how can any serious dbms or dbms driver not have controllable concurrency options?

We need this desperately. Any large system deals with this problem, it's not an edge case. It needs to be officially supported (not an unofficial plugin) to give peace of mind that our systems won't blow up one day because of API changes.

And thank you @vkarpov15 for being open to this discussion.

@vkarpov15 vkarpov15 reopened this Mar 18, 2019
@vkarpov15
Copy link
Collaborator

We'll look into adding more official support for this. For now, it will be a plugin, but whether we ship it with Mongoose or make it an officially supported plugin is open to debate.

I'd love to read some of the blog posts and stackoverflow discussions you mentioned @lonix1 , any links?

@vkarpov15 vkarpov15 added this to the 5.x Unprioritized milestone Mar 18, 2019
@lonix1
Copy link

lonix1 commented Mar 18, 2019

I didn't save them 😄 but they're there. There are all sorts of workarounds for concurrency control, and if memory serves, most of them link to the work done by that guy who made the plugin above, because that's the only widely used code so far. unless you want to roll your own, but I guess most people would be scared to do that for something so critical. and get it wrong

@eoin-obrien
Copy link

I'm rather late to the party here, but I'm the author of the OCC plugin mentioned above mongoose-update-if-current.

I've just added the option to use a timestamp-based strategy (i.e. with updatedAt) instead of a version-based strategy. It's something I've been meaning to get around to for a while, and it should be live on npm by the end of the week. Any additional feedback and/or criticism that could help improve would be appreciated as well.

@vkarpov15 If I can be of any assistance to you regarding OCC in Mongoose, I'd be more than happy to help out!

@vkarpov15 vkarpov15 added new feature This change adds new functionality, like a new method or class and removed plugin labels Jul 5, 2020
@vkarpov15 vkarpov15 modified the milestones: 5.x Unprioritized, 5.10 Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

No branches or pull requests

6 participants