From 9e1f377c4f21b899d16f4c62450c68691f4b42a8 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.

---
 opends/src/server/org/opends/server/replication/server/ServerReader.java |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/opends/src/server/org/opends/server/replication/server/ServerReader.java b/opends/src/server/org/opends/server/replication/server/ServerReader.java
index 9c5f4bd..c1dfb54 100644
--- a/opends/src/server/org/opends/server/replication/server/ServerReader.java
+++ b/opends/src/server/org/opends/server/replication/server/ServerReader.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011 ForgeRock AS
+ *      Portions Copyright 2011-2013 ForgeRock AS
  */
 package org.opends.server.replication.server;
 
@@ -58,7 +58,7 @@
    * The tracer object for the debug logger.
    */
   private static final DebugTracer TRACER = getTracer();
-  private final ProtocolSession session;
+  private final Session session;
   private final ServerHandler handler;
   private final String remoteAddress;
 
@@ -68,11 +68,11 @@
    * Constructor for the LDAP server reader part of the replicationServer.
    *
    * @param session
-   *          The ProtocolSession from which to read the data.
+   *          The Session from which to read the data.
    * @param handler
    *          The server handler for this server reader.
    */
-  public ServerReader(ProtocolSession session, ServerHandler handler)
+  public ServerReader(Session session, ServerHandler handler)
   {
     super("Replication server RS(" + handler.getReplicationServerId()
         + ") reading from " + handler.toString() + " at "
@@ -314,18 +314,6 @@
         logError(errMessage);
       }
     }
-    catch (ClassNotFoundException e)
-    {
-      if (debugEnabled())
-        TRACER.debugInfo(
-            "In " + this.getName() + " " + stackTraceToSingleLineString(e));
-      /*
-       * The remote server has sent an unknown message,
-       * close the connection.
-       */
-      errMessage = ERR_UNKNOWN_MESSAGE.get(handler.toString());
-      logError(errMessage);
-    }
     catch (Exception e)
     {
       if (debugEnabled())

--
Gitblit v1.10.0