ai-automation-consultant / Failure Lab
Database Unique Constraint
Parallel sync workers collide while creating the same company row.
Category
database
Difficulty
standard
Last Run
none
Incident Brief
Diagnose the database error and describe a concurrency-safe fix.
Broken State
Two workers insert the same normalized domain instead of using an upsert.
Symptoms
- The error appears only under parallel load.
- The unique index is on normalized company domain.
Trace
db.error=P2002 unique constraint failed on Company_domain_key company.domain=example.com worker=sync-2