From 7c62a0f60797135b8e41a6ddd4bfbcceb6f765c4 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 04 Dec 2013 11:05:46 +0000
Subject: [PATCH] Fixing stalled builds. Fixed problem introduced in r9887: an open cursor was never released.
---
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java | 35 +++++++++++++----------------------
1 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
index 79f3513..acbe030 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDB.java
@@ -55,6 +55,7 @@
/**
* This class implements the interface between the underlying database
* and the JEReplicaDB class.
+ * <p>
* This is the only class that should have code using the BDB interfaces.
*/
public class ReplicationDB
@@ -137,7 +138,6 @@
replicationServer.getReplicationServerDomain(baseDN, true);
db = dbenv.getOrAddDb(serverId, baseDN, domain.getGenerationId());
-
intializeCounters();
}
@@ -184,7 +184,6 @@
return new CSN(decodeUTF8(data));
}
-
/**
* add a list of changes to the underlying db.
*
@@ -203,8 +202,7 @@
for (UpdateMsg change : changes)
{
- final DatabaseEntry key =
- createReplicationKey(change.getCSN());
+ final DatabaseEntry key = createReplicationKey(change.getCSN());
final DatabaseEntry data = new ReplicationData(change);
insertCounterRecordIfNeeded(change.getCSN());
@@ -309,8 +307,6 @@
return new ReplServerDBCursor();
}
-
-
private void closeAndReleaseReadLock(Cursor cursor)
{
try
@@ -378,8 +374,6 @@
}
}
-
-
/**
* Read the newest CSN present in the database.
*
@@ -617,14 +611,13 @@
}
catch (DatabaseException e)
{
- StaticUtils.close(localCursor);
throw new ChangelogException(e);
}
finally
{
if (!cursorHeld)
{
- dbCloseLock.readLock().unlock();
+ closeAndReleaseReadLock(localCursor);
}
}
}
@@ -662,13 +655,11 @@
}
catch (ChangelogException e)
{
- StaticUtils.close(localCursor);
abort(localTxn);
throw e;
}
catch (Exception e)
{
- StaticUtils.close(localCursor);
abort(localTxn);
throw new ChangelogException(e);
}
@@ -676,7 +667,7 @@
{
if (!cursorHeld)
{
- dbCloseLock.readLock().unlock();
+ closeAndReleaseReadLock(localCursor);
}
}
}
@@ -809,7 +800,8 @@
{
return null;
}
- } catch (DatabaseException e)
+ }
+ catch (DatabaseException e)
{
return null;
}
@@ -895,12 +887,11 @@
// RE-create the db
db = dbenv.getOrAddDb(serverId, baseDN, -1);
}
- catch(Exception e)
+ catch (Exception e)
{
MessageBuilder mb = new MessageBuilder();
mb.append(ERR_ERROR_CLEARING_DB.get(toString(),
- e.getMessage() + " " +
- stackTraceToSingleLineString(e)));
+ e.getMessage() + " " + stackTraceToSingleLineString(e)));
logError(mb.toMessage());
}
finally
@@ -909,6 +900,7 @@
dbCloseLock.writeLock().unlock();
}
}
+
/**
* Count the number of changes between 2 changes numbers (inclusive).
* @param start The lower limit of the count.
@@ -966,9 +958,8 @@
return 0;
}
-
- private void findFirstCounterRecordAfterStartPoint(CSN start,
- CSN stop, int[] counterValues, int[] distanceToCounterRecords)
+ private void findFirstCounterRecordAfterStartPoint(CSN start, CSN stop,
+ int[] counterValues, int[] distanceToCounterRecords)
throws DatabaseException
{
Cursor cursor = db.openCursor(null, null);
@@ -1020,8 +1011,8 @@
}
}
- private boolean findFirstCounterRecordBeforeStopPoint(CSN start,
- CSN stop, int[] counterValues, int[] distanceToCounterRecords)
+ private boolean findFirstCounterRecordBeforeStopPoint(CSN start, CSN stop,
+ int[] counterValues, int[] distanceToCounterRecords)
throws DatabaseException
{
Cursor cursor = db.openCursor(null, null);
--
Gitblit v1.10.0