-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
I had the following scenario:
- Gunicorn spawning more than one worker
- a slow running system because of a momentarily high CPU usage
- a user that attempts to log in for the first time since this middleware has been added to the project (and thus has no entry in the preventconcurrentlogins_visitor table) impatiently clicks login several times. So all those login attempts would run in parallel.
In such situations a race condition can occur and because of that, I got the following exception:
duplicate key value violates unique constraint "preventconcurrentlogins_visitor_user_id_key"
DETAIL: Key (user_id)=(385) already exists.
...
File "/opt/python3.9/lib/python3.9/site-packages/preventconcurrentlogins/middleware.py", line 39, in process_request
Visitor.objects.create(
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels