zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

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

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