MBOX-Line: From tss at iki.fi  Mon May 12 20:48:02 2008
To: imap-protocol@u.washington.edu
From: Timo Sirainen <tss@iki.fi>
Date: Fri Jun  8 12:34:41 2018
Subject: [Imap-protocol] Optimistic incremental THREAD=REFERENCES
In-Reply-To: <E146A798-5E98-4ADB-9B6E-C03D99F50A2E@iki.fi>
References: <1210364641.9518.397.camel@hurina>
	<C4+/sgL3fH13VZgTRBl1nA.md5@lochnagar.oryx.com>
	<E146A798-5E98-4ADB-9B6E-C03D99F50A2E@iki.fi>
Message-ID: <1210650482.9518.501.camel@hurina>

On Sat, 2008-05-10 at 00:52 +0300, Timo Sirainen wrote:
> On May 10, 2008, at 12:06 AM, Arnt Gulbrandsen wrote:
> 
> > I wrote code do to the same thing, and found another corner case. If  
> > one or more early message(s) is/are deleted from the mailbox, then  
> > it can be (and very seldom is) the case that a thread is split.
> >
> > Consider this four-message thread:
> >    1 is the start.
> >    2 has an In-Reply-To pointing to 1.
> >    3 has an In-Reply-To pointing to 1
> >    4 has an IRT pointing to 2
> >
> > If you thread this incrementally, you learn that this is one thread.
> >
> > If messages 1 and 2 are deleted and another message arrives
> >    5 has an IRT pointing to 3
> > then your incremental algorithm may still have enough information to  
> > tie messages 3, 4 and 5 together in one thread. A non-incremental  
> > T=R doesn't have that information, and will make two threads.
> 
> A quick test shows that my algorithm handles this, probably because of  
> the refcounting rules. I'll look at it more closely later to make sure  
> that it does.

That exact test produced a correct result for some reason, but looks
like I had still missed that problem completely. I guess I concentrated
too much on References: header that I missed one of the simplest cases:

 - 1 is root
 - 2 points to 1
 - 3 points to 2

Expunge 2 -> all 1..3 are still referenced, so threading doesn't make 1
and 3 separate roots.

Luckily this can be fixed easily: link_refcount should contain "number
of links to parent node" instead of "number of links from child nodes".
After that change (and some other changes due to it) my tests appear to
be giving correct results again.

Updated document in http://dovecot.org/tmp/thread-refs.txt (probably
will be moved to http://dovecot.org/doc/ some day).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part
URL: <http://mailman13.u.washington.edu/pipermail/imap-protocol/attachments/20080513/d25f7d7e/attachment.sig>
