Friday, June 8, 2018

[389-commits] [389-ds-base] 01/01: Ticket 49768 - Under network intensive load persistent search can erronously decrease connection refcnt

This is an automated email from the git hooks/post-receive script.

tbordaz pushed a commit to branch 389-ds-base-1.3.8
in repository 389-ds-base.

commit 42ab464e3962794d16661edb0c12d26aa173733f
Author: Thierry Bordaz <tbordaz@redhat.com>
Date: Thu May 24 15:36:34 2018 +0200

Ticket 49768 - Under network intensive load persistent search can erronously decrease connection refcnt

Bug Description:
If a connection enters in turbo mode (because of high traffic) or
a worker reads several requests in the read buffer (more_data), the thread
keeps processing connection.
In that condition it should not decrease the refcnt.
In case the operation is a persistent search, it decreases systematically
the refcnt.
So refcnt can become lower than the actual number of threads active on the connection.

Most of the time it can create messages like
Attempt to release connection that is not acquired
In some rare case, if the a connection is out of the active list but a remaining thread
tries to remove it again it can lead to a crash

Fix Description:
The fix consist, when processing a PS, to decrease the refcnt at the condition
the connection is not in turbo mode or in more_data.

https://pagure.io/389-ds-base/issue/49768

Reviewed by: Mark Reynolds

Platforms tested: F26

Flag Day: no

Doc impact: no
---
ldap/servers/slapd/connection.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index c54e7c2..1dbb49f 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -1811,9 +1811,17 @@ connection_threadmain()
slapi_counter_increment(ops_completed);
/* If this op isn't a persistent search, remove it */
if (op->o_flags & OP_FLAG_PS) {
- PR_EnterMonitor(conn->c_mutex);
- connection_release_nolock(conn); /* psearch acquires ref to conn - release this one now */
- PR_ExitMonitor(conn->c_mutex);
+ /* Release the connection (i.e. decrease refcnt) at the condition
+ * this thread will not loop on it.
+ * If we are in turbo mode (dedicated to that connection) or
+ * more_data (continue reading buffered req) this thread
+ * continues to hold the connection
+ */
+ if (!thread_turbo_flag && !more_data) {
+ PR_EnterMonitor(conn->c_mutex);
+ connection_release_nolock(conn); /* psearch acquires ref to conn - release this one now */
+ PR_ExitMonitor(conn->c_mutex);
+ }
/* ps_add makes a shallow copy of the pb - so we
* can't free it or init it here - just set operation to NULL.
* ps_send_results will call connection_remove_operation_ext to free it

--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
389-commits mailing list -- 389-commits@lists.fedoraproject.org
To unsubscribe send an email to 389-commits-leave@lists.fedoraproject.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/389-commits@lists.fedoraproject.org/message/6ED2C55NYPBDD6YFTTRFGJD2CVWJIFLH/

No comments:

Post a Comment