Skip to content

Avoid blocking IMAP pool cleanup on logout#72

Open
chodorenko wants to merge 1 commit into
Alinto:masterfrom
chodorenko:master
Open

Avoid blocking IMAP pool cleanup on logout#72
chodorenko wants to merge 1 commit into
Alinto:masterfrom
chodorenko:master

Conversation

@chodorenko

@chodorenko chodorenko commented May 28, 2026

Copy link
Copy Markdown

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

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.
@chodorenko

Copy link
Copy Markdown
Author

@QHivert Can you review and approve ?

@QHivert

QHivert commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

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.

@chodorenko

Copy link
Copy Markdown
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants