Browse Source

Ticket 47816 -v2- internal syncrepl searches are flagged as unindexed

Bug Description:  if syncrepl is enabled it uses an attribute targetuniqueid
			for internal searches. this is not indexed and
			lot of warnings are logged

Fix Description:   add an equality index to the default indexes
			for exising instances tit will add the index
			to the changelog backend and trigge a reindex

https://fedorahosted.org/389/ticket/47816

Reviewed by: ?
Ludwig Krispenz 11 years ago
parent
commit
0a69c4dfbe

+ 2 - 0
Makefile.am

@@ -565,6 +565,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/50fixNsState.pl \
 	ldap/admin/src/scripts/50telexnumbersyntaxplugin.ldif \
 	ldap/admin/src/scripts/50guidesyntaxplugin.ldif \
+	ldap/admin/src/scripts/50targetuniqueid.ldif \
 	ldap/ldif/50replication-plugins.ldif \
 	ldap/admin/src/scripts/50linkedattrsplugin.ldif \
 	$(POSIX_WINSYNC_PLUGIN_LDIF) \
@@ -579,6 +580,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/70upgradefromldif.pl \
 	ldap/admin/src/scripts/80upgradednformat.pl \
 	ldap/admin/src/scripts/81changelog.pl \
+	ldap/admin/src/scripts/82targetuniqueidindex.pl \
 	ldap/admin/src/scripts/90subtreerename.pl \
 	ldap/admin/src/scripts/91subtreereindex.pl \
 	ldap/admin/src/scripts/50updateconfig.ldif \

+ 2 - 0
Makefile.in

@@ -1973,6 +1973,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/50fixNsState.pl \
 	ldap/admin/src/scripts/50telexnumbersyntaxplugin.ldif \
 	ldap/admin/src/scripts/50guidesyntaxplugin.ldif \
+	ldap/admin/src/scripts/50targetuniqueid.ldif \
 	ldap/ldif/50replication-plugins.ldif \
 	ldap/admin/src/scripts/50linkedattrsplugin.ldif \
 	$(POSIX_WINSYNC_PLUGIN_LDIF) \
@@ -1987,6 +1988,7 @@ update_DATA = ldap/admin/src/scripts/exampleupdate.pl \
 	ldap/admin/src/scripts/70upgradefromldif.pl \
 	ldap/admin/src/scripts/80upgradednformat.pl \
 	ldap/admin/src/scripts/81changelog.pl \
+	ldap/admin/src/scripts/82targetuniqueidindex.pl \
 	ldap/admin/src/scripts/90subtreerename.pl \
 	ldap/admin/src/scripts/91subtreereindex.pl \
 	ldap/admin/src/scripts/50updateconfig.ldif \

+ 7 - 0
ldap/admin/src/scripts/50targetuniqueid.ldif

@@ -0,0 +1,7 @@
+dn: cn=targetuniqueid,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config
+changetype: add
+objectclass: top
+objectclass: nsIndex
+cn: targetuniqueid
+nssystemindex: true
+nsindextype: eq

+ 52 - 0
ldap/admin/src/scripts/82targetuniqueidindex.pl

@@ -0,0 +1,52 @@
+use Mozilla::LDAP::Conn;
+use Mozilla::LDAP::Utils qw(normalizeDN);
+use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn);
+use DSUpdate qw(isOffline);
+
+sub runinst {
+    my ($inf, $inst, $dseldif, $conn) = @_;
+
+    my $rc, @errs;
+
+    my $config = $conn->search("cn=config", "base", "(objectclass=*)");
+    if (!$config) {
+        push @errs, ['error_finding_config_entry', 'cn=config',
+                     $conn->getErrorString()];
+        return @errs;
+    }
+
+    ($rc, @errs) = isOffline($inf, $inst, $conn);
+    if (!$rc) {
+        return @errs;
+    }
+
+    my $retrocldb = $conn->search("cn=changelog,cn=ldbm database,cn=plugins,cn=config", "base", "(objectclass=*)");
+    if (!$retrocldb) {
+        return (); # retrocl is not enabled; do nothing
+    }
+
+    my $indexdn = "cn=targetuniqueid,cn=index,cn=changelog,cn=ldbm database,cn=plugins,cn=config";
+    my $targetuiniqidindex = $conn->search($indexdn, "base", "(objectclass=*)");
+    if ($targetuiniqidindex) {
+        return (); # targetuiniqidindex is alredy defined; do nothing
+    }
+
+    # add the targetuniqeid index to the retrocl backend
+
+    my $entry = new Mozilla::LDAP::Entry();
+    $entry->setDN($indexdn);
+    $entry->setValues('objectclass', 'top', 'nsIndex');
+    $entry->setValues('cn', 'targetuniqueid');
+    $entry->setValues('nsSystemIndex', 'false');
+    $entry->setValues('nsIndexType', 'eq');
+    $conn->add($entry);
+
+    # reindex targetuniquueid
+    my $instancedir = $config->getValues('nsslapd-instancedir');
+    my $reindex = $instancedir . "/db2index";
+
+    my $rc = system("$reindex -n changelog -t targetuniqeid");
+
+
+    return @errs;
+}

+ 7 - 0
ldap/ldif/template-dse.ldif.in

@@ -974,6 +974,13 @@ cn: nsTombstoneCSN
 nssystemindex: true
 nsindextype: eq
 
+dn: cn=targetuniqueid,cn=default indexes, cn=config,cn=ldbm database,cn=plugins,cn=config
+objectclass: top
+objectclass: nsIndex
+cn: targetuniqueid
+nssystemindex: true
+nsindextype: eq
+
 dn: cn=monitor, cn=ldbm database, cn=plugins, cn=config
 objectclass: top
 objectclass: extensibleObject