From 8c65daf79d1c7fbe47f556c4d4bba2c2859851d1 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Mon, 21 Apr 2008 21:08:12 +0000
Subject: [PATCH] This patch adds index buffering capabilities to the JE backend as to avoid using a fixed lock timeout for subtree delete and mod DN operations. Previously, any index modifications to subordinate entries of the affected operations will be performed with dn2id and id2entry modifications. This creates multiple random access to index database keys which could cause deadlocks in face of multiple parallel operations. With this fix, all index modifications are buffered up until the end of the operation so that each key of each index will be accessed once and in order. This maintains the DB access ordering in the JE backend of dn2id, id2entry, dn2uri, indexes in config order, VLV indexes in config order, and finally id2children and id2subtree. Since deadlocks should no longer occur in the JE backend, JE lock timeouts are now disabled at the JE environment level instead of the txn level. With this change, the performance of subtree deletes and mod DN operations have increased dramatically.

---
 opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
index e600889..630334a 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/WorkThread.java
@@ -39,6 +39,7 @@
 import java.util.*;
 import com.sleepycat.je.DatabaseException;
 import com.sleepycat.je.Transaction;
+import com.sleepycat.je.LockMode;
 
 /**
  * A thread to process import entries from a queue.  Multiple instances of
@@ -410,9 +411,9 @@
   private EntryID getAncestorID(DN2ID dn2id, DN dn, Transaction txn)
           throws DatabaseException {
     int i=0;
-    EntryID nodeID = dn2id.get(txn, dn);
+    EntryID nodeID = dn2id.get(txn, dn, LockMode.DEFAULT);
     if(nodeID == null) {
-      while((nodeID = dn2id.get(txn, dn)) == null) {
+      while((nodeID = dn2id.get(txn, dn, LockMode.DEFAULT)) == null) {
         try {
           Thread.sleep(50);
           if(i == 3) {
@@ -444,12 +445,12 @@
     DN2ID dn2id = context.getEntryContainer().getDN2ID();
     LDIFImportConfig ldifImportConfig = context.getLDIFImportConfig();
     DN entryDN = entry.getDN();
-    EntryID entryID = dn2id.get(txn, entryDN);
+    EntryID entryID = dn2id.get(txn, entryDN, LockMode.DEFAULT);
     if (entryID != null) {
       if (ldifImportConfig.appendToExistingData() &&
               ldifImportConfig.replaceExistingEntries()) {
         ID2Entry id2entry = context.getEntryContainer().getID2Entry();
-        Entry existingEntry = id2entry.get(txn, entryID);
+        Entry existingEntry = id2entry.get(txn, entryID, LockMode.DEFAULT);
         element.setExistingEntry(existingEntry);
       } else {
         Message msg = WARN_JEB_IMPORT_ENTRY_EXISTS.get();

--
Gitblit v1.10.0