[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldif2ldbm.c, 1.12, 1.13 vlv_srch.c, 1.7, 1.8

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Thu Sep 20 16:58:43 UTC 2007


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32368/back-ldbm

Modified Files:
	ldif2ldbm.c vlv_srch.c 
Log Message:
Resolves: #243820
Summary: Online browsing indexing hangs
Description:
1. adding more shutdown checks in the indexing code to achieve the swift
shutdown even in the long running browsing indexing.
2. in the error case, cleaning up the index file.
3. found minor memory leaks.



Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ldif2ldbm.c	13 Dec 2006 22:21:22 -0000	1.12
+++ ldif2ldbm.c	20 Sep 2007 16:58:41 -0000	1.13
@@ -1264,7 +1264,7 @@
     int              numvlv = 0;
     int              return_value = -1;
     ID               temp_id;
-    int              i, j;
+    int              i, j, vlvidx;
     ID               lastid;
     struct backentry *ep;
     char             *type;
@@ -1277,6 +1277,9 @@
     int              index_aid = 0;          /* index ancestorid */
 
     LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2index\n", 0, 0, 0 );
+    if ( g_get_shutdown() || c_get_shutdown() ) {
+        return -1;
+    }
         
     slapi_pblock_get(pb, SLAPI_BACKEND_INSTANCE_NAME, &instance_name);
     slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li);
@@ -1387,6 +1390,10 @@
 
         slapi_pblock_get(pb, SLAPI_DB2INDEX_ATTRS, &attrs);
         for (i = 0; attrs[i] != NULL; i++) {
+            if ( g_get_shutdown() || c_get_shutdown() ) {
+                ret = -1;
+                goto out;
+            }
             switch(attrs[i][0]) {
             case 't':        /* attribute type to index */
                 db2index_add_indexed_attr(be, attrs[i]);
@@ -1495,6 +1502,10 @@
      */
     vlv_acquire_lock(be);
     while (1) {
+        if ( g_get_shutdown() || c_get_shutdown() ) {
+            ret = -1;
+            goto out;
+        }
         if (idl) {
             if (idindex >= idl->b_nids)
                 break;
@@ -1597,6 +1608,10 @@
 
                 slapi_attr_get_type( attr, &type );
                 for ( j = 0; indexAttrs[j] != NULL; j++ ) {
+                    if ( g_get_shutdown() || c_get_shutdown() ) {
+                        ret = -1;
+                        goto out;
+                    }
                     if (slapi_attr_type_cmp(indexAttrs[j], type,
                                             SLAPI_TYPE_CMP_SUBTYPE) == 0 ) {
                         back_txn txn;
@@ -1679,9 +1694,13 @@
         /*
          * Update the Virtual List View indexes
          */
-        for ( j = 0; j<numvlv; j++ ) {
+        for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
             back_txn txn;
             int rc = 0;
+            if ( g_get_shutdown() || c_get_shutdown() ) {
+                ret = -1;
+                goto out;
+            }
             if (run_from_cmdline)
             {
                 txn.back_txn_txn = NULL;
@@ -1693,7 +1712,7 @@
                 if (0 != rc) {
                     LDAPDebug(LDAP_DEBUG_ANY,
                       "%s: ERROR: failed to begin txn for update index '%s'\n",
-                      inst->inst_name, indexAttrs[j], 0);
+                      inst->inst_name, indexAttrs[vlvidx], 0);
                     LDAPDebug(LDAP_DEBUG_ANY,
                         "%s: Error %d: %s\n", inst->inst_name, rc,
                         dblayer_strerror(rc));
@@ -1701,20 +1720,20 @@
                         slapi_task_log_notice(task,
                          "%s: ERROR: failed to begin txn for update index '%s' "
                          "(err %d: %s)", inst->inst_name,
-                         indexAttrs[j], rc, dblayer_strerror(rc));
+                         indexAttrs[vlvidx], rc, dblayer_strerror(rc));
                     }
                     ret = -2;
                     goto out;
                 }
             }
-            vlv_update_index(pvlv[j], &txn, li, pb, NULL, ep);
+            vlv_update_index(pvlv[vlvidx], &txn, li, pb, NULL, ep);
             if (!run_from_cmdline)
             {
                 rc = dblayer_txn_commit(li, &txn);
                 if (0 != rc) {
                     LDAPDebug(LDAP_DEBUG_ANY,
                       "%s: ERROR: failed to commit txn for update index '%s'\n",
-                      inst->inst_name, indexAttrs[j], 0);
+                      inst->inst_name, indexAttrs[vlvidx], 0);
                     LDAPDebug(LDAP_DEBUG_ANY,
                         "%s: Error %d: %s\n", inst->inst_name, rc,
                         dblayer_strerror(rc));
@@ -1722,7 +1741,7 @@
                         slapi_task_log_notice(task,
                         "%s: ERROR: failed to commit txn for update index '%s' "
                         "(err %d: %s)", inst->inst_name,
-                        indexAttrs[j], rc, dblayer_strerror(rc));
+                        indexAttrs[vlvidx], rc, dblayer_strerror(rc));
                     }
                     ret = -2;
                     goto out;
@@ -1810,6 +1829,16 @@
     } else {
         dbc->c_close(dbc);
     }
+    if (ret < 0) {/* error case: undo vlv indexing */
+        struct vlvIndex *p = NULL;
+        /* if jumped to out due to an error, vlv lock has not been released */
+        vlv_release_lock(be);
+        for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+            p = pvlv[vlvidx];
+            vlvIndex_go_offline(p, be);
+            vlvIndex_delete(&p);
+        }
+    }
     dblayer_release_id2entry( be, db );
 
     instance_set_not_busy(inst);


Index: vlv_srch.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv_srch.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- vlv_srch.c	10 Nov 2006 23:45:39 -0000	1.7
+++ vlv_srch.c	20 Sep 2007 16:58:41 -0000	1.8
@@ -245,9 +245,9 @@
         for(pi= (*ppvs)->vlv_index;pi!=NULL;)
         {
             ni= pi->vlv_next;
-			if(pi->vlv_be != NULL) {
-				vlvIndex_go_offline(pi,pi->vlv_be);
-			}
+            if(pi->vlv_be != NULL) {
+                vlvIndex_go_offline(pi,pi->vlv_be);
+            }
             vlvIndex_delete(&pi);
             pi= ni;
         }
@@ -569,6 +569,8 @@
         }
         ldap_free_sort_keylist((*ppvs)->vlv_sortkey);
         attrinfo_delete(&((*ppvs)->vlv_attrinfo));
+        slapi_ch_free((void**)&((*ppvs)->vlv_name));
+        slapi_ch_free((void**)&((*ppvs)->vlv_filename));
         slapi_ch_free((void**)&((*ppvs)->vlv_mrpb));
         slapi_ch_free((void**)&((*ppvs)->vlv_syntax_plugin));
         PR_DestroyLock((*ppvs)->vlv_indexlength_lock);




More information about the Fedora-directory-commits mailing list