Bug 233215

Summary: verify-db.pl still assumes the db dir is always in the instance dir
Product: [Retired] 389 Reporter: Noriko Hosoi <nhosoi>
Component: Command Line UtilitiesAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: high Docs Contact:
Priority: high    
Version: 1.0.4   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:46:44 UTC Type: ---
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: 152373, 240316, 427409    
Attachments:
Description Flags
cvs diff template-verify-db.pl.in
none
cvs commit message
none
(* cvs diff create_instance.c (* create_instance.c.diff in Comment #7)
none
svn diff db4.template (** db4.template.diff in Comment #7)
none
cvs diff ldapserver/m4/db.m4 (*** db.m4.diff)
none
Proposed patch (**** patch.4.2.52.txn)
none
cvs commit messages
none
cvs commit message
none
cvs commit message none

Description Noriko Hosoi 2007-03-20 23:12:26 UTC
Description of problem:
The command line utility failed to be updated with the FHS change.

If the db is not in the instance dir (or the directory where verify-db.pl is
located), it does not check the db files.

Comment 1 Noriko Hosoi 2007-03-21 17:28:19 UTC
Created attachment 150603 [details]
cvs diff template-verify-db.pl.in

File: ldap/admin/src/scripts/template-verify-db.pl.in

Changes:
0) eliminated the "current directory" from the utility.  Now, it can be run
from  any location.
1) changed to take a new option [-a <fullpath_to_db_dir> ] to allow specifying
the db dir/changelog dir; by default the start point is "db_dir"
(nsslapd-directory in cn=config,cn=ldbm database,cn=plugins,cn=config)
2) instead of assuming the db dir structure (e.g.,
db/<backend_instance>/<db_files>), now it checks all the db files found under
the specified path.  This allows to run the utility against the backup files,
as well.

Comment 2 Rich Megginson 2007-03-21 17:38:02 UTC
Ok.

Comment 3 Noriko Hosoi 2007-03-21 17:43:42 UTC
Created attachment 150606 [details]
cvs commit message

Reviewed by Rich (Thank you!)

Checked in into HEAD.

Comment 7 Noriko Hosoi 2007-03-30 01:30:24 UTC
There are mutiple problems found around verify-db.pl on Solaris... :(

1, I introduced "DB-DIR" macro for template-verify-db.pl.in, but the
corresponding version if create_instance.c hasn't been checked in yet (*
create_instance.c.diff is being attached)
2. template-verify-db.in has the following envirament variable PATH set:
    $ENV{'PATH'} = "$prefix@db_bindir@:$prefix/usr/bin:@db_bindir@:/usr/bin";
    And the derived verify-db.pl on 64-bit Solaris looks like this:
    $ENV{'PATH'} = "$prefix/usr/bin:$prefix/usr/bin:/usr/bin:/usr/bin";
2-1. The problem is db_* utilities on 64-bit Solaris are installed in
/usr/bin/sparcv9, thus verify-db.pl fails to find the executables and exits.
2-2. To get the right path, db4 packaging is supposed to generate db.pc and put
the file in /usr/lib/sparcv9/pkgconfig, but svn:pkgs/db4 spec file does not have
the code (** db4.template.diff is being attached)  Note: the system Berkeley DB
on RHELs has db.pc in /usr/lib/pkgconfig.
2-3. Even though db.pc is placed in the right place, ldapserver/m4/db.m4 does
not check db.pc with pkg-config, but sets the hardcoded path /usr/bin to
db_bindir (*** db.m4.diff is being attached)
3. With all the above fixes, ran verify-db.pl, then one of the Berkeley DB
utilities db_printlog crashed...  The cause of the crash was a field called
timestamp is declared as int32_t, but the pointer to the value is casted to
(time_t *), where time_t is 64 bits on the 64-bit machine.  The cast mismatch
makes ctime/localtime fail and it leads the utility crash.   I looked at the db
4.4.20 code, and verified it was fixed.  I back-ported the change to 4.2.52 and
made a patch since I could not find the patch on the Sleepycat site. (****
patch.4.2.52.txn is being attached)

Comment 8 Noriko Hosoi 2007-03-30 01:32:55 UTC
Created attachment 151245 [details]
(*
cvs diff create_instance.c (* create_instance.c.diff in Comment #7)

File: ldap/admin/src/create_instance.c

Change: 
1, I introduced "DB-DIR" macro for template-verify-db.pl.in, but the
corresponding version if create_instance.c hasn't been checked in yet.

Comment 9 Noriko Hosoi 2007-03-30 01:37:53 UTC
Created attachment 151246 [details]
svn diff db4.template (** db4.template.diff in Comment #7)

File: svn:rpms/pkgs/db4/SPECS/db4.template

Changes: 
1) added a code to generate db.pc for pkg-config
2) apply a patch to fix the db_printlog crash problem.	The patch proposal is
being attached later (**** patch.4.2.52.txn)

Comment 10 Noriko Hosoi 2007-03-30 01:42:23 UTC
Created attachment 151247 [details]
cvs diff ldapserver/m4/db.m4 (*** db.m4.diff)

File: ldapserver/m4/db.m4

Change: To set db_bindir, if db.pc exists, check if bindir variable is defined
in the file or not.  If it's defined, set it to db_bindir.  If not, set the
default path /usr/bin to db_bindir.

Comment 11 Noriko Hosoi 2007-03-30 01:47:16 UTC
Created attachment 151248 [details]
Proposed patch (**** patch.4.2.52.txn)

File: svn:rpms/pkgs/db4/SOURCES/patch.4.2.52.txn

Fix Description: The cause of the db_printlog crash was the unexpected cast
from  the pointer to the 32-bit integer to the pointer to time_t/long (64-bit).
 The patch is a back-port from db 4.4.20, where the problem was already fixed.

Comment 12 Nathan Kinder 2007-03-30 17:51:30 UTC
The changes look good.

Comment 13 Noriko Hosoi 2007-03-30 18:22:10 UTC
Created attachment 151305 [details]
cvs commit messages

Reviewed by Nathan (Thank you!!)

Checked in into HEAD.

I'm rebuilding RHATdb4x packages for Solaris...

Comment 14 Noriko Hosoi 2007-04-12 18:59:42 UTC
After the check-in in Comment #10, I forgot to check in these derived files, and
the fix was not used indeed... :(
  Makefile.in
  aclocal.m4
  configure
  ltmain.sh

(In reply to comment #10)
> Created an attachment (id=151247) [edit]
> cvs diff ldapserver/m4/db.m4 (*** db.m4.diff)
> File: ldapserver/m4/db.m4
> Change: To set db_bindir, if db.pc exists, check if bindir variable is defined
> in the file or not.  If it's defined, set it to db_bindir.  If not, set the
> default path /usr/bin to db_bindir.



Comment 15 Noriko Hosoi 2007-04-12 21:07:11 UTC
Created attachment 152506 [details]
cvs commit message

Thank you for the approval, Rich and Nathan.

Checked in into HEAD.

Comment 16 Noriko Hosoi 2007-04-13 18:09:50 UTC
It finally worked on Solaris.
520|6 6 8760 1 1|CLU Utilities test: verify
520|6 6 8760 1 2|--------------------------
520|6 6 8760 1 3|1) verify-db.pl -a <db_dir> from /tmp
520|6 6 8760 1 4|-------------------------------------
520|6 6 8760 1 5|Verify db (from /tmp with -a option): passed
520|6 6 8760 1 6|2) verify-db.pl from
/export/DS7.2-26189/server/slapd-agamemnon/../slapd-utiltest
520|6 6 8760 1 7|-----------------------------
520|6 6 8760 1 8|Verify db (from MYIROOT with no option): passed
520|6 6 8760 1 9|3) run verify-db.pl against broken db
520|6 6 8760 1 10|-------------------------------------
520|6 6 8760 1 11|Verify db: failed as expected
520|6 6 8760 1 12|ERROR MESSAGE:
520|6 6 8760 1 13|DB ERROR: db_verify:
/export/DS7.2-26189/server/slapd-agamemnon/../slapd-utiltest/db/userRoot/id2entry.db4:
unexpected file type or format DB
ERROR: db_verify: DB->open:
/export/DS7.2-26189/server/slapd-agamemnon/../slapd-utiltest/db/userRoot/id2entry.db4:
Invalid argument
220|6 6 0 04:48:56|PASS


Comment 19 Noriko Hosoi 2007-12-06 02:50:26 UTC
Created attachment 279051 [details]
cvs commit message

Reviewed by Rich (Thank you!!)

Checked in into TET CVS HEAD.