﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29134	RelatedObjectDoesNotExist & Duplicate Key Exception Occurring Sporadically	Jason	nobody	"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?

"	Bug	closed	Database layer (models, ORM)	1.8	Normal	needsinfo	orm, database, RelatedObjectDoesNotExist, IntegrityError, duplicate key		Unreviewed	0	0	0	0	0	0
