Browse Source

Bug 644608 - RHDS 8.1->8.2 upgrade fails to properly migrate ACIs

https://bugzilla.redhat.com/show_bug.cgi?id=644608

Description: Adding the ancestorid fix code to ##upgradednformat.pl.
The upgrade utility upgradednformat in the previous version could
have broken the ancestorid index file.  The ID list in the updated
index value may not be in the ascendant order.  This patch checks
the ID order in the ID lists.  Once it detects the disorder, it
reindexes the corrupted ancestorid.
Noriko Hosoi 15 years ago
parent
commit
13b9aff869
1 changed files with 35 additions and 0 deletions
  1. 35 0
      ldap/admin/src/scripts/80upgradednformat.pl

+ 35 - 0
ldap/admin/src/scripts/80upgradednformat.pl

@@ -122,6 +122,7 @@ sub runinst {
             #                -1 -- error
             my $escapes = system("$upgradednformat -n $backend -a $dbinstdir -N");
             if (0 == $escapes) {
+                # need to upgrade dn format
                 my $rc = 0;
 
                 if (system("cd $pdbdir; tar cf - db/DBVERSION | (cd $dbinstdir; tar xf -)") ||
@@ -161,6 +162,40 @@ sub runinst {
                     rmdir("$dbinstdir/dnupgrade");
                     return ("error_cant_convert_db", $backend, $rc);
                 }
+            } else {
+                # already upgraded or an error occurred.
+                # check ancestorid to see if it has not-sorted ID list or not.
+                my $ancestorid = $dbinstdir . "/ancestorid.db4";
+                if (-e "$ancestorid") {
+                    my $disorder = 0;
+                    open(ANCESTOR, "/usr/bin/dbscan -f $ancestorid -r |");
+                    while (<ANCESTOR>) {
+                        if (!/^=[0-9]*/) {
+                            chomp($_);
+                            my @IDs = split(/ |	/, $_);
+                            # print "ID count: $#IDs\n";
+                            my $lasti = $#IDs;
+                            for (my $i = 1; $i < $lasti; $i++) {
+                                if ($IDs[$i] >= $IDs[$i + 1]) {
+                                    $disorder = 1;
+                                    last;
+                                }
+                            }
+                            # print "Result: $disorder \n";
+                            if ($disorder) {
+                                last;
+                            }
+                        }
+                    }
+                    close(ANCESTOR);
+
+                    # ancestorid index is in disorder; need to reindex it.
+                    if ($disorder) {
+                        print "The ancestorid index in $backend is in disorder; Reindexing $ancestorid.\n";
+                        my $reindex = $instancedir . "/db2index";
+                        my $rc = system("$reindex -n $backend -t ancestorid");
+                    }
+                }
             }
         }