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/IndexBuffer.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
index c4682a3..9469591 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/IndexBuffer.java
@@ -55,6 +55,8 @@
{
void flush(WriteableTransaction txn) throws StorageRuntimeException, DirectoryException;
+ void writeTrustState(WriteableTransaction txn) throws StorageRuntimeException;
+
void put(Index index, ByteString key, EntryID entryID);
void put(VLVIndex index, ByteString sortKey);
@@ -62,6 +64,8 @@
void remove(VLVIndex index, ByteString sortKey);
void remove(Index index, ByteString key, EntryID entryID);
+
+ void reset();
}
/**
@@ -214,6 +218,21 @@
}
@Override
+ public void writeTrustState(WriteableTransaction txn)
+ {
+ // Indexes cache the index trust flag. Ensure that the cached value is written into the db.
+ for (Index index : bufferedIndexes.keySet())
+ {
+ index.setTrusted(txn, index.isTrusted());
+ }
+
+ for (VLVIndex index : bufferedVLVIndexes.keySet())
+ {
+ index.setTrusted(txn, index.isTrusted());
+ }
+ }
+
+ @Override
public void put(Index index, ByteString key, EntryID entryID)
{
createOrGetBufferedIndexValues(index, key).addEntryID(entryID);
@@ -246,6 +265,13 @@
index.update(txn, entry.getKey(), values.deletedEntryIDs, values.addedEntryIDs);
}
}
+
+ @Override
+ public void reset()
+ {
+ bufferedIndexes.clear();
+ bufferedVLVIndexes.clear();
+ }
}
/**
@@ -285,6 +311,12 @@
}
@Override
+ public void writeTrustState(WriteableTransaction txn)
+ {
+ // Nothing to do
+ }
+
+ @Override
public void remove(VLVIndex index, ByteString sortKey)
{
throw new UnsupportedOperationException();
@@ -295,6 +327,12 @@
{
throw new UnsupportedOperationException();
}
+
+ @Override
+ public void reset()
+ {
+ throw new UnsupportedOperationException();
+ }
}
private final IndexBufferImplementor impl;
@@ -329,6 +367,19 @@
impl.flush(txn);
}
+ /**
+ * Indexes might cache their trust state. This ensure that the cached state is persisted into the database.
+ *
+ * @param txn
+ * a non null transaction
+ * @throws StorageRuntimeException
+ * If an error occurs in the storage.
+ */
+ void writeTrustState(WriteableTransaction txn)
+ {
+ impl.writeTrustState(txn);
+ }
+
void put(Index index, ByteString key, EntryID entryID)
{
impl.put(index, key, entryID);
@@ -348,4 +399,9 @@
{
impl.remove(index, key, entryID);
}
+
+ void reset()
+ {
+ impl.reset();
+ }
}
--
Gitblit v1.10.0