Bug 835875 - Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,573
Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.Abs...
Status: CLOSED WONTFIX
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Content Management (Show other bugs)
6.0.1
Unspecified Unspecified
high Severity high (vote)
: Unspecified
: --
Assigned To: Dmitri Dolguikh
Garik Khachikyan
: Reopened, Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-27 07:53 EDT by James Laska
Modified: 2015-01-04 16:59 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Deletion of a previously promoted repository from the Providers screen resulted in a JDBC runtime error if recreated with the same name, due to the association with environments. This fix denies deletion of promoted repositories from the Providers screen unless deleted from existing environments.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-03-18 13:38:37 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
katello-debug-20120627075212.tar.gz (3.43 MB, application/octet-stream)
2012-06-27 07:53 EDT, James Laska
no flags Details
katello-debug-20130208130639.tar.gz (8.14 MB, application/octet-stream)
2013-02-08 13:09 EST, James Laska
no flags Details

  None (edit)
Description James Laska 2012-06-27 07:53:44 EDT
Created attachment 594748 [details]
katello-debug-20120627075212.tar.gz

Description of problem:

After removing a repository from a custom provider, I then created a new repository with the same name.  The following error resulted ...

{"displayMessage":"Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,573"}

Version-Release number of selected component (if applicable):
 * candlepin-0.6.5-1.el6_2.src.rpm
 * katello-0.1.318-1.el6cf.src.rpm
 * katello-candlepin-cert-key-pair-1.0-1.src.rpm
 * katello-certs-tools-1.0.7-1.el6_3.src.rpm
 * katello-cli-0.1.112-1.el6cf.src.rpm
 * katello-configure-0.1.110-1.el6_3.src.rpm
 * katello-qpid-broker-key-pair-1.0-1.src.rpm
 * katello-qpid-client-key-pair-1.0-1.src.rpm
 * katello-selinux-0.1.10-1.el6.src.rpm
 * pulp-1.0.4-1.el6.src.rpm


How reproducible:


Steps to Reproduce:
1. Create a custom provider, product and repository
2. Sync repository and attach to system templates ... promote (unsure if this step is required)
3. Delete the repository created in step#1
4. Create a new repository attached to the same product, using the same name used in step#1
  
Actual results:

{"displayMessage":"Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,573"}

Expected results:

 * It should succeed, or I should get a warning that I cannot use the same name?

Additional info:

 * See katello-debug attached
Comment 1 Lukas Zapletal 2012-08-28 06:24:50 EDT
REPRODUCED

I can confirm that it's the promotion that triggers the bug. Synchronization, attaching to a template did not reproduce it.

[root@aa ~]# kk provider create --name prov
Successfully created provider [ prov ]

[root@aa ~]# kk product create --name product --provider prov
Created ...

[root@aa ~]# kk repo create --name repo --product product --url http://lzap.fedorapeople.org/fakerepos/zoo5/
Successfully created repository [ repo ]

[root@aa ~]# kk repo delete --name repo --product product
Deleted repository '95'

[root@aa ~]# kk repo create --name repo --product product --url http://lzap.fedorapeople.org/fakerepos/zoo5/
Successfully created repository [ repo ]

[root@aa ~]# kk product synchronize --name product
Product [ product ] synchronized                                      

[root@aa ~]# kk repo delete --name repo --product product
Deleted repository '97'

[root@aa ~]# kk repo create --name repo --product product --url http://lzap.fedorapeople.org/fakerepos/zoo5/
Successfully created repository [ repo ]

[root@aa ~]# kk product synchronize --name product
Product [ product ] synchronized                                      

[root@aa ~]# kk environment create --name env --prior Library
Successfully created environment [ env ]

[root@aa ~]# kk changeset create --name ch1 --environment env
Successfully created changeset [ ch1 ] for environment [ env ]

[root@aa ~]# kk changeset update --name ch1 --environment env --add_product product
Successfully updated changeset [ ch1 ]

[root@aa ~]# kk changeset promote --name ch1 --environment env
Changeset [ ch1 ] applied                 

[root@aa ~]# kk repo delete --name repo --product product
Deleted repository '98'

[root@aa ~]# kk repo create --name repo --product product --url http://lzap.fedorapeople.org/fakerepos/zoo5/
Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,598
Comment 2 Lukas Zapletal 2012-08-30 10:32:52 EDT
https://github.com/Katello/katello/pull/550
Comment 3 Lukas Zapletal 2012-09-03 06:03:46 EDT
Ignore the comment 2 ^^^

The exception is:

Sep 03 11:59:35 [http-8443-1] ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: duplicate key value violates unique constraint "cp_content_label_key"
Sep 03 11:59:35 [http-8443-1] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into cp_content (created, updated, contentUrl, gpgUrl, label, metadataExpire, name, releaseVer, requiredTags, type, vendor, id) values ('2012-09-03 11:59:34.624000 +02:00:00', '2012-09-03 11:59:34.624000 +02:00:00', '/custom/product/repo', '', 'ACME_Corporation_product_repo', NULL, 'repo', NULL, NULL, 'yum', 'Custom', '1346666374624') was aborted.  Call getNextException to see the cause.

Caused by: java.sql.BatchUpdateException: Batch entry 0 insert into cp_content (created, updated, contentUrl, gpgUrl, label, metadataExpire, name, releaseVer, requiredTags, type, vendor, id) values ('2012-09-03 11:59:34.624000 +02:00:00', '2012-09-03 11:59:34.624000 +02:00:00', '/custom/product/repo', '', 'ACME_Corporation_product_repo', NULL, 'repo', NULL, NULL, 'yum', 'Custom', '1346666374624') was aborted.  Call getNextException to see the cause.
Comment 4 Lukas Zapletal 2012-09-06 08:40:41 EDT
After discussion on the list (Re: [katello-devel] Demotions and deletions - solution) this solution is to be implemented:

1. If the user attempts to delete a repo (from providers screen) and
the repo was not previously promoted, allow the deletion to occur.
(This is also today's behavior.)

2. If the user attempts to delete a repo (from providers screen) and
the repo was previously promoted:

      a. Do not allow the repo to be deleted.  In order to support this,

          i. Disable the 'remove' link so the user doesn't have theoption.
             Add a tipsy next to the remove link that when hovered theuser
             can be given information on 'why' the remove link isdisabled.
             (e.g. "Before removing this repo from the product, itmust first
             be deleted from the following environments using a deletion
             changeset: A, B, C.")

More info in the thread.
Comment 5 Lukas Zapletal 2012-09-10 08:43:58 EDT
witlessb is taking over
Comment 6 Dmitri Dolguikh 2012-09-11 10:48:21 EDT
fixed in a2fa896bb1078f792df3d329e684e6bb83ce5b16.
Comment 8 Garik Khachikyan 2012-09-18 07:37:42 EDT
# REOPEN

I have to reopen the bug: as UI allows removal of the provider which has the repo promoted. I think the whole sequence of: provider->product->repo needs to be locked if there is a single promotion (of product/repo) there.

Same exception occur:
---
Resources::Candlepin::Content: 500 Internal Server Error {"displayMessage":"Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,569"} (POST /candlepin/content/) (RestClient::InternalServerError)
{"displayMessage":"Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,569"}
Click here for more details.
---

checked on CFSE version:
---

python-qpid-0.7.946106-1.el6.noarch
candlepin-cert-consumer-brno-cfse.usersys.redhat.com-1.0-1.noarch
qpid-cpp-client-0.14-16.el6.x86_64
candlepin-0.7.8-1.el6cf.noarch
katello-glue-pulp-1.1.12-7.el6cf.noarch
qpid-cpp-server-ssl-0.14-16.el6.x86_64
katello-candlepin-cert-key-pair-1.0-1.noarch
mod_wsgi-3.3-3.pulp.el6.x86_64
python-isodate-0.4.4-4.pulp.el6.noarch
katello-cli-common-1.1.8-1.git.2.a0908e7.el6.noarch
katello-cli-1.1.8-1.git.2.a0908e7.el6.noarch
qpid-cpp-client-ssl-0.14-16.el6.x86_64
python-oauth2-1.5.170-2.pulp.el6.noarch
pulp-common-1.1.12-1.el6cf.noarch
pulp-selinux-server-1.1.12-1.el6cf.noarch
m2crypto-0.21.1.pulp-7.el6.x86_64
candlepin-selinux-0.7.8-1.el6cf.noarch
katello-common-1.1.12-7.el6cf.noarch
katello-glue-candlepin-1.1.12-7.el6cf.noarch
katello-1.1.12-7.el6cf.noarch
katello-all-1.1.12-7.el6cf.noarch
katello-qpid-broker-key-pair-1.0-1.noarch
katello-certs-tools-1.1.8-1.el6cf.noarch
katello-repos-1.1.2-1.el6.noarch
katello-agent-1.1.2-1.el6.noarch
katello-configure-1.1.9-3.el6cf.noarch
qpid-cpp-server-0.14-16.el6.x86_64
pulp-1.1.12-1.el6cf.noarch
katello-selinux-1.1.1-1.el6cf.noarch
candlepin-tomcat6-0.7.8-1.el6cf.noarch
katello-qpid-client-key-pair-1.0-1.noarch
---
Comment 9 Garik Khachikyan 2012-09-18 07:40:30 EDT
scenario to reproduce:
- create provider/product/repo
- promote the product
- remove the provider
- recreate provider/product (same names)
- try to create the repo with the same name. Exception!
Comment 13 Garik Khachikyan 2012-10-03 10:55:22 EDT
# VERIFIED

there is exception showing: 
---
Provider cannot be deleted since one of its products or repositories has already been promoted. Using a changeset, please delete the repository from existing environments before deleting it.
---

doing the scenario on comment#9

checked on version:
---
katello-1.1.12-12.el6cf.noarch
katello-cli-1.1.8-6.el6cf.noarch
Comment 15 errata-xmlrpc 2012-12-04 14:46:59 EST
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/RHSA-2012-1543.html
Comment 16 James Laska 2013-02-08 13:06:32 EST
I'm seeing a very similar failure, while attempting to add a custom provider repository, whose name matches that of a custom provider repository that has since been deleted.

> 2013-02-08 12:31:50,359 [ERROR][MainThread] error() @ base.py:222 - error: Runtime Error Could not execute JDBC batch update at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError:2,569

This was reproduced with the following packages ...

 * candlepin-0.7.19-3.el6cf.src.rpm
 * katello-1.1.12.2-3.el6cf.src.rpm
 * katello-candlepin-cert-key-pair-1.0-1.src.rpm
 * katello-certs-tools-1.1.8-1.el6cf.src.rpm
 * katello-cli-1.1.8-14.el6cf.src.rpm
 * katello-configure-1.1.9-13.el6cf.src.rpm
 * katello-qpid-broker-key-pair-1.0-1.src.rpm
 * katello-qpid-client-key-pair-1.0-1.src.rpm
 * katello-selinux-1.1.1-3.el6cf.src.rpm
 * pulp-1.1.15-1.el6cf.src.rpm

I don't recall observing the exception noted in comment#13

Can someone confirm that the patch has been applied to the above version of katello?
Comment 17 James Laska 2013-02-08 13:09:24 EST
Created attachment 695202 [details]
katello-debug-20130208130639.tar.gz
Comment 18 James Laska 2013-02-08 13:28:54 EST
Reopening based on discussion w/ bkearney on #systemengine
Comment 19 Mike McCune 2013-08-16 14:16:07 EDT
getting rid of 6.0.0 version since that doesn't exist
Comment 22 Mike McCune 2014-03-18 13:38:37 EDT
This bug was closed because of a lack of activity.  If you feel this bug should be reconsidered for attention please feel free to re-open the bug with a comment stating why it should be reconsidered.

Note You need to log in before you can comment on or make changes to this bug.