From a32bc83b64f0f82d731980a433a2180fe4f366f3 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 20 Jun 2013 15:02:35 +0000
Subject: [PATCH] Fix for OPENDJ-846, Intermittent Replication failure. The issue was triggered by the mix of AssuredReplication and bad network conditions, which resulted in a deadlock between 2 RS, as both were blocked on writing to the TCP socket and not reading (because waiting on the write lock). The solution (more of a workaround) is to have another thread for sending data to the socket and have the reader and writer posting data to send to a queue that this new thread is polling. There are still potential deadlocks but they will occur much later, if the sendQueue gets full. The code needs more work post 2.6 to be fully non blocking, but the changes are enough for now to resolve the customer deadlock case.
---
opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
index 7ba4c8e..23de638 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/service/ReplicationBroker.java
@@ -95,7 +95,7 @@
*/
public final static String NO_CONNECTED_SERVER = "Not connected";
private volatile String replicationServer = NO_CONNECTED_SERVER;
- private volatile ProtocolSession session = null;
+ private volatile Session session = null;
private final ServerState state;
private final String baseDn;
private final int serverId;
@@ -1230,7 +1230,7 @@
String port = server.substring(separator + 1);
String hostname = server.substring(0, separator);
- ProtocolSession localSession = null;
+ Session localSession = null;
Socket socket = null;
boolean hasConnected = false;
Message errorMessage = null;
@@ -2180,7 +2180,7 @@
* @param failingSession the socket which failed
* @param infiniteTry the socket which failed
*/
- public void reStart(ProtocolSession failingSession, boolean infiniteTry)
+ public void reStart(Session failingSession, boolean infiniteTry)
{
if (failingSession != null)
{
@@ -2308,7 +2308,7 @@
try
{
boolean credit;
- ProtocolSession current_session;
+ Session current_session;
Semaphore currentWindowSemaphore;
/*
@@ -2465,7 +2465,7 @@
// Save session information for later in case we need it for log messages
// after the session has been closed and/or failed.
- final ProtocolSession savedSession = session;
+ final Session savedSession = session;
if (savedSession == null)
{
// Must be shutting down.
@@ -2612,7 +2612,7 @@
if (!shutdown)
{
- final ProtocolSession tmpSession = session;
+ final Session tmpSession = session;
if (tmpSession == null || !tmpSession.closeInitiated())
{
/*
@@ -2879,7 +2879,7 @@
*/
public boolean isSessionEncrypted()
{
- final ProtocolSession tmp = session;
+ final Session tmp = session;
return tmp != null ? tmp.isEncrypted() : false;
}
@@ -3127,7 +3127,7 @@
*/
String getLocalUrl()
{
- final ProtocolSession tmp = session;
+ final Session tmp = session;
return tmp != null ? tmp.getLocalUrl() : "";
}
@@ -3142,12 +3142,12 @@
return monitor;
}
- private void setSession(final ProtocolSession newSession)
+ private void setSession(final Session newSession)
{
// De-register the monitor with the old name.
deregisterReplicationMonitor();
- final ProtocolSession oldSession = session;
+ final Session oldSession = session;
if (oldSession != null)
{
oldSession.close();
--
Gitblit v1.10.0