SUSE Support

Here When You Need Us

Error when syncing channels in SUSE Manager 4.2: duplicate key value violates unique constraint "rhn_channelcomps_cid_ctype_uq"

This document (000021076) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Manager 4.2

Situation

Syncing channels yields an error for some of them. So far the channels were always RedHat 8 related (or any of their clones, such as Oracle Linux).
The full trace in the log (which can be found in "/var/log/rhn/reposync/") is something similar to this:
202X/YY/ZZ 00:30:10 -04:00 Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/spacewalk/satellite_tools/reposync.py", line 622, in sync
    self.import_modules(plugin)
  File "/usr/lib/python3.6/site-packages/spacewalk/satellite_tools/reposync.py", line 883, in import_modules
    self.copy_metadata_file(plug, modulesfile, 'modules', relative_modules_dir)
  File "/usr/lib/python3.6/site-packages/spacewalk/satellite_tools/reposync.py", line 871, in copy_metadata_file
    last_modified=last_modified)
  File "/usr/lib/python3.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 150, in execute
    return self._execute_wrapper(self._execute, *p, **kw)
  File "/usr/lib/python3.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 299, in _execute_wrapper
    retval = function(*p, **kw)
  File "/usr/lib/python3.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 182, in _execute
    return self._execute_(args, kwargs)
  File "/usr/lib/python3.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 322, in _execute_
    self._real_cursor.execute(self.sql, params)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "rhn_channelcomps_cid_ctype_uq"
DETAIL:  Key (channel_id, comps_type_id)=(126, 2) already exists.

Resolution

The following commands should be run as root on the SUSE Manager server:
#> spacewalk-sql --select-mode /etc/sysconfig/rhn/schema-upgrade/susemanager-schema-4.2.24-to-susemanager-schema-4.2.25/200-rhnChannelComps-drop_unique_index.sql.postgresql

#> spacewalk-sql --select-mode /etc/sysconfig/rhn/schema-upgrade/susemanager-schema-4.2.24-to-susemanager-schema-4.2.25/201-rhn_channel_cloned_comps_trig_fun.sql.postgresql
Then the channel can be synced again. It is recommended to run the sync manually this time, and watch if finish successfully (the value of the variable should be replaced by the actual channel to be synced):
#> spacewalk-repo-sync -c $CHANNEL_NAME

Cause

There was a schema migration in a wrong directory, hence not executed after updating.

Status

Reported to Engineering

Additional Information

The fix will be released with version 4.2.13. Until that version is released, until then this article should be followed. Once released, simply patching to the latest version should take care of everything.

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021076
  • Creation Date: 06-Jun-2023
  • Modified Date:06-Jun-2023
    • SUSE Manager Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.