Opened 7 years ago

Closed 7 years ago

#29134 closed Bug (needsinfo)

RelatedObjectDoesNotExist & Duplicate Key Exception Occurring Sporadically

Reported by: Jason Owned by: nobody
Component: Database layer (models, ORM) Version: 1.8
Severity: Normal Keywords: orm, database, RelatedObjectDoesNotExist, IntegrityError, duplicate key
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

We are using multi-table inheritance and occasionally we'll get a RelatedObjectDoesNotExist or a IntegrityError: duplicate key value violates unique constraint.

  • Our site is active, and we successfully generate at least 10,000 new related objects per day with no issues.
  • Our primary keys are auto-value ints that are up to approximately 200 million.
  • We previously saw these errors once every 100 days, but lately we're seeing it twice a week, and our code hasnt changed much in the last few months; no new apis, model changes, etc.
  • Our multi-table inheritance is only one-level (our model has a parent object, and about 8 inherited objects), where we perform many adds and deletes. Nowhere in our codebase do we create or delete parent objects - we always work on the inherited objects.
  • Other objects that do not use multi-table inheritance have never had an issue with duplicate keys.
  • We use django 1.8, PostgreSQL 9.5.10, Ubuntu 16.04; the db & webserver run on the same machine with 12 cores, 48gb of memory

Is there an existing bug we are unaware of? Why would we get duplicate keys and RelatedObjectDoesNotExist only occasionally?

Change History (1)

comment:1 by Tim Graham, 7 years ago

Resolution: needsinfo
Status: newclosed
Type: UncategorizedBug

Please use the ticket tracker for reporting confirmed bugs (with steps to reproduce). You could ask this question on our support channels although I'm doubtful someone will have some magical insight.

Perhaps it's worth pointing out that Django 1.8 is fairly old by now and security support ends on April 1. I think you're slightly more likely to get some help if you're running a current version of Django to rule out the possibility that the issue isn't fixed by now (if it's indeed a bug in Django and not some other problem).

Note: See TracTickets for help on using tickets.
Back to Top