From 420d0685be611af4544bcce545a380b9298c0d6a Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 28 May 2010 17:31:16 +0000
Subject: [PATCH] Fix for issue #4514 and #4533. Resolved some possible lock contention in ReplicationServerDomain, resulting in errors in logs.
---
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java | 60 ++++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 38 insertions(+), 22 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
index 2c6f204..5137ba4 100644
--- a/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -2110,10 +2110,13 @@
*
* @param generationId The new value of generationId.
*/
- synchronized public void initGenerationID(long generationId)
+ public void initGenerationID(long generationId)
{
- this.generationId = generationId;
- this.generationIdSavedStatus = true;
+ synchronized (generationIDLock)
+ {
+ this.generationId = generationId;
+ this.generationIdSavedStatus = true;
+ }
}
/**
@@ -2124,21 +2127,22 @@
* @param savedStatus The saved status of the generationId.
* @return The old generation id
*/
- synchronized public long changeGenerationId(long generationId,
- boolean savedStatus)
+ public long changeGenerationId(long generationId, boolean savedStatus)
{
- long oldGenerationId = this.generationId;
-
- if (this.generationId != generationId)
+ synchronized (generationIDLock)
{
- // we are changing of genId
- clearDbs();
+ long oldGenerationId = this.generationId;
- this.generationId = generationId;
- this.generationIdSavedStatus = savedStatus;
+ if (this.generationId != generationId)
+ {
+ // we are changing of genId
+ clearDbs();
+
+ this.generationId = generationId;
+ this.generationIdSavedStatus = savedStatus;
+ }
+ return oldGenerationId;
}
-
- return oldGenerationId;
}
/**
@@ -2564,18 +2568,20 @@
* @return The monitor data.
* @throws DirectoryException When an error occurs.
*/
- synchronized protected MonitorData computeMonitorData(
- boolean updateMonitorData)
+ protected MonitorData computeMonitorData(boolean updateMonitorData)
throws DirectoryException
{
- if (updateMonitorData)
+ synchronized (monitoringLock)
{
- // Update the monitorData of ALL domains if this was necessary.
- replicationServer.computeMonitorData();
- }
+ if (updateMonitorData)
+ {
+ // Update the monitorData of ALL domains if this was necessary.
+ replicationServer.computeMonitorData();
+ }
- // Returns the monitorData of THIS domain
- return monitorData;
+ // Returns the monitorData of THIS domain
+ return monitorData;
+ }
}
/**
@@ -2859,6 +2865,16 @@
private ReentrantLock lock = new ReentrantLock();
/**
+ * This lock is used to protect the monitoring computing.
+ */
+ private final Object monitoringLock = new Object();
+
+ /**
+ * This lock is used to protect the generationid variable.
+ */
+ private final Object generationIDLock = new Object();
+
+ /**
* Tests if the current thread has the lock on this domain.
* @return True if the current thread has the lock.
*/
--
Gitblit v1.10.0