Error code

DB_CONSTRAINT_VIOLATION

Database constraint violated

  • HTTP status409
  • Classprogrammer
  • Severityerror
  • Retryableno

Database constraint violated

INSERT or UPDATE violated a UNIQUE / FK / NOT NULL / CHECK constraint. Indicates a bug in the caller, not infrastructure.

Common causes

  • Race condition created duplicate key.
  • Caller didn’t check FK target existed first.
  • Required field omitted by a partial update path.

What to do

Fix the caller. Wrap inserts in upsert/onDuplicate logic where the duplicate is benign.

הפרת אילוץ במסד הנתונים

INSERT/UPDATE הפר אילוץ UNIQUE / FK / NOT NULL / CHECK. מצביע על באג בקורא, לא בתשתית.

סיבות נפוצות

  • Race יצר מפתח כפול.
  • הקורא לא בדק קיום היעד של FK.
  • שדה חובה הושמט בנתיב עדכון חלקי.

פעולה מומלצת

תקנו את הקורא. עטפו insert ב־upsert במקרה שהכפל לגיטימי.