traeak opened a new pull request, #13806: URL: https://github.com/apache/trafficserver/pull/13806
The shared session pool mutex was held across migrating a pooled origin connection to another thread and across closing sessions, which put socket and TLS work inside a lock every thread contends for. The lock now covers only the pool tables and handing a connection off: - Migration is split into a detach under the lock and an attach after it is released. - Sessions that cannot be pooled, time out, or are closed by the origin are closed after the lock is released. - A pool purge has each thread close its own sessions. This fixes three race conditions in the migration of a pooled origin connection, all present before this change: - The migrating thread stopped the old connection's EventIO while the owning thread could still be rescheduling that connection, having failed the try lock on its VIO mutex. The owning thread then used the stopped EventIO, which hit ink_assert(event_loop) in debug builds and dereferenced a null event loop with kqueue. EventIO::modify and EventIO::refresh now do nothing once stopped. - With kqueue, stopping an EventIO did not remove its registration, and a migrated socket is never closed. The old thread's kqueue could keep delivering events addressed to a connection that thread had since freed. Migration now removes the registration, and a refresh racing with the removal undoes its own add. - When creating the new connection failed, the old one was closed a second time, after the owning thread could already have freed or reused it. The session no longer refers to the old connection once it has been detached. The pooled_server_connections gauge also no longer drifts after a purge. -- 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]
