-
Notifications
You must be signed in to change notification settings - Fork 238
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
Race condition for two requests in close proximity #71
Comments
I think this is the case in pretty much every single webapp. I'd really avoid putting things in the session where this is a real problem. |
@mephi42 has shown an interesting solution to this problems that covers most situations, however (in line with @ThiefMaster comment) I'm not convinced that this is a common enough issue for people to warrant significant changes and a new database structure that may not transition easily. I'd also be interested in the performance effects and concerned with the ease of administering when the data is so splintered (looking at sessions or cleaning up expired ones). Also it would only solve the issue for SQLAlchemy backend. Closing this for now as not planned, but will reopen if there is enough interest. It may be an opportunity for someone to create a high concurrency oriented fork and trailblaze. Closing as not planned at this stage. |
I spent the whole morning debugging an issue where submitting two requests in close proximity will cause a race condition in the flask-session extension.
I'm using the Redis session interface, but it might affect others as well.
Here is what happens:
E.g.
session['my_list'].append('foo')
andsession['my_list'].append('bar')
This is roughly what happens in Redis:
GET session:123 -> []
GET session:123 -> []
SETEX session:123 [foo]
SETEX session:123 [bar]
This is what should happen:
GET session:123 -> []
SETEX session:123 foo
GET session:123 -> [foo]
SETEX session:123 [foo, bar]
The text was updated successfully, but these errors were encountered: