Bug 914827

Summary: New consumer types fail if they have imported a manifest which contains them
Product: [Retired] Subscription Asset Manager Reporter: Bryan Kearney <bkearney>
Component: candlepinAssignee: Bryan Kearney <bkearney>
Status: CLOSED ERRATA QA Contact: SAM QE List <sam-qe-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.3CC: sthirugn, strobert, 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: Environment:
Last Closed: 2013-10-01 11:06:42 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, 987696    
Attachments:
Description Flags
katello-upgrade error none

Description Bryan Kearney 2013-02-22 22:11:50 UTC
Importing a manifest from hosted which contains the consumer type "sam" causes the DB upgrade to fail:

Stopping all katello services
Shutting down Katello services...
Stopping katello-jobs:                                     [FAILED]
Stopping katello: 
Stopping foreman: Foreman was not running.                 [FAILED]

Stopping elasticsearch:                                    [FAILED]
Stopping Qpid AMQP daemon:                                 [  OK  ]
Stopping mongod:                                           [  OK  ]
Stopping httpd:                                            [  OK  ]
Stopping tomcat6:                                          [  OK  ]
Done.
tomcat6 is stopped                                         [  OK  ]
httpd is stopped
mongod is stopped
qpidd is stopped
elasticsearch is stopped
Foreman is stopped
katello is not running.
delayed_job is not running.
delayed_job_monitor is not running.
Loaded 15 steps to the upgrade queue
------------------------------------------------------------------------------------------------------------------
Step:        Start qpidd service (1/15)
Runs:        always
Description: Start the service

Starting step Start qpidd service
Starting Qpid AMQP daemon:                                 [  OK  ]
Successfuly finished step: Start qpidd service
------------------------------------------------------------------------------------------------------------------
Step:        Start mongod service (2/15)
Runs:        always
Description: Start the service

Starting step Start mongod service
Starting mongod:                                           [  OK  ]
Successfuly finished step: Start mongod service
------------------------------------------------------------------------------------------------------------------
Step:        Migrate MongoDB database (3/15)
Runs:        always
Description: This steps calls pulp-migrate tool to migrate Pulp database schema to the most recent
             version.

Starting step Migrate MongoDB database
Beginning database migrations.
Migration package pulp.server.db.migrations is up to date at version 2
Database migrations complete.
Loading content types.
Content types loaded.
Successfuly finished step: Migrate MongoDB database
------------------------------------------------------------------------------------------------------------------
Step:        Start Apache httpd service (4/15)
Runs:        always
Description: Start the service

Starting step Start Apache httpd service
Starting httpd:                                            [  OK  ]
Successfuly finished step: Start Apache httpd service
------------------------------------------------------------------------------------------------------------------
Step:        Remove hornetq files (5/15)
Runs:        always
Description: Certain Candlepin versions can contain several directories with journal data of hornetq
             daemon which needs to be removed.

Starting step Remove hornetq files
Successfuly finished step: Remove hornetq files
------------------------------------------------------------------------------------------------------------------
Step:        Migrate candlepin database (6/15)
Runs:        always
Description: This step calls Candlepin cpdb utility to upgrade database schema in postgresql database
             to the latest version.

Starting step Migrate candlepin database

########## ERROR ############
Error running command: liquibase --driver=org.postgresql.Driver --classpath=/usr/share/java/postgresql-jdbc.jar:/var/lib/tomcat6/webapps/candlepin/WEB-INF/classes/ --changeLogFile=db/changelog/changelog-update.xml --url=jdbc:postgresql:candlepin --username=candlepin  --password=candlepin migrate -Dcommunity=False
Status code: 65280
Command output: INFO 2/22/13 1:38 PM:liquibase: Successfully acquired change log lock
INFO 2/22/13 1:38 PM:liquibase: Reading from databasechangelog
INFO 2/22/13 1:38 PM:liquibase: Reading from databasechangelog
SEVERE 2/22/13 1:38 PM:liquibase: Change Set db/changelog/20130212124537-insert-katello-consumer-types.xml::20130212124537-product::bkearney failed.  Error: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
liquibase.exception.DatabaseException: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
        at liquibase.executor.jvm.JdbcExecutor.execute(Unknown Source)
        at liquibase.executor.jvm.JdbcExecutor.execute(Unknown Source)
        at liquibase.database.AbstractDatabase.execute(Unknown Source)
        at liquibase.database.AbstractDatabase.executeStatements(Unknown Source)
        at liquibase.changelog.ChangeSet.execute(Unknown Source)
        at liquibase.changelog.visitor.UpdateVisitor.visit(Unknown Source)
        at liquibase.changelog.ChangeLogIterator.run(Unknown Source)
        at liquibase.Liquibase.update(Unknown Source)
        at liquibase.integration.commandline.Main.doMigration(Unknown Source)
        at liquibase.integration.commandline.Main.main(Unknown Source)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:345)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(Unknown Source)
        ... 10 more
INFO 2/22/13 1:38 PM:liquibase: Successfully released change log lock
Liquibase Update Failed: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
SEVERE 2/22/13 1:38 PM:liquibase: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
liquibase.exception.MigrationFailedException: Migration failed for change set db/changelog/20130212124537-insert-katello-consumer-types.xml::20130212124537-product::bkearney:
     Reason: liquibase.exception.DatabaseException: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key":
          Caused By: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key":
          Caused By: ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
        at liquibase.changelog.ChangeSet.execute(Unknown Source)
        at liquibase.changelog.visitor.UpdateVisitor.visit(Unknown Source)
        at liquibase.changelog.ChangeLogIterator.run(Unknown Source)
        at liquibase.Liquibase.update(Unknown Source)
        at liquibase.integration.commandline.Main.doMigration(Unknown Source)
        at liquibase.integration.commandline.Main.main(Unknown Source)
Caused by: liquibase.exception.DatabaseException: Error executing SQL INSERT INTO cp_consumer_type (id, label, manifest) VALUES ('1006', 'sam', 'Y'): ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
        at liquibase.executor.jvm.JdbcExecutor.execute(Unknown Source)
        at liquibase.executor.jvm.JdbcExecutor.execute(Unknown Source)
        at liquibase.database.AbstractDatabase.execute(Unknown Source)
        at liquibase.database.AbstractDatabase.executeStatements(Unknown Source)
        ... 6 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "cp_consumer_type_label_key"
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
        at org.postgresql.jdbc2.AbstractJdbc2StatemeUpgrade script did not return zero, investigate, stop services and re-run upgrade.
More info in /var/log/katello/katello_upgrade.log
nt.execute(AbstractJdbc2Statement.java:479)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:353)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:345)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(Unknown Source)
        ... 10 more


For more information, use the --logLevel flag)
Migrating candlepin database
Traceback (most recent call last):
  File "./cpdb", line 146, in <module>
    dbsetup.update()
  File "./cpdb", line 80, in update
    self._run_liquibase("db/changelog/changelog-update.xml")
  File "./cpdb", line 103, in _run_liquibase
    self.community))
  File "./cpdb", line 32, in run_command
    error_out(command, status, output)
  File "./cpdb", line 40, in error_out
    raise Exception("Error running command")
Exception: Error running command

Comment 1 Steven Roberts 2013-02-22 22:14:07 UTC
As a workaround, I was able to:
vi /var/lib/tomcat6/webapps/candlepin/WEB-INF/classes/db/changelog/changelog-update.xml

and comment out (<!-- -->) the 20130212124537-insert-katello-consumer-types.xml line.

Comment 2 Bryan Kearney 2013-07-16 19:14:13 UTC
https://github.com/candlepin/candlepin/pull/327

Comment 3 Bryan Kearney 2013-07-16 19:17:59 UTC
*** Bug 984099 has been marked as a duplicate of this bug. ***

Comment 4 Bryan Kearney 2013-07-18 11:23:29 UTC
Fixed in master at 

commit aa174e82cf1cdee80cfb3886d36c41340898dc75
Author: Bryan Kearney <bkearney>
Date:   Tue Jul 16 15:08:55 2013 -0400

    914827: Do not insert new consumer types if they are already present.
    
    The manifest files pull down the latest consumer types. Therefore, the
    scripts which work on the install fail on an upgrade. This patch causes
    the inserts to be marked as having run if the content is already there.
    
    Since the two types were added at the same time, there is no need to
    test for both values


Expect to see this in 0.8.18 or later.

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

Comment 6 sthirugn@redhat.com 2013-08-15 22:17:21 UTC
Failed for the same reason as https://bugzilla.redhat.com/show_bug.cgi?id=983647#c6

Comment 7 sthirugn@redhat.com 2013-08-16 13:51:39 UTC
Upgrade still fails. More info attached.

Packages tested:
* candlepin-0.8.20-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.20-1.el6sam.noarch
* candlepin-tomcat6-0.8.20-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-7.el6sat.noarch
* katello-cli-common-1.4.3-7.el6sat.noarch
* katello-common-1.4.3-8.el6sam_splice.noarch
* katello-configure-1.4.4-2.el6sat.noarch
* katello-glue-candlepin-1.4.3-8.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-8.el6sam_splice.noarch
* katello-headpin-1.4.3-8.el6sam_splice.noarch
* katello-headpin-all-1.4.3-8.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 sthirugn@redhat.com 2013-08-16 13:52:59 UTC
Created attachment 787267 [details]
katello-upgrade error

Comment 10 sthirugn@redhat.com 2013-08-19 16:13:33 UTC
VERIFIED. The liquibase error mentioned in this BZ is not happening anymore.  But there is an other issue with upgrade which is tracked under BZ 998631

Packages tested:
* candlepin-0.8.20-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.20-1.el6sam.noarch
* candlepin-tomcat6-0.8.20-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-7.el6sat.noarch
* katello-cli-common-1.4.3-7.el6sat.noarch
* katello-common-1.4.3-8.el6sam_splice.noarch
* katello-configure-1.4.4-2.el6sat.noarch
* katello-glue-candlepin-1.4.3-8.el6sam_splice.noarch
* katello-glue-elasticsearch-1.4.3-8.el6sam_splice.noarch
* katello-headpin-1.4.3-8.el6sam_splice.noarch
* katello-headpin-all-1.4.3-8.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 12 errata-xmlrpc 2013-10-01 11:06:42 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