Bug 1179682

Summary: The problem with a migration from the upgraded Satellite
Product: Red Hat Satellite 5 Reporter: Martin Korbel <mkorbel>
Component: UpgradesAssignee: Jan Dobes <jdobes>
Status: CLOSED CURRENTRELEASE QA Contact: Ales Dujicek <adujicek>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 570CC: adujicek, cperry, tlestach
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-utils-2.3.2-17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-05-29 21:49:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1095841, 1162131    

Description Martin Korbel 2015-01-07 10:30:47 UTC
Description of problem:
Problem with import dump from PostgreSQL into Oracle, when we have upgraded version of satellite (spacewalk-schema-upgrade). The core of problem is different order of columns, when we have got a clean installation and an upgraded installation of DB. 


Version-Release number of selected component (if applicable):
Satellite-5.7.0-RHEL6-re20150105.1 (spacewalk-utils-2.3.2-13.el6sat)

How reproducible:
100%

Steps to Reproduce:
1. we have got some older version of Satellite (Sat5.6,Sat5.5,...) with some data in DB. In my case is important the version of satellite (spacewalk-schema), it has to be older than spacewalk-schema-2.2.15.1. Because this version of  spacewalk-schema has altered  columns in the table rhnorgconfiguration.
2. we upgrade the satellite to the latest version (in my case Satellite-5.7.0-RHEL6-re20150105.1). 
3. we have got prepared external Oracle DB.
4. Follow these steps:
> yum upgrade -y
> /usr/bin/spacewalk-schema-upgrade
> echo '\d rhnorgconfiguration;' | spacewalk-sql --select-mode -
                         Table "public.rhnorgconfiguration"
           Column           |           Type           |          Modifiers           
----------------------------+--------------------------+------------------------------
 org_id                     | numeric                  | not null
 staging_content_enabled    | character(1)             | not null default 'N'::bpchar
 crash_reporting_enabled    | character(1)             | not null default 'Y'::bpchar
 crashfile_upload_enabled   | character(1)             | not null default 'Y'::bpchar
 crash_file_sizelimit       | numeric                  | not null default 2048
 scapfile_upload_enabled    | character(1)             | not null default 'N'::bpchar
 scap_file_sizelimit        | numeric                  | not null default 2097152
 scap_retention_period_days | numeric                  | default 90
 created                    | timestamp with time zone | not null default now()
 modified                   | timestamp with time zone | not null default now()
 create_default_sg          | character(1)             | not null default 'N'::bpchar


5. Follow these steps:
# Preparing of the satellite
> yum install spacewalk-utils
> yum remove rhn-upgrade -y  # bz1171675
> rhn-satellite stop
> service postgresql start
# make a dump
> spacewalk-dump-schema --to=oracle  > /tmp/schema-oracle.dump
# disable postgresql
> service postgresql stop
> chkconfig postgresql off
> yum remove spacewalk-postgresql
> yum install spacewalk-oracle # You should be sure, the dependencies are installed from the correct channel.
# Configure DB
> setenforce 0 # problem with selinux
> spacewalk-setup --db-only --external-oracle   #WA bz1179374
> echo 'describe rhnorgconfiguration;' | spacewalk-sql --select-mode -
ORG_ID                     NUMBER
STAGING_CONTENT_ENABLED    CHAR(1)
CRASH_REPORTING_ENABLED    CHAR(1)
CRASHFILE_UPLOAD_ENABLED   CHAR(1)
CRASH_FILE_SIZELIMIT       NUMBER
SCAPFILE_UPLOAD_ENABLED    CHAR(1)
SCAP_FILE_SIZELIMIT        NUMBER
SCAP_RETENTION_PERIOD_DAYS NUMBER
CREATE_DEFAULT_SG          CHAR(1)
CREATED   TIMESTAMP(6) WITH LOCAL TIME ZONE
MODIFIED  TIMESTAMP(6) WITH LOCAL TIME ZONE

6. We can grep /tmp/schema-oracle.dump
> grep -A 10 "insert into rhnorgconfiguration" /tmp/schema-oracle.dump
insert into rhnorgconfiguration values ('1',
'N',
'Y',
'Y',
'2048',
'N',
'2097152',
'90',
to_timestamp_tz('2013-11-26 08:46:05+00'),
to_timestamp_tz('2013-11-26 08:46:05+00'),
'N');

We can see this insert line is in a bad order.

7. We can try to import the dump (it can take very long time).
> NLS_LANG=AMERICAN_AMERICA.UTF8 sqlplus rhnsat/xxx@//oracle.redhat.com/rhnsat.world < /root/schema-oracle.dump;

Actual results:
ERROR at line 9:
ORA-12899: value too large for column
"RHNSAT"."RHNORGCONFIGURATION"."CREATE_DEFAULT_SG" (actual: 36, maximum: 1)

Expected results:
No errors

Additional info:
I guess, the best way is insert the names of columns into each SQL insert command.

Comment 1 Jan Dobes 2015-03-02 16:12:55 UTC
this was completely rewritten in bz1095841

Comment 3 Clifford Perry 2015-05-29 21:49:20 UTC
https://rhn.redhat.com/errata/RHEA-2015-0802.html