On Dec 5, 2012, at 3:24 AM, Jan Pazdziora wrote:

On Tue, Dec 04, 2012 at 09:14:31PM -0500, Maria Iano wrote:
I have a 32-bit RHEL 5.8 server which was running spacewalk 1.7.
Today I upgraded it to 1.8 and that seemed to work without any
problems. However, when I ran spacewalk-schema-upgrade it died with
this error at the end of the log file:

                                ?column?
--------------------------------------------------------------------------
spacewalk-schema-1.7-to-spacewalk-schema-1.8/143-novell-package- keys.sql
(1 row)

psql:/var/log/spacewalk/schema-upgrade/20121204-162859-script.sql:
2356: ERROR:  duplicate key value violates unique constraint
"rhn_pkg_provider_name_uq"

I took a look at line 2356 in /var/log/spacewalk/schema-upgrade/ 20121204-162859-script.sql
and here it is with the previous line:

insert into rhnPackageProvider (id, name) values
(sequence_nextval('rhn_package_provider_id_seq'), 'Novell Inc.' );

Out of curiosity I tried restoring the database and running that
query on its own and it ran with no error. I tried the upgrade after
running that, and also after restoring again but it died both times
with the same error.

Did it really die on the exact same line?

Yes it died on the same line. It died with a different error the second time, sorry I missed that earlier. The first time I ran it, it died with this error: psql:/var/log/spacewalk/schema-upgrade/20121204-153735-script.sql: 2356: ERROR: duplicate key value violates unique constraint "rhn_pkg_provider_id_pk"

After that I restored the database from backup and manually ran:
select * from rhn_package_provider_id_seq;
select * from rhnPackageProvider;
insert into rhnPackageProvider (id, name) values (sequence_nextval('rhn_package_provider_id_seq'), 'Novell Inc.' );
select * from rhnPackageProvider;
select * from rhn_package_provider_id_seq;

and I'll paste in the output below. It had the expected effect of adding " Novell Inc." to rhnPackageProvider. After that I ran spacewalk-schema-upgrade and the error message was: psql:/var/log/spacewalk/schema-upgrade/20121204-162859-script.sql: 2356: ERROR: duplicate key value violates unique constraint "rhn_pkg_provider_name_uq"

spaceschema=# select * from rhn_package_provider_id_seq;
sequence_name | last_value | start_value | increment_by | max_value | min_value |
cache_value | log_cnt | is_cycled | is_called
-----------------------------+------------+-------------+-------------- +---------------------+-----------+-
------------+---------+-----------+-----------
rhn_package_provider_id_seq | 108 | 100 | 1 | 9223372036854775807 | 1 |
          1 |      32 | f         | t
(1 row)

spaceschema=# select * from rhnPackageProvider;
id | name | created | modified -----+------------------+------------------------------- +------------------------------- 100 | Red Hat Inc. | 2012-05-11 17:05:11.399089-04 | 2012-05-11 17:05:11.399089-04 101 | Fedora | 2012-05-11 17:05:11.401747-04 | 2012-05-11 17:05:11.401747-04 102 | CentOS | 2012-05-11 17:05:11.403533-04 | 2012-05-11 17:05:11.403533-04 103 | Scientific Linux | 2012-05-11 17:05:11.404611-04 | 2012-05-11 17:05:11.404611-04 105 | Oracle Inc. | 2012-05-11 17:05:11.407241-04 | 2012-05-11 17:05:11.407241-04 106 | Spacewalk | 2012-05-11 17:05:11.408151-04 | 2012-05-11 17:05:11.408151-04 107 | EPEL | 2012-05-11 17:05:11.409168-04 | 2012-05-11 17:05:11.409168-04 108 | VMware | 2012-05-23 13:45:15.527746-04 | 2012-05-23 13:45:15.527746-04 104 | SUSE | 2012-05-11 17:05:11.406173-04 | 2012-12-04 15:46:36.020452-05
(9 rows)

spaceschema=# insert into rhnPackageProvider (id, name) values (sequence_nextval('rhn_package_provider_id_seq'), 'Novell Inc.' );
INSERT 0 1

spaceschema=# select * from rhnPackageProvider ; id | name | created | modified -----+------------------+------------------------------- +------------------------------- 100 | Red Hat Inc. | 2012-05-11 17:05:11.399089-04 | 2012-05-11 17:05:11.399089-04 101 | Fedora | 2012-05-11 17:05:11.401747-04 | 2012-05-11 17:05:11.401747-04 102 | CentOS | 2012-05-11 17:05:11.403533-04 | 2012-05-11 17:05:11.403533-04 103 | Scientific Linux | 2012-05-11 17:05:11.404611-04 | 2012-05-11 17:05:11.404611-04 105 | Oracle Inc. | 2012-05-11 17:05:11.407241-04 | 2012-05-11 17:05:11.407241-04 106 | Spacewalk | 2012-05-11 17:05:11.408151-04 | 2012-05-11 17:05:11.408151-04 107 | EPEL | 2012-05-11 17:05:11.409168-04 | 2012-05-11 17:05:11.409168-04 108 | VMware | 2012-05-23 13:45:15.527746-04 | 2012-05-23 13:45:15.527746-04 104 | SUSE | 2012-05-11 17:05:11.406173-04 | 2012-12-04 15:46:36.020452-05 109 | Novell Inc. | 2012-12-04 16:06:35.073876-05 | 2012-12-04 16:06:35.073876-05
(10 rows)

spaceschema=# select * from rhn_package_provider_id_seq ; sequence_name | last_value | start_value | increment_by | max_value | min_value |
cache_value | log_cnt | is_cycled | is_called
-----------------------------+------------+-------------+-------------- +---------------------+-----------+-
------------+---------+-----------+-----------
rhn_package_provider_id_seq | 109 | 100 | 1 | 9223372036854775807 | 1 |
          1 |      32 | f         | t
(1 row)



Has anyone else come across this?

Can you check that

        /var/log/spacewalk/schema-upgrade/20121204-162859-script.sql

script to see if the line 2356 is indeed the first line in the script
which mentions "Novell Inc."? Clearly, when you restore and run that
command, it passes, so the record with name "Novell Inc." is not in
your rhnPackageProvider table. Then on line 2356 it is there.
I suspect there is something earlier in the script which inserts it
there.

I thought there must be too, but I can't find it. The first occurrence in 20121204-162859-script.sql of 'Novell Inc' is on that line.

# grep -in 'Novell Inc' /var/log/spacewalk/schema-upgrade/ 20121204-162859-script.sql
2356:(sequence_nextval('rhn_package_provider_id_seq'), 'Novell Inc.' );
2358:update rhnPackageKey set provider_id = lookup_package_provider('Novell Inc.') 2360:update rhnPackageKey set provider_id = lookup_package_provider('Novell Inc.') 2362:update rhnPackageKey set provider_id = lookup_package_provider('Novell Inc.') 2364:update rhnPackageKey set provider_id = lookup_package_provider('Novell Inc.') 2368: (select sequence_nextval('rhn_pkey_id_seq'), '2afe16421d061a62', lookup_package_key_type('gpg'), lookup_package_provider('Novell Inc.') from dual 2371: (select sequence_nextval('rhn_pkey_id_seq'), '14c28bc97e2e3b05', lookup_package_key_type('gpg'), lookup_package_provider('Novell Inc.') from dual 2374: (select sequence_nextval('rhn_pkey_id_seq'), '478a32e8a1912208', lookup_package_key_type('gpg'), lookup_package_provider('Novell Inc.') from dual 2377: (select sequence_nextval('rhn_pkey_id_seq'), '73d25d630dfb3188', lookup_package_key_type('gpg'), lookup_package_provider('Novell Inc.') from dual

Is there something that runs before that script?

At this point I have restored the database again. Then I ran the commands below for not any good reason, just wondered if they might help. I'm not familiar with postgresql, I need to read up on it. I haven't tried running the schema upgrade again.

# reindex index rhn_pkg_provider_name_uq;
# analyze;

Thank you for your help!
Maria


_______________________________________________
Spacewalk-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-list

Reply via email to