Bug 1314042

Summary: When repeatedly importing a manifest a foreign key constraint sometimes occurs
Product: [Community] Candlepin Reporter: Barnaby Court <bcourt>
Component: candlepinAssignee: pjonasti
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: low Docs Contact:
Priority: low    
Version: 2.0CC: dsarman, pjonasti, vrjain
Target Milestone: ---Keywords: Triaged
Target Release: 2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: candlepin-2.0.22-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-01-20 12:23:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1194565    

Description Barnaby Court 2016-03-02 19:20:01 UTC
When repeatedly importing manifests sometimes a foreign key constraint error occurs. 

Please see the downstream bug for the log files. 

The relevant entries in the foreman debug are:
        at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:996) ~[hibernate-entitymanager-4.2.5.Final-redhat-1.jar:4.2.5.Final-redhat-1]
        at org.candlepin.model.AbstractHibernateCurator.flush(AbstractHibernateCurator.java:364) ~[AbstractHibernateCurator.class:na]
        at org.candlepin.model.AbstractHibernateCurator.save(AbstractHibernateCurator.java:359) ~[AbstractHibernateCurator.class:na]
        at org.candlepin.model.AbstractHibernateCurator.create(AbstractHibernateCurator.java:112) ~[AbstractHibernateCurator.class:na]
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58) ~[guice-persist-3.0-redhat-1.jar:3.0-redhat-1]


and
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "cp_subscription" violates foreign key constraint "fk_sub_branding_sub_id" on table "cp_sub_branding"
  Detail: Key (id)=(8aa2a3e44ba4ec4e014ba4f83d320058) is still referenced from table "cp_sub_branding".

Comment 1 Barnaby Court 2016-03-03 21:05:13 UTC
This is likely a timing issue on manifest delete & import. Someone needs to go though the manifest import & delete code to validate why this is happening and figure out the path to prevent it.

Comment 2 Barnaby Court 2017-01-18 18:01:15 UTC
*** Bug 1338951 has been marked as a duplicate of this bug. ***