[Spacewalk-list] ERROR: (23, 'ERROR: duplicate key value violates unique constraint "rhn_cnp_cid_nid_uq"', 'Could not update database entry.')

Robert Paschedag robert.paschedag at web.de
Tue Jul 17 19:59:57 UTC 2018


On 07/17/18 12:54, Giles Coochey wrote:
> On 17/07/2018 11:26, Robert Paschedag wrote:
>>
>>> Gesendet: Dienstag, 17. Juli 2018 um 11:28 Uhr
>>> Von: "Giles Coochey" <giles at coochey.net>
>>> An: "spacewalk-list at redhat.com" <spacewalk-list at redhat.com>
>>> Betreff: [Spacewalk-list] ERROR: (23, 'ERROR: duplicate key value
>>> violates unique constraint "rhn_cnp_cid_nid_uq"', 'Could not update
>>> database entry.')
>>>
>>> I'm getting the unique contrainst violation on attempting to reposync my
>>> Centos 6 OS updates.
>>>
>>> I've googled the error and see that in the past it is due to misnaming
>>> of packages in the repo, but it doesn't help me find which package might
>>> be the root cause of this (prior reports seem to indicate a different
>>> package to what might be at fault now, the prior thread dates back to
>>> 2016).
>>>
>>> There is a more recent report with regard to satellite-sync here:
>>> https://access.redhat.com/solutions/511223 (which appears to be from
>>> June 2018).
>>>
>>> Unfortunately, I don't have a Redhat login/subscription so I'm not privy
>>> to the potential solution.
>>>
>>> Anybody able to assist or provide information as to what the 511223
>>> solution on the Redhat knowledgebase refers to?
>>>
>>> The precise error I get is as follows:
>>>
>>> 10:23:09     516/520 : yum-plugin-versionlock-1.1.30-41.el6.noarch.rpm
>>> 10:23:09     517/520 : yum-updateonboot-1.1.30-41.el6.noarch.rpm
>>> 10:23:10     518/520 : yum-utils-1.1.30-41.el6.noarch.rpm
>>> 10:23:10     519/520 : zsh-html-4.3.11-8.el6.centos.x86_64.rpm
>>> 10:23:10     520/520 : zsh-4.3.11-8.el6.centos.x86_64.rpm
>>> 10:23:11
>>> 10:23:11   Importing packages to DB:
>>>                  Importing packages:
>>> |##################################################| 100.0%
>>> 10:27:34
>>> 10:27:34   Linking packages to the channel.
>>> 10:27:40 ERROR: (23, 'ERROR:  duplicate key value violates unique
>>> constraint "rhn_cnp_cid_nid_uq"', 'Could not update database entry.')
>>> Traceback (most recent call last):
>>>     File "/usr/bin/spacewalk-repo-sync", line 264, in <module>
>>>       sys.exit(abs(main() or 0))
>>>     File "/usr/bin/spacewalk-repo-sync", line 247, in main
>>>       elapsed_time, channel_ret_code = sync.sync()
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/reposync.py",
>>>
>>> line 540, in sync
>>>       [self.channel_label], [], "server.app.yumreposync")
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/server/taskomatic.py", line
>>> 69, in add_to_repodata_queue_for_channel_package_subscription
>>>       add_to_repodata_queue(channel, caller, reason[:128])
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/server/taskomatic.py", line
>>> 53, in add_to_repodata_queue
>>>       queue.add(entry)
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/server/taskomatic.py", line
>>> 44, in add
>>>       bypass_filters=self._boolean_as_char(entry.bypass_filters))
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py",
>>> line 151, in execute
>>>       return self._execute_wrapper(self._execute, *p, **kw)
>>>     File
>>> "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py",
>>>
>>> line 302, in _execute_wrapper
>>>       raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
>>> spacewalk.server.rhnSQL.sql_base.SQLSchemaError: (99999, 'ERROR: current
>>> transaction is aborted, commands ignored until end of transaction
>>> block', '', InternalError('current transaction is aborted, commands
>>> ignored until end of transaction block\n',))
>> I don't know the full correct path right now from my mind, but you can
>> look into
>> the postgres DB logs somewhere in /var/lib/pgdata/logs/<weekday>.log
>> (I think).
>>
>> There should be some more detail.
> 
> I found in: /var/lib/pgsql/data/pg_log/postgresql-Mon.log:
> 
> 
> 2018-07-16 10:56:49.241 BST ERROR:  duplicate key value violates unique
> constraint "rhn_cnp_cid_nid_uq"
> 2018-07-16 10:56:49.241 BST CONTEXT:  SQL statement "insert into
> rhnChannelNewestPackage (channel_id, name_id, evr_id, package_id,
> package_arch_id) (select channel_id, name_id, evr_id, package
> _id, package_arch_id from rhnChannelNewestPackageView where channel_id
> =  $1  and ( $2  is null or name_id =  $2 ) )"
>         PL/pgSQL function "refresh_newest_package" line 8 at SQL statement
> 2018-07-16 10:56:49.242 BST STATEMENT:  SELECT
> rhn_channel.refresh_newest_package(102, E'server.app.yumreposync', NULL)
> 2018-07-16 10:56:49.458 BST ERROR:  current transaction is aborted,
> commands ignored until end of transaction block
> 2018-07-16 10:56:49.458 BST STATEMENT:  update rhnChannel set
> LAST_SYNCED = current_timestamp
>                                      where label = E'basechannel'
> 2018-07-16 11:07:46.380 BST ERROR:  duplicate key value violates unique
> constraint "rhn_cnp_cid_nid_uq"
> 2018-07-16 11:07:46.380 BST CONTEXT:  SQL statement "insert into
> rhnChannelNewestPackage (channel_id, name_id, evr_id, package_id,
> package_arch_id) (select channel_id, name_id, evr_id, package
> _id, package_arch_id from rhnChannelNewestPackageView where channel_id
> =  $1  and ( $2  is null or name_id =  $2 ) )"
>         PL/pgSQL function "refresh_newest_package" line 8 at SQL statement
> 2018-07-16 11:07:46.380 BST STATEMENT:  SELECT
> rhn_channel.refresh_newest_package(102, E'server.app.yumreposync', NULL)
> 2018-07-16 11:07:46.577 BST ERROR:  current transaction is aborted,
> commands ignored until end of transaction block
> 2018-07-16 11:07:46.577 BST STATEMENT:  update rhnChannel set
> LAST_SYNCED = current_timestamp
>                                      where label = E'basechannel'
> 2018-07-16 11:11:24.679 BST ERROR:  duplicate key value violates unique
> constraint "rhn_cnp_cid_nid_uq"

This is for me also hard to debug. This is from my SW 2.7 system

rhnschema=# \d rhnChannelNewestPackage
Tabelle ��public.rhnchannelnewestpackage��
     Spalte      |   Typ   | Attribute
-----------------+---------+-----------
 channel_id      | numeric | not null
 name_id         | numeric | not null
 evr_id          | numeric | not null
 package_arch_id | numeric | not null
 package_id      | numeric | not null
Indexe:
    "rhn_cnp_cid_nid_uq" UNIQUE, btree (channel_id, name_id,
package_arch_id)
    "rhn_cnp_pid_idx" btree (package_id)
Fremdschl��ssel-Constraints:
    "rhn_cnp_cid_fk" FOREIGN KEY (channel_id) REFERENCES rhnchannel(id)
ON DELETE CASCADE
    "rhn_cnp_eid_fk" FOREIGN KEY (evr_id) REFERENCES rhnpackageevr(id)
    "rhn_cnp_nid_fk" FOREIGN KEY (name_id) REFERENCES rhnpackagename(id)
    "rhn_cnp_paid_fk" FOREIGN KEY (package_arch_id) REFERENCES
rhnpackagearch(id)
    "rhn_cnp_pid_fk" FOREIGN KEY (package_id) REFERENCES rhnpackage(id)
ON DELETE CASCADE

rhnschema=# select count(*) from rhnChannelNewestPackage;
 count
--------
 212394
(1 Zeile)

rhnschema=#

So...the "rhn_cnp_cid_nid_uq" constraint is the combination of
channel_id_name_id and package_arch_id that is already present.

Is this the first time you try to sync this channel? Did you possible
add another repository to be included within a channel (to sync from?)

Maybe you could try to delete all packages within that channel (102) and
try to sync again. But you should verify, that there are no more
packages with this channel id (102) within the rhnChannelNewestPackage.

Sorry...currently have no other idea.

Robert


> 2018-07-16 11:11:24.679 BST CONTEXT:  SQL statement "insert into
> rhnChannelNewestPackage (channel_id, name_id, evr_id, package_id,
> package_arch_id) (select channel_id, name_id, evr_id, package
> _id, package_arch_id from rhnChannelNewestPackageView where channel_id
> =  $1  and ( $2  is null or name_id =  $2 ) )"
>         PL/pgSQL function "refresh_newest_package" line 8 at SQL statement
> 2018-07-16 11:11:24.679 BST STATEMENT:  SELECT
> rhn_channel.refresh_newest_package(102, E'server.app.yumreposync', NULL)
> 2018-07-16 11:11:24.894 BST ERROR:  current transaction is aborted,
> commands ignored until end of transaction block
> 2018-07-16 11:11:24.894 BST STATEMENT:  update rhnChannel set
> LAST_SYNCED = current_timestamp
>                                      where label = E'basechannel'
> 2018-07-16 23:41:10.371 BST LOG:  could not send data to client:
> Connection reset by peer
> 2018-07-16 23:41:10.371 BST STATEMENT:  select taskorun0_.id as id233_,
> taskorun0_.org_id as org2_233_, taskorun0_.template_id as
> template3_233_, taskorun0_.schedule_id as schedule4_233_, task
> orun0_.start_time as start5_233_, taskorun0_.end_time as end6_233_,
> taskorun0_.std_output_path as std7_233_, taskorun0_.std_error_path as
> std8_233_, taskorun0_.status as status233_, taskorun0_
> .created as created233_, taskorun0_.modified as modified233_ from
> rhnTaskoRun taskorun0_ where taskorun0_.end_time<$1
> 2018-07-16 23:41:10.372 BST LOG:  could not send data to client: Broken
> pipe
> 2018-07-16 23:41:10.372 BST STATEMENT:  select taskorun0_.id as id233_,
> taskorun0_.org_id as org2_233_, taskorun0_.template_id as
> template3_233_, taskorun0_.schedule_id as schedule4_233_, task
> orun0_.start_time as start5_233_, taskorun0_.end_time as end6_233_,
> taskorun0_.std_output_path as std7_233_, taskorun0_.std_error_path as
> std8_233_, taskorun0_.status as status233_, taskorun0_
> .created as created233_, taskorun0_.modified as modified233_ from
> rhnTaskoRun taskorun0_ where taskorun0_.end_time<$1
> 
> 
>> Robert
>>>
>>> _______________________________________________
>>> Spacewalk-list mailing list
>>> Spacewalk-list at redhat.com
>>> https://www.redhat.com/mailman/listinfo/spacewalk-list
>> _______________________________________________
>> Spacewalk-list mailing list
>> Spacewalk-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/spacewalk-list
> 
> 
> _______________________________________________
> Spacewalk-list mailing list
> Spacewalk-list at redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-list




More information about the Spacewalk-list mailing list