Bug 701320 - Problem with Oracle to Postgresql migration in 1.4
Summary: Problem with Oracle to Postgresql migration in 1.4
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 1.4
Hardware: x86_64
OS: Linux
unspecified
urgent
Target Milestone: ---
Assignee: Michael Mráka
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On:
Blocks: space16
TreeView+ depends on / blocked
 
Reported: 2011-05-02 15:17 UTC by benjamin.allot-ext
Modified: 2011-07-25 19:03 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-25 19:03:16 UTC
Embargoed:


Attachments (Terms of Use)

Description benjamin.allot-ext 2011-05-02 15:17:18 UTC
Description of problem:
The spacewalk-setup --upgrade fails after a migration from oracle XE to postgresql

Version-Release number of selected component (if applicable):
Spacewalk : 1.4
Postgresql : 8.4

How reproducible:
Always



Steps to Reproduce:
1. # spacewalk-setup --disconnected --upgrade
2.
3.
  
Actual results:
** Database: Setting up database connection for PostgreSQL backend.
Hostname (leave empty for local)?
Database? spaceschema
Username? spacewalk
Password?
** Database: Populating database.
** Database: Skipping database population.
* Setting up users and groups.
** GPG: Initializing GPG and importing key.
* Performing initial configuration.
* Activating Spacewalk.
** Certificate not activated.
** Upgrade process requires the certificate to be activated after the schema is upgraded.
* Enabling Monitoring.
* Configuring apache SSL virtual host.
Should setup configure apache's default ssl server for you (saves original ssl.conf) [Y]?
* Configuring tomcat.
Reversed (or previously applied) patch detected!  Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file web.xml.rej
* Configuring jabberd.
* Creating SSL certificates.
** Skipping SSL certificate generation.
* Deploying configuration files.
* Update configuration in database.
DBD::Pg::st execute failed: ERROR:  null value in column "category_id" violates not-null constraint
Issuing rollback() for database handle being DESTROY'd without explicit disconnect().

Expected results:


Additional info:
Here is the relevant line in postgresql log file : 

CONTEXT:  COPY rhnpackagerepodata, line 1: "1057        \x1fÂ\x08\x00\x00\x00\x00\x00\x00\x00ÂUMsÃ0\x10½÷WhtJ¦Âü\x015NÃöL¤34¡%9ôÃ
                                                                                                                                           \x08..."
STATEMENT:  copy rhnpackagerepodata(package_id,primary_xml,filelist,other,created,modified) from stdin;
ERROR:  null value in column "category_id" violates not-null constraint
STATEMENT:  INSERT
          INTO rhnTemplateString
               (id, category_id, label, value, description)
        VALUES (sequence_nextval('rhn_template_str_id_seq'),
                (SELECT TC.id FROM rhnTemplateCategory TC WHERE TC.label = 'org_strings'),
                'hostname',
                $1,
                'Host name for the RHN Satellite')


The sql request : SELECT TC.id FROM rhnTemplateCategory TC WHERE TC.label = 'org_strings' give nothing.

Comment 1 benjamin.allot-ext 2011-05-03 07:18:02 UTC
After a bit more research, the org_string row is present in the dump extracted from Oracle XE.

Comment 2 benjamin.allot-ext 2011-05-03 12:46:25 UTC
Here the extract from the dump about rhntemplatecategory table :

-- Types for rhntemplatecategory: DOUBLE PRECISION VARCHAR2 VARCHAR2 DATE DATE
copy rhntemplatecategory(id,label,description,created,modified) from stdin;
1       org_strings     Organization specific strings.  2011-01-20 12:46:10     2011-01-20 12:46:10
2       email_strings   Strings appearing in e-mail sent to users.      2011-01-20 12:46:10     2011-01-20 12:46:10
\.


And after the import : 
-bash-3.2$ psql spaceschema
psql (8.4.7)
Type "help" for help.

spaceschema=# select * from rhntemplatecategory;
 id | label | description | created | modified
----+-------+-------------+---------+----------
(0 rows)

As I said previously, during the import, only this message occurs : 

----------------------------------------------------------
ERROR:  invalid byte sequence for encoding "LATIN1": 0x00
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
CONTEXT:  COPY rhnpackagerepodata, line 1: "1057        \x1fÂ\x08\x00\x00\x00\x00\x00\x00\x00ÂUMsÃ0\x10½÷WhtJ¦Âü\x015NÃöL¤34¡%9ôÃ
                                                                                                                                           \x08..."
STATEMENT:  copy rhnpackagerepodata(package_id,primary_xml,filelist,other,created,modified) from stdin;
-----------------------------------------------------------

I think this is only a problem related to postgresql NULL content behaviour from the metadata stored in the database.
Therefore, the import is stopped and the database is half filled.
I found no hint on how to fix the issue at https://fedorahosted.org/spacewalk/wiki/PostgreSQLPortingGuide

Comment 3 Jan Pazdziora 2011-07-20 11:52:33 UTC
Aligning under space16.

Comment 4 Jan Pazdziora 2011-07-25 19:03:16 UTC
I believe the problem with the rhnpackagerepodata was addressed in Spacewalk master, fe0f87bd13c9c4e9479a85cedc8e5c5f06720d9a, spacewalk-utils-1.5.4-1, based on thread

https://www.redhat.com/archives/spacewalk-list/2011-July/msg00081.html

Closing as CURRENTRELEASE with Spacewalk 1.5 released, please reopen if the bug still happens for you.


Note You need to log in before you can comment on or make changes to this bug.