moonchen opened a new issue, #13890:
URL: https://github.com/apache/trafficserver/issues/13890

   Every TCP client accept takes two locks in `ConnectionTracker`, whatever the 
configuration:
   
   1. The shared lock on the client exempt list (`client_exempt_list_mutex`), 
in `ConnectionTracker::is_client_exempt()`. The accept takes it even when 
`proxy.config.http.per_client.connection.exempt_list` is empty.
   2. For a client that is not in the exempt list, the exclusive mutex on the 
inbound table (`_inbound_table._mutex`), in 
`ConnectionTracker::obtain_inbound()`. The accept finds or creates a `Group` 
for the client address. When the last connection from that address closes, 
`Group::release()` takes the same mutex again to erase the `Group`.
   
   The accept takes the second lock even when 
`proxy.config.net.per_client.max_connections_in` is 0, which means no limit. 
`NetHandler::get_per_client_max_connections_in()` maps 0 to `INT32_MAX - 1`, so 
the `client_max > 0` check in `handle_max_client_connections()` always passes. 
This has been the case since #10688. #13737 kept the same locks for accepted 
connections. Connections that `proxy.config.net.connections_throttle` refuses 
now also take the shared lock, because the exempt-list lookup happens before 
the throttle check.
   
   The inbound table mutex is one mutex for all accept threads. A client that 
opens one connection at a time takes it twice per connection and allocates a 
new `Group` each time.
   
   Possible changes:
   
   - Skip the inbound table when `max_connections_in` is 0. The 
`get_connection_tracker_info` JSONRPC method reports the inbound table, so with 
no limit set, clients would no longer appear in its output.
   - Skip the exempt-list lock when the list is empty, or keep the list as an 
immutable snapshot that a reload or a plugin API edit replaces, so that readers 
take no lock.
   - Together with the first change, look up the exempt list only when the 
per-client limit is set or the connection count is at `connections_throttle`. 
`proxy.process.net.per_client.connections_exempt_in` and 
`proxy.process.net.per_client.connections_exempt_currently_open` would then 
count only the connections that a limit applied to.
   
   The cost of these locks has not been measured.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to