Blame SOURCES/0082-Ticket-49696-replicated-operations-should-be-seriali.patch

3b7e51
From f0b41ec12f957612c69ae5be3bbbb6e2d6db2530 Mon Sep 17 00:00:00 2001
3b7e51
From: Ludwig Krispenz <lkrispen@redhat.com>
3b7e51
Date: Thu, 17 May 2018 10:31:58 +0200
3b7e51
Subject: [PATCH]     Ticket 49696: replicated operations should be serialized
3b7e51
3b7e51
    Bug: there was a scenario where two threads could process replication operations in parallel.
3b7e51
         The reason was that for a new repl start request the repl conn flag is not set and the
3b7e51
         connection is made readable.
3b7e51
         When the start repl op is finished, the flagi set, but in a small window the supplier could
3b7e51
         already have sent updates and more_data would trigger this thread also to continue to process
3b7e51
         repl operations.
3b7e51
3b7e51
    Fix: In the situation where a thread successfully processed a start repl request and just set the repl_conn
3b7e51
         flag  do not use more_data.
3b7e51
3b7e51
    Reviewed by: Thierry, thanks
3b7e51
---
3b7e51
 ldap/servers/slapd/connection.c | 14 +++++++++++---
3b7e51
 1 file changed, 11 insertions(+), 3 deletions(-)
3b7e51
3b7e51
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
3b7e51
index 5ca32a333..b5030f0cb 100644
3b7e51
--- a/ldap/servers/slapd/connection.c
3b7e51
+++ b/ldap/servers/slapd/connection.c
3b7e51
@@ -1822,9 +1822,17 @@ connection_threadmain()
3b7e51
 
3b7e51
             /* If we're in turbo mode, we keep our reference to the connection alive */
3b7e51
             /* can't use the more_data var because connection could have changed in another thread */
3b7e51
-            more_data = conn_buffered_data_avail_nolock(conn, &conn_closed) ? 1 : 0;
3b7e51
-            slapi_log_err(SLAPI_LOG_CONNS, "connection_threadmain", "conn %" PRIu64 " check more_data %d thread_turbo_flag %d\n",
3b7e51
-                          conn->c_connid, more_data, thread_turbo_flag);
3b7e51
+            slapi_log_err(SLAPI_LOG_CONNS, "connection_threadmain", "conn %" PRIu64 " check more_data %d thread_turbo_flag %d"
3b7e51
+                          "repl_conn_bef %d, repl_conn_now %d\n",
3b7e51
+                          conn->c_connid, more_data, thread_turbo_flag,
3b7e51
+                          replication_connection, conn->c_isreplication_session);
3b7e51
+            if (!replication_connection &&  conn->c_isreplication_session) {
3b7e51
+                /* it a connection that was just flagged as replication connection */
3b7e51
+                more_data = 0;
3b7e51
+            } else {
3b7e51
+                /* normal connection or already established replication connection */
3b7e51
+                more_data = conn_buffered_data_avail_nolock(conn, &conn_closed) ? 1 : 0;
3b7e51
+            }
3b7e51
             if (!more_data) {
3b7e51
                 if (!thread_turbo_flag) {
3b7e51
                     /*
3b7e51
-- 
3b7e51
2.13.6
3b7e51