Skip to content

ITS#9628 Fix incorrect c_n_ops_executing counter when backend is asynchronous

Nadezhda Ivanova requested to merge nivanova/openldap:c_n_ops_executing into master

The c_n_ops_executing counter is used by the server to determine the number of operations pending execution for a connection, and therefore the number of active threads used by the connection, since in a synchronous back-end these are identical. However, when the back-and is asynchronous, this counter no longer matches the number of active threads - the thread has completed its function, but the counter remains incremented until a response is received for the operation. In case of async-meta this is handled when the response is received, by a different thread. So, when the target servers are slower to respond, we have a situation when the counter is incremented, showing a high thread usage, when in fact there are very few threads in use. The server then starts deferring and rejecting operations, even though it is not overloaded.

In this patch the c_n_ops_executing counter is decremented as soon as the thread finishes processing the operation and forwarding it to the target server, making sure that the counter is again consistent with the number of active threads. To prevent the connection being closed as idle if there are still pending asynchronous operations, a new counter is introduced. c_n_ops_async is used to track the number of operations that have been submitted to the asynchronous backend and are waiting for a response, but no threads are engaged in their processing at the moment. It is exposed by cn=monitor by the monitorConnectionOpsAsync attribute. It is incremented when a thread finishes sending the operation, and decremented when the back-end sends the response back.

Merge request reports