From b88a555f5a584c355442ee8db6d218c9fe95fa36 Mon Sep 17 00:00:00 2001
From: Yannick Lecaillez <ylecaillez@forgerock.com>
Date: Tue, 17 Nov 2015 10:16:04 +0000
Subject: [PATCH] OPENDJ-2393: Possible index corruption

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 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 cfc6bf6..876b13c 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
@@ -66,8 +66,11 @@
    * A flag to indicate if this index should be trusted to be consistent with the entries tree.
    * If not trusted, we assume that existing entryIDSets for a key is still accurate. However, keys
    * that do not exist are undefined instead of an empty entryIDSet. The following rules will be
-   * observed when the index is not trusted: - no entryIDs will be added to a non-existing key. -
-   * undefined entryIdSet will be returned whenever a key is not found.
+   * observed when the index is not trusted:
+   * <ul>
+   * <li>no entryIDs will be added to a non-existing key.</li>
+   * <li>undefined entryIdSet will be returned whenever a key is not found.</li>
+   * </ul>
    */
   private volatile boolean trusted;
 
@@ -95,7 +98,7 @@
   }
 
   @Override
-  final void open0(WriteableTransaction txn)
+  final void afterOpen(WriteableTransaction txn)
   {
     final EnumSet<IndexFlag> flags = state.getIndexFlags(txn, getName());
     codec = flags.contains(COMPACTED) ? CODEC_V2 : CODEC_V1;
@@ -154,21 +157,6 @@
   public final void update(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs,
       final EntryIDSet addedIDs) throws StorageRuntimeException
   {
-    /*
-     * Check the special condition where both deletedIDs and addedIDs are null. This is used when
-     * deleting entries must be completely removed.
-     */
-    if (deletedIDs == null && addedIDs == null)
-    {
-      boolean success = txn.delete(getName(), key);
-      if (!success && logger.isTraceEnabled())
-      {
-        logger.trace("The expected key does not exist in the index %s.\nKey:%s ",
-            getName(), key.toHexPlusAsciiString(4));
-      }
-      return;
-    }
-
     // Handle cases where nothing is changed early to avoid DB access.
     if (isNullOrEmpty(deletedIDs) && isNullOrEmpty(addedIDs))
     {

--
Gitblit v1.10.0