Description
When two users simultaneously accept each other's connection requests, duplicate connections are created in the database.
Steps to Reproduce
- User A sends connection request to User B
- User B sends connection request to User A
- Both users click "Accept" at nearly the same time
- Two connection records are created instead of one
Expected Behavior
Only one connection record should exist regardless of timing. Use database-level locking or atomic operations to prevent duplicates.
Root Cause
The �ccept_request view doesn't check for an existing accepted connection before creating a new one, and there's no database constraint or lock preventing race conditions.
Files to Fix
- linkup/network/views.py - Add select_for_update() in accept view, check for existing accepted connection
- linkup/network/models.py - Add unique constraint on (user, friend) pairs
- Run python manage.py makemigrations and migrate
Acceptance Criteria
Description
When two users simultaneously accept each other's connection requests, duplicate connections are created in the database.
Steps to Reproduce
Expected Behavior
Only one connection record should exist regardless of timing. Use database-level locking or atomic operations to prevent duplicates.
Root Cause
The �ccept_request view doesn't check for an existing accepted connection before creating a new one, and there's no database constraint or lock preventing race conditions.
Files to Fix
Acceptance Criteria