mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.38k stars 89 forks source link

Improve mox concurrency #128

Open haraldrudell opened 5 months ago

haraldrudell commented 5 months ago

I notice that if: — 2 threads are loading messages via imap — while the webmail interface is used

up to 20 s delay is observed in the Webmail interface say marking messages read, ie. ECMAScript requests to mox

mjl- commented 5 months ago

Some potentially long-running commands take a write transaction where you may have expected a read-only transaction. Notably "FETCH", which may have to mark a message as \Seen when reading it. The underlying bbolt DB only allows 1 writer at a time on a database, so a long transaction will block other operations.

It may be possible to instead start with a read transaction, and do a separate (short) write transaction for each message that needs to be marked as \Seen. But care has to be taken around dependencies between the read and write transaction, see https://pkg.go.dev/go.etcd.io/bbolt#section-readme.