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
Situation
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
#> 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.postgresqlThen 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
Status
Additional Information
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
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com