[Dovecot] How to get rid of locks

Timo Sirainen tss at iki.fi
Mon May 14 12:59:20 EEST 2007

On Sat, 2007-04-07 at 22:30 +0300, Timo Sirainen wrote:
> I just figured out that O_APPEND is pretty great. If the operating  
> system updates seek position after writing to a file opened with  
> O_APPEND, writes to Dovecot's transaction log file can be made  
> lockless.

Well, almost. Log rotation isn't possible without some sort of locking.
But the locks could still be reduced:

 - Normally keep the .log file read-locked all the time (multiple
processes can have it read-locked)
 - Write to it with O_APPEND
 - If you notice that the log is going to be rotated soon, drop the read
lock and acquire it only for the duration of appends
 - When the log is wanted to be rotated, try to get a write-lock. If it
fails, try again later. If it succeeds, it's safe to rotate the log.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://dovecot.org/pipermail/dovecot/attachments/20070514/d4b678ba/attachment.pgp 

More information about the dovecot mailing list