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

Does Fawn works with cluster environment? #31

Open
ghost opened this issue Nov 10, 2017 · 4 comments
Open

Does Fawn works with cluster environment? #31

ghost opened this issue Nov 10, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 10, 2017

Hi, I have a cluster with multiple instances of my node js server running the same application. Some are on different machines or even remotely distant to each other.
I read in your documentation that you specify that:

if you're running multiple apps connected to the same db, provide a string value for _collection that's unique to each app. Do this to avoid a situation where one app rolls back the unfinished transaction(s) of another app.

However, this will not work here because one server may crash and no other servers will look into that collection, so some transactions will remain blocked.

So, if i'm using the same collection for all my servers, and a server restart and call rollback, it could be that some unfinished transaction(s) of another servers get deleted.

did I understand correctly?

I could I solve the issue here?

What happens if I transaction get rolled back while it's running on the other server? does it just fail without compromise the database state? That could be acceptable even if suboptimal.

thanks!

@e-oj
Copy link
Owner

e-oj commented Nov 10, 2017

Good question. Yes, the issue with using the same collection is that another server's transactions could get deleted. In your case, you could use a different collection for each fork of the process and listen for an 'error' or 'exit' event on each of those forks. When one of those events occur, you can use the roller to rollback any "failed" transactions

@ghost
Copy link
Author

ghost commented Nov 10, 2017

Well, but the server could just explode 😂

What about having a "Roller" that run continuously on each server and check the transactions last update time.. if it's older than X (an options of the roller) it delete the transactions, otherwise it will try again later.
We could run this every 30 seconds or so (this too should be an options of the roller)

I guess even with X = 1000ms - 2000ms it should be long enough.

what do you think?

@e-oj
Copy link
Owner

e-oj commented Nov 10, 2017

😂😂 Just don't keep explosives near your servers. I like that idea though; I could make it part of the next update or would you like to work on this?

@xfg
Copy link

xfg commented Jan 20, 2018

This is dangerous to do rollbacks because this library is not acid compliant and isolation property from acid is not followed. Other parallel transactions see all intermediate changes which was done by current transaction even if it was not completed and they may did their changes which are based at this intermediate state. When we do the rollback to the previous state we do not consider this changes and thus may get incorrect data consistency after rollback.

Without acid isolation we have to do a compensating transaction not rollback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants