[Dovecot] index synchronization during local delivery

Andy YB Hu ybhu at hk1.ibm.com
Wed Feb 15 06:13:18 EET 2012


I can generate the UID once I create the uidlist lock, and the UID is
incremental globally.

Some questions:
1, Whether I can  write the mail to tmp/ after creating
dovecot-uidlist.lock?
2, I did the 5 steps manually, found that new mail is set to OLD flag, so
that when SELECT command, it told there was no NEW mail.  Looks like need
to change code in maildir_uidlist_sync_next_uid()?
3, About the dovecot-uidlist.lock file creation and deletion, I checked the
code, there are functions in dovecot like maildir_uidlist_lock_timeout and
maildir_uidlist_unlock. If I did that via calling these functions, there
are lots of extra codes need to call(like auth, mailbox open...). So the
question is if I do that in my codes, how to handle the race condition
correctly? (At least there would be other sessions want to lock the files
also / already locked it while I want to create the dovecot-uidlist.lock)

Thanks.



                                                                           
             Timo Sirainen                                                 
             <tss at iki.fi>                                                  
             Sent by:                                                   To 
             dovecot-bounces at d         Dovecot Mailing List                
             ovecot.org                <dovecot at dovecot.org>               
                                                                        cc 
                                                                           
             02/15/2012 10:19                                      Subject 
             AM                        Re: [Dovecot] index synchronization 
                                       during local delivery               
                                                                           
             Please respond to                                             
              Dovecot Mailing                                              
                   List                                                    
             <dovecot at dovecot.                                             
                   org>                                                    
                                                                           
                                                                           




On 14.2.2012, at 5.31, Andy YB Hu wrote:

> Now our system will take dovecot as the whole imap back end, and keep the
> LDA of ours, But our system has our own UID generation mechanism (in
> dovecot it's incremental from 1), which will be done while local
delivery,
> So when  local deliveries, it will first generate the UID, move the mail
> into maildir, then synchronize the mailbox index, which is part of
dovecot
> LDA does.   The question is what API or something else about index
> synchronization I can integrate into our own LDA program easily?   Seems
> mailbox_copy() would be the possibility?

If you want it to be free of race conditions:

1. Write the mail to tmp/
2. Create dovecot-uidlist.lock
3. Generate the UID and move the mail to new/ or cur/
4. Append a line to dovecot-uidlist with your UID and the Maildir filename
5. Delete dovecot-uidlist.lock

Although it sounds like the UID is generated before you can even create
uidlist lock? That means IMAP client can at the same time generate a
conflicting UID with APPEND/COPY. Also remember that UIDs must always be
increasing. If you try to add a new message with lower UID then Dovecot
won't like it, and even if you fix that, some IMAP clients may never see
the mail.

Anyway, once you have uidlist updated you can do indexing/caching with e.g.
"doveadm index" command in v2.0.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20120215/2a76ec9a/attachment-0012.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic09089.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20120215/2a76ec9a/attachment-0013.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20120215/2a76ec9a/attachment-0014.gif>


More information about the dovecot mailing list