[Dovecot] Locking /var/mail/user issue with postfix and dovecot

Robert JR roundcube222 at alaadin.org
Fri Oct 26 01:11:14 EEST 2012


On 2012-10-26 00:15, Ben Morrow wrote:

> At 10AM +0300 on 25/10/12 you (Robert JR) wrote:
>
>> Stan, sorry but you didnot understand my question at all, dovecot in
>> this case is reading the mailbox file while user downloading the 
>> mail
>> and not WRITING. only postfix write when a mail arrives and DOVECOT
>> only read the mail. And even if both write to the file, I have 
>> already
>> set the locking option of both to FCNTL so no problem should happen. 
>> My
>> question is postfix locking option is = FCNTL, DOTLOCK , and dovecot 
>> =
>> FCNTL, if postfix find a file already FCNTL, why it dotlock the file 
>> 5
>> secs then remove the dotlock and say resource unaviable?
>
> As Stan said earlier, this is a Postfix question. The rule for
> dotlocking is that you must create the .lock *before* opening the 
> file,
> in case whoever has it locked will be replacing the file altogether; 
> but
> with fcntl locking you must acquire the lock *after* opening the 
> file,
> since that's the way the syscall works. This means that if Postfix is
> going to use both forms of lock, it has to acquire a dotlock before 
> it
> can look for a fcntl lock.
>
> In other words: the methods in mailbox_delivery_lock are *not* tried 
> in
> order, because they can't be. Dotlock is always tried first.
>
> You should have compatible locking settings for all your programs
> accessing your mboxes. If Postfix is using dotlock, Dovecot should be
> using dotlock as well. If you don't have any local programs (mail
> clients, for instance) which require dotlocks, you should probably
> change Postfix to just use fcntl locks.
>
> Ben
Thanks Ben for your valuable support and detailed explanation .. but 
according to your explanation dovecot documentation contains wrong 
explanation to the dotlock and that's why i was confused.

it is written as follow

**
If multiple lock methods are used, which is usually the case since 
dotlocks aren't typically used for read locking, the order in which the 
locking is done is important. Consider if two programs were running at 
the same time, both use dotlock and fcntl locking but in different 
order:

Program A: fcntl locks the mbox
Program B at the same time: dotlocks the mbox
Program A continues: tries to dotlock the mbox, but since it's already 
dotlocked by B, it starts waiting
Program B continues: tries to fcntl lock the mbox, but since it's 
already fcntl locked by A, it starts waiting
Now both of them are waiting for each others locks. Finally after a 
couple of minutes they time out and fail the operation.
**

So this means that the documentation as mentioned above is wrong and 
dotlock is always first even if the order is different ..
Anyway i have sent this question to postfix maillist and i will wait 
their reply .

Thanks again
Robert.



More information about the dovecot mailing list