Avoid blocking IMAP pool cleanup on logout#72
Conversation
The IMAP connection pool garbage collector used to call logout while scanning and mutating the shared cache. A slow or stuck IMAP server could therefore keep the cleanup path busy for a long time and delay access to pooled sessions. Protect the connection cache with a small NSLock, remove expired entries from the pool while holding that lock, and perform the network logout work afterwards on a background thread. This keeps the cache unavailable only for the short bookkeeping phase instead of for the duration of every IMAP LOGOUT command. Also guard the collector against non-connection placeholders already supported by cacheEntry:forURL:, and keep the debug pool count behind the same synchronization.
|
@QHivert Can you review and approve ? |
|
Hello, sorry we're on a rush for SOGo 6. I cannot review this for the moment. However I have some concerns about side-effect. The bug seems to be very specific to your infra and I'm afraid this fix can have unexpected effects on others infra. |
|
We are also looking forward to SOGo 6. However, based on experience, the first releases will most likely require some time before becoming truly production-ready, so we expect to continue using the stable SOGo 5 branch for quite a while. The issue is not strictly specific to our infrastructure — it simply becomes much more visible under heavy load and with a large number of active clients, which is the case in our environment. We tested the proposed changes in our high-load configuration and observed a significant improvement in overall behavior and stability. We would highly appreciate some time from your side to review and possibly implement the solution. @QHivert Let’s make the product better together :) |
The IMAP connection pool garbage collector used to call logout while scanning and mutating the shared cache. A slow or stuck IMAP server could therefore keep the cleanup path busy for a long time and delay access to pooled sessions.
Protect the connection cache with a small NSLock, remove expired entries from the pool while holding that lock, and perform the network logout work afterwards on a background thread. This keeps the cache unavailable only for the short bookkeeping phase instead of for the duration of every IMAP LOGOUT command.
Also guard the collector against non-connection placeholders already supported by cacheEntry:forURL:, and keep the debug pool count behind the same synchronization.
BUG: 6210