ebc913e
From a2fb904458713b493e3b84bafa1771675d1bced9 Mon Sep 17 00:00:00 2001
ebc913e
From: Rich Megginson <rmeggins@redhat.com>
ebc913e
Date: Sat, 7 Apr 2012 09:05:18 -0600
ebc913e
Subject: [PATCH 3/4] Ticket #336 - [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
ebc913e
ebc913e
https://fedorahosted.org/389/ticket/336
ebc913e
Resolves: Ticket #336
ebc913e
Bug Description: [abrt] 389-ds-base-1.2.10.4-2.fc16: index_range_read_ext: Process /usr/sbin/ns-slapd was killed by signal 11 (SIGSEGV)
ebc913e
Reviewed by: nhosoi (Thanks!)
ebc913e
Branch: 389-ds-base-1.2.10
ebc913e
Fix Description:
ebc913e
1) Entries can be deleted out from under a search operation.  The range read
ebc913e
code was not handling this situation correctly.  The code should notice that
ebc913e
the index query was empty, and continue to the next highest key in the range.
ebc913e
2) DB cursor c_close() functions can return DB_LOCK_DEADLOCK that must be
ebc913e
reported to the higher level operation functions.  If not, then subsequent
ebc913e
operations in the same transaction fail.  When a DB_LOCK_DEADLOCK is returned
ebc913e
by any DB update operation in the transaction, the transaction must be aborted
ebc913e
and a new transaction begun before any other transacted db operations can
ebc913e
occur.
ebc913e
Platforms tested: RHEL6 x86_64
ebc913e
Flag Day: no
ebc913e
Doc impact: no
ebc913e
BZ: 808770
ebc913e
(cherry picked from commit d09ce0e3ab2ea24496ee44622b050e007bb3cb8a)
ebc913e
---
ebc913e
 ldap/servers/slapd/back-ldbm/index.c |   25 +++++++++++++++++--------
ebc913e
 1 files changed, 17 insertions(+), 8 deletions(-)
ebc913e
ebc913e
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
ebc913e
index 0ed6918..0ede6de 100644
ebc913e
--- a/ldap/servers/slapd/back-ldbm/index.c
ebc913e
+++ b/ldap/servers/slapd/back-ldbm/index.c
ebc913e
@@ -1496,14 +1496,23 @@ index_range_read_ext(
ebc913e
         if(retry_count == IDL_FETCH_RETRY_COUNT) {
ebc913e
           ldbm_nasty("index_range_read retry count exceeded",1095,*err);
ebc913e
         }
ebc913e
-        tmp2 = idl_union( be, idl, tmp );
ebc913e
-        idl_free( idl );
ebc913e
-        idl_free( tmp );
ebc913e
-        idl = tmp2;
ebc913e
-        if (ALLIDS(idl)) {
ebc913e
-            LDAPDebug(LDAP_DEBUG_TRACE, "index_range_read hit an allids value\n",
ebc913e
-                      0, 0, 0);
ebc913e
-            break;
ebc913e
+        if (!idl) {
ebc913e
+            if (slapi_is_loglevel_set(LDAP_DEBUG_TRACE)) {
ebc913e
+                char encbuf[BUFSIZ];
ebc913e
+                LDAPDebug2Args(LDAP_DEBUG_TRACE,
ebc913e
+                               "index_range_read_ext: cur_key=%s(%li bytes) was deleted - skipping\n",
ebc913e
+                               encoded(&cur_key, encbuf), (long)cur_key.dsize);
ebc913e
+            }
ebc913e
+        } else {
ebc913e
+            tmp2 = idl_union( be, idl, tmp );
ebc913e
+            idl_free( idl );
ebc913e
+            idl_free( tmp );
ebc913e
+            idl = tmp2;
ebc913e
+            if (ALLIDS(idl)) {
ebc913e
+                LDAPDebug(LDAP_DEBUG_TRACE, "index_range_read hit an allids value\n",
ebc913e
+                          0, 0, 0);
ebc913e
+                break;
ebc913e
+            }
ebc913e
         }
ebc913e
         if (DBT_EQ (&cur_key, &upperkey)) { /* this is the last key */
ebc913e
             break;
ebc913e
-- 
ebc913e
1.7.1
ebc913e