Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 985444

Summary: Runtime error from Candlepin while adding large number of hosts
Product: [Retired] Subscription Asset Manager Reporter: Vitaly Kuznetsov <vkuznets>
Component: candlepinAssignee: Tom McKay <tomckay>
Status: CLOSED ERRATA QA Contact: Og Maciel <omaciel>
Severity: high Docs Contact:
Priority: unspecified    
Version: 1.3CC: dgoodwin, sthirugn, tomckay
Target Milestone: rc   
Target Release: 1.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 995942 (view as bug list) Environment:
Last Closed: 2013-10-01 11:12:13 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:
Embargoed:
Bug Depends On:    
Bug Blocks: 833466, 995942    

Description Vitaly Kuznetsov 2013-07-17 13:45:32 UTC
Description of problem:
After adding large number of systems (955) in katello I got the following error from it:
ServerRequestError: (400, {u'displayMessage': u'Runtime Error detached entity passed to persist: org.candlepin.model.ConsumerInstalledProduct at org.hibernate.event.def.DefaultPersistEventListener.onPersist:102', u'errors': [u'Runtime Error detached entity passed to persist: org.candlepin.model.ConsumerInstalledProduct at org.hibernate.event.def.DefaultPersistEventListener.onPersist:102']}, None)

The stack trace in /var/log/tomcat6/catalina.out looks like this:

Jul 17 09:19:42 [http-8443-5] ERROR org.candlepin.exceptions.mappers.CandlepinExceptionMapper - Runtime Error detached entity passed to persist: org.candlepin.model.ConsumerInstalledProduct at org.hibernate.event.def.DefaultPersistEventListener.onPersist:102
org.hibernate.PersistentObjectException: detached entity passed to persist: org.candlepin.model.ConsumerInstalledProduct
	at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:102)
	at org.hibernate.impl.SessionImpl.firePersistOnFlush(SessionImpl.java:672)
	at org.hibernate.impl.SessionImpl.persistOnFlush(SessionImpl.java:664)
	at org.hibernate.engine.CascadingAction$9.cascade(CascadingAction.java:346)
	at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292)
	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240)
	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
	at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:320)
	at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:266)
	at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:243)
	at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
	at org.hibernate.engine.Cascade.cascade(Cascade.java:154)
	at org.hibernate.event.def.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:154)
	at org.hibernate.event.def.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:145)
	at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:88)
	at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
	at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:997)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1590)
	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306)
	at org.candlepin.model.ConsumerCurator.getHost(ConsumerCurator.java:377)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:58)
	at org.candlepin.resource.ConsumerResource.checkForGuestsUpdate(ConsumerResource.java:937)
	at org.candlepin.resource.ConsumerResource.performConsumerUpdates(ConsumerResource.java:756)
	at org.candlepin.auth.interceptor.SecurityInterceptor.invoke(SecurityInterceptor.java:109)
	at org.candlepin.resource.ConsumerResource.updateConsumer(ConsumerResource.java:732)
	at org.candlepin.auth.interceptor.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66)
	at sun.reflect.GeneratedMethodAccessor330.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155)
	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222)
	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211)
	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:525)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:502)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:263)
	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:178)
	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:91)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:62)
	at org.candlepin.servlet.filter.ContentTypeHackFilter.doFilter(ContentTypeHackFilter.java:58)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
	at org.candlepin.servlet.filter.logging.LoggingFilter.doFilter(LoggingFilter.java:60)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
	at org.candlepin.servlet.filter.CandlepinPersistFilter.doFilter(CandlepinPersistFilter.java:48)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
	at org.candlepin.servlet.filter.CandlepinScopeFilter.doFilter(CandlepinScopeFilter.java:57)
	at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Thread.java:722)


Version-Release number of selected component (if applicable):
candlepin-tomcat6-0.8.17-1.el6.noarch
katello-candlepin-cert-key-pair-1.0-1.noarch
katello-glue-candlepin-1.4.2-1.git.846.c3e1652.el6.noarch
candlepin-0.8.17-1.el6.noarch

How reproducible:
Once

Steps to Reproduce:
1. Try creating large number of systems via katello api

Actual results:
Stack trace

Expected results:
Systems created normally

Additional info:

Comment 3 Devan Goodwin 2013-07-17 14:21:38 UTC
This can be considered an issue either with how Katello is PUTting consumer updates, or with how candlepin interprets them.

It is caused by sending up objects like GuestIds and ConsumerInstalledProducts with an ID already populated. This indicates Katello is fetching a representation of the consumer, changing it, and sending it right back.

Candlepin's update consumer call was written differently, and only expects fields that the caller (client) would know about. The client just sends the data it knows about, it does not store or know the candlepin ID for an installed product record, and thus does not send it with the update call.

Katello could drop the IDs from these objects, or just send the data that has changed.

Candlepin could also be modified to support something like GET /consumers/uuid and then PUT'ing the response right back.

Comment 4 Tom McKay 2013-07-18 20:11:59 UTC
Branch: refs/heads/master
  Home:   https://github.com/Katello/katello
  Commit: 4d260a32994d827b9e51fb292bb40dea190cc7da
      https://github.com/Katello/katello/commit/4d260a32994d827b9e51fb292bb40dea190cc7da
  Author: Tom McKay <thomasmckay>
  Date:   2013-07-18 (Thu, 18 Jul 2013)

Comment 5 Vitaly Kuznetsov 2013-07-19 09:40:25 UTC
Thanks, not failing anymore with katello-glue-candlepin-1.4.2-1.git.866.c6be614.el6

Comment 6 Bryan Kearney 2013-08-02 18:52:37 UTC
SNAP0 contains these bug fixes. Moving to ON_QA.

Comment 7 sthirugn@redhat.com 2013-08-14 19:25:27 UTC
Verified. Og Maciel was able to add 1000 systems with no error.

Packages tested:
* candlepin-0.8.19-1.el6sam.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.8.19-1.el6sam.noarch
* candlepin-tomcat6-0.8.19-1.el6sam.noarch
* elasticsearch-0.19.9-8.el6sat.noarch
* katello-candlepin-cert-key-pair-1.0-1.noarch
* katello-certs-tools-1.4.2-2.el6sat.noarch
* katello-cli-1.4.3-4.el6sat.noarch
* katello-cli-common-1.4.3-4.el6sat.noarch
* katello-common-1.4.3-5.el6sam_splice.noarch
* katello-configure-1.4.4-2.el6sat.noarch
* katello-glue-candlepin-1.4.3-5.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-5.el6sam_splice.noarch
* katello-headpin-1.4.3-5.el6sam_splice.noarch
* katello-headpin-all-1.4.3-5.el6sam_splice.noarch
* katello-selinux-1.4.4-2.el6sat.noarch
* thumbslug-0.0.32-1.el6sam.noarch
* thumbslug-selinux-0.0.32-1.el6sam.noarch

Comment 9 errata-xmlrpc 2013-10-01 11:12:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2013-1390.html