Bug 893459

Summary: Installer pre-upgrade step should ensure DB consistency using fkvalidator.sh
Product: Red Hat Enterprise Virtualization Manager Reporter: Eli Mesika <emesika>
Component: ovirt-engine-setupAssignee: Alex Lourie <alourie>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Stehlik <pstehlik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 3.2.0CC: alourie, bazulay, dyasny, iheim, mgoldboi, Rhev-m-bugs, sgrinber, ykaul
Target Milestone: ---   
Target Release: 3.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: integration
Fixed In Version: sf16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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: 912305, 915925    
Bug Blocks: 948448    

Description Eli Mesika 2013-01-09 11:35:54 UTC
Description of problem:
When upgrading real customer databases we ha encounter sometimes that DB had inconsistent data, mostly by data added manually in a way that breaks a Foreign Key constraint.

Installer pre upgrade step should run fkvalidaor.sh to chekc DB consistency and if any such are found, the user should approve running fkvalidaor.sh with the -f flag that forces removal of the inconsistent data.

Version-Release number of selected component (if applicable):


How reproducible:
always

Steps to Reproduce:
1.take any parent/child tables (for example job & step)
2.force insertion of illegal data to the child table by disabling child table triggers 
ALTER TABLE <child table> DISABLE TRIGGER ALL;
3.Insert a row in child that breaks the FK
4. ALTER TABLE <child table> ENABLE TRIGGER ALL;
5. use pg_dump to backup the database
6. use pg_restore to restore the database
  
Actual results:
You will get a FK violation error

Expected results:

FK violations should be trapped and resolved in the pre-upgrade step
Additional info:
see
fkvalidaor.sh --help

Comment 1 Barak 2013-01-09 12:07:14 UTC
can the fkvalidator.sh list of inconsistencies ?
Please add the --help of the tool to this BZ.

Comment 2 Eli Mesika 2013-01-09 12:18:43 UTC
(In reply to comment #1)
> can the fkvalidator.sh list of inconsistencies ?
> Please add the --help of the tool to this BZ.

Yes

Usage: fkvalidator.sh [-h] [-s SERVERNAME [-p PORT]] [-d DATABASE] [-u USERNAME] [-l LOGFILE] [-f] [-v]

 -s SERVERNAME - The database servername for the database  (def. localhost)
 -p PORT       - The database port for the database        (def. 5432)
 -d DATABASE   - The database name                         (def. engine)
 -u USERNAME   - The admin username for the database.
 -l LOGFILE    - The logfile for capturing output          (def. fkvalidator.sh.log)
 -f            - Fix the non consistent data by removing it from DB.
 -v            - Turn on verbosity                         (WARNING: lots of output)
 -h            - This help text.

Comment 3 Eli Mesika 2013-01-09 12:20:55 UTC
examples

1) listing violations
fkvalidator.sh -u postgres -d engine 

2) resolving violations
fkvalidator.sh -u postgres -d engine -f

Comment 4 Alex Lourie 2013-02-18 10:04:59 UTC
Hi Eli

Please do with this the same as with taskcleaner.sh and put it in the different folder.

Thanks.

Comment 8 Eli Mesika 2013-05-08 17:28:08 UTC
We had found a problem in fkvalidator when the child table has a value that not exists in the parent table but this value is null.
Moving BZ to POST in order to fix that as suggested by Moran

Comment 10 Itamar Heim 2013-06-11 09:45:19 UTC
3.2 has been released

Comment 11 Itamar Heim 2013-06-11 09:45:20 UTC
3.2 has been released

Comment 12 Itamar Heim 2013-06-11 09:55:56 UTC
3.2 has been released