From 9f0904fda87bfcf921deeccdbaeafe834fbad696 Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <yannick.lecaillez@forgerock.com>
Date: Fri, 24 Apr 2015 14:30:47 +0000
Subject: [PATCH] OPENDJ-1725: Persistit: very long recovery and many discarded txns after addrate test

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java |   41 +++++++++--------------------------------
 1 files changed, 9 insertions(+), 32 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
index 14ceb70..bd68494 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
@@ -60,10 +60,6 @@
 
   /** The limit on the number of entry IDs that may be indexed by one key. */
   private int indexEntryLimit;
-  /**
-   * Whether to maintain a count of IDs for a key once the entry limit has exceeded.
-   */
-  private final boolean maintainCount;
 
   private final State state;
 
@@ -87,8 +83,6 @@
    *          The state database to persist index state info.
    * @param indexEntryLimit
    *          The configured limit on the number of entry IDs that may be indexed by one key.
-   * @param maintainCount
-   *          Whether to maintain a count of IDs for a key once the entry limit has exceeded.
    * @param txn
    *          a non null database transaction
    * @param entryContainer
@@ -96,12 +90,11 @@
    * @throws StorageRuntimeException
    *           If an error occurs in the database.
    */
-  DefaultIndex(TreeName name, State state, int indexEntryLimit, boolean maintainCount, WriteableTransaction txn,
-      EntryContainer entryContainer) throws StorageRuntimeException
+  DefaultIndex(TreeName name, State state, int indexEntryLimit, WriteableTransaction txn, EntryContainer entryContainer)
+      throws StorageRuntimeException
   {
     super(name);
     this.indexEntryLimit = indexEntryLimit;
-    this.maintainCount = maintainCount;
     this.state = state;
 
     final EnumSet<IndexFlag> flags = state.getIndexFlags(txn, getName());
@@ -137,7 +130,7 @@
     ByteString value = txn.read(getName(), key);
     if (value != null)
     {
-      final ImportIDSet importIDSet = new ImportIDSet(key, codec.decode(key, value), indexEntryLimit, maintainCount);
+      final ImportIDSet importIDSet = new ImportIDSet(key, codec.decode(key, value), indexEntryLimit);
       importIDSet.merge(idsToBeAdded);
       txn.put(getName(), key, importIDSet.valueToByteString(codec));
     }
@@ -154,7 +147,7 @@
     ByteString value = txn.read(getName(), key);
     if (value != null)
     {
-      final ImportIDSet importIDSet = new ImportIDSet(key, codec.decode(key, value), indexEntryLimit, maintainCount);
+      final ImportIDSet importIDSet = new ImportIDSet(key, codec.decode(key, value), indexEntryLimit);
       importIDSet.remove(idsToBeRemoved);
       if (importIDSet.isDefined() && importIDSet.size() == 0)
       {
@@ -178,8 +171,7 @@
   {
     /*
      * Check the special condition where both deletedIDs and addedIDs are null. This is used when
-     * deleting entries and corresponding id2children and id2subtree records must be completely
-     * removed.
+     * deleting entries must be completely removed.
      */
     if (deletedIDs == null && addedIDs == null)
     {
@@ -203,7 +195,7 @@
      * Avoid taking a write lock on a record which has hit all IDs because it is likely to be a
      * point of contention.
      */
-    if (!maintainCount && !get(txn, key).isDefined())
+    if (!get(txn, key).isDefined())
     {
       return;
     }
@@ -241,12 +233,12 @@
     });
   }
 
-  private boolean isNullOrEmpty(EntryIDSet entryIDSet)
+  private static boolean isNullOrEmpty(EntryIDSet entryIDSet)
   {
     return entryIDSet == null || entryIDSet.size() == 0;
   }
 
-  private boolean isNotEmpty(EntryIDSet entryIDSet)
+  private static boolean isNotEmpty(EntryIDSet entryIDSet)
   {
     return entryIDSet != null && entryIDSet.size() > 0;
   }
@@ -265,22 +257,13 @@
         }
         if (idCountDelta + entryIDSet.size() >= indexEntryLimit)
         {
-          if (maintainCount)
-          {
-            entryIDSet = newUndefinedSetWithSize(key, entryIDSet.size() + idCountDelta);
-          }
-          else
-          {
-            entryIDSet = newUndefinedSet();
-          }
-
+          entryIDSet = newUndefinedSetWithKey(key);
           if (logger.isTraceEnabled())
           {
             StringBuilder builder = new StringBuilder();
             StaticUtils.byteArrayToHexPlusAscii(builder, key.toByteArray(), 4);
             logger.trace("Index entry exceeded in index %s. " + "Limit: %d. ID list size: %d.\nKey:%s", getName(),
                 indexEntryLimit, idCountDelta + addedIDs.size(), builder);
-
           }
         }
         else
@@ -373,10 +356,4 @@
   {
     return trusted;
   }
-
-  @Override
-  public final boolean getMaintainCount()
-  {
-    return maintainCount;
-  }
 }

--
Gitblit v1.10.0