1 Return-Path: <m.walters@qmul.ac.uk>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 132F7431FB6
\r
6 for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 16:10:38 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5
\r
12 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,
\r
13 NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
14 Received: from olra.theworths.org ([127.0.0.1])
\r
15 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id uV+vVp9B3lMM for <notmuch@notmuchmail.org>;
\r
17 Tue, 21 Oct 2014 16:10:30 -0700 (PDT)
\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])
\r
19 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id C5058431FAE
\r
22 for <notmuch@notmuchmail.org>; Tue, 21 Oct 2014 16:10:29 -0700 (PDT)
\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])
\r
24 by mail2.qmul.ac.uk with esmtp (Exim 4.71)
\r
25 (envelope-from <m.walters@qmul.ac.uk>)
\r
26 id 1XgiZM-0004l0-3F; Wed, 22 Oct 2014 00:10:26 +0100
\r
27 Received: from 5751dfa2.skybroadband.com ([87.81.223.162] helo=localhost)
\r
28 by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)
\r
29 (envelope-from <m.walters@qmul.ac.uk>)
\r
30 id 1XgiZL-0002hb-E9; Wed, 22 Oct 2014 00:10:23 +0100
\r
31 From: Mark Walters <markwalters1009@gmail.com>
\r
32 To: Austin Clements <aclements@csail.mit.edu>, notmuch@notmuchmail.org
\r
33 Subject: Re: [PATCH v2 08/12] lib: Implement ghost-based thread linking
\r
34 In-Reply-To: <1412637438-4821-9-git-send-email-aclements@csail.mit.edu>
\r
35 References: <1412637438-4821-1-git-send-email-aclements@csail.mit.edu>
\r
36 <1412637438-4821-9-git-send-email-aclements@csail.mit.edu>
\r
37 User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1
\r
38 (x86_64-pc-linux-gnu)
\r
39 Date: Wed, 22 Oct 2014 00:10:21 +0100
\r
40 Message-ID: <87zjcphvdu.fsf@qmul.ac.uk>
\r
42 Content-Type: text/plain; charset=us-ascii
\r
43 X-Sender-Host-Address: 87.81.223.162
\r
44 X-QM-Geographic: According to ripencc,
\r
45 this message was delivered by a machine in Britain (UK) (GB).
\r
46 X-QM-SPAM-Info: Sender has good ham record. :)
\r
47 X-QM-Body-MD5: 9724697ff21306866e8fe63340c902a0 (of first 20000 bytes)
\r
48 X-SpamAssassin-Score: -0.1
\r
49 X-SpamAssassin-SpamBar: /
\r
50 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
52 spam. We require at least 5.0 points to mark a message as spam.
\r
53 This message scored -0.1 points.
\r
54 Summary of the scoring:
\r
55 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
56 provider * (markwalters1009[at]gmail.com)
\r
57 * -0.1 AWL AWL: From: address is in the auto white-list
\r
58 X-QM-Scan-Virus: ClamAV says the message is clean
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Tue, 21 Oct 2014 23:10:38 -0000
\r
73 On Tue, 07 Oct 2014, Austin Clements <aclements@csail.mit.edu> wrote:
\r
74 > From: Austin Clements <amdragon@mit.edu>
\r
76 > This updates the thread linking code to use ghost messages instead of
\r
77 > user metadata to link messages into threads.
\r
79 > In contrast with the old approach, this is actually correct.
\r
80 > Previously, thread merging updated only the thread IDs of message
\r
81 > documents, not thread IDs stored in user metadata. As originally
\r
82 > diagnosed by Mark Walters [1] and as demonstrated by the broken
\r
83 > T260-thread-order test, this can cause notmuch to fail to link
\r
84 > messages even though they're in the same thread. In principle the old
\r
85 > approach could have been fixed by updating the user metadata thread
\r
86 > IDs as well, but these are not indexed and hence this would have
\r
87 > required a full scan of all stored thread IDs. Ghost messages solve
\r
88 > this problem naturally by reusing the exact same thread ID and message
\r
89 > ID representation and indexing as regular messages.
\r
91 > Furthermore, thanks to this greater symmetry, ghost messages are also
\r
92 > algorithmically simpler. We continue to support the old user metadata
\r
93 > format, so this patch can't delete any code, but when we do remove
\r
94 > support for the old format, several functions can simply be deleted.
\r
96 > [1] id:8738h7kv2q.fsf@qmul.ac.uk
\r
98 > lib/database.cc | 86 +++++++++++++++++++++++++++++++++++++++++++++++++--------
\r
99 > 1 file changed, 75 insertions(+), 11 deletions(-)
\r
101 > diff --git a/lib/database.cc b/lib/database.cc
\r
102 > index c641bcd..fdcc526 100644
\r
103 > --- a/lib/database.cc
\r
104 > +++ b/lib/database.cc
\r
105 > @@ -1752,6 +1752,12 @@ _get_metadata_thread_id_key (void *ctx, const char *message_id)
\r
109 > +static notmuch_status_t
\r
110 > +_resolve_message_id_to_thread_id_old (notmuch_database_t *notmuch,
\r
112 > + const char *message_id,
\r
113 > + const char **thread_id_ret);
\r
115 > /* Find the thread ID to which the message with 'message_id' belongs.
\r
117 > * Note: 'thread_id_ret' must not be NULL!
\r
118 > @@ -1760,9 +1766,9 @@ _get_metadata_thread_id_key (void *ctx, const char *message_id)
\r
120 > * Note: If there is no message in the database with the given
\r
121 > * 'message_id' then a new thread_id will be allocated for this
\r
122 > - * message and stored in the database metadata, (where this same
\r
123 > + * message ID and stored in the database metadata so that the
\r
124 > * thread ID can be looked up if the message is added to the database
\r
128 > static notmuch_status_t
\r
129 > _resolve_message_id_to_thread_id (notmuch_database_t *notmuch,
\r
130 > @@ -1770,6 +1776,49 @@ _resolve_message_id_to_thread_id (notmuch_database_t *notmuch,
\r
131 > const char *message_id,
\r
132 > const char **thread_id_ret)
\r
134 > + notmuch_private_status_t status;
\r
135 > + notmuch_message_t *message;
\r
137 > + if (! (notmuch->features & NOTMUCH_FEATURE_GHOSTS))
\r
138 > + return _resolve_message_id_to_thread_id_old (notmuch, ctx, message_id,
\r
139 > + thread_id_ret);
\r
141 > + /* Look for this message (regular or ghost) */
\r
142 > + message = _notmuch_message_create_for_message_id (
\r
143 > + notmuch, message_id, &status);
\r
144 > + if (status == NOTMUCH_PRIVATE_STATUS_SUCCESS) {
\r
145 > + /* Message exists */
\r
146 > + *thread_id_ret = talloc_steal (
\r
147 > + ctx, notmuch_message_get_thread_id (message));
\r
148 > + } else if (status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
\r
149 > + /* Message did not exist. Give it a fresh thread ID and
\r
150 > + * populate this message as a ghost message. */
\r
151 > + *thread_id_ret = talloc_strdup (
\r
152 > + ctx, _notmuch_database_generate_thread_id (notmuch));
\r
153 > + if (! *thread_id_ret) {
\r
154 > + status = NOTMUCH_PRIVATE_STATUS_OUT_OF_MEMORY;
\r
156 > + status = _notmuch_message_initialize_ghost (message, *thread_id_ret);
\r
157 > + if (status == 0)
\r
158 > + /* Commit the new ghost message */
\r
159 > + _notmuch_message_sync (message);
\r
162 > + /* Create failed. Fall through. */
\r
165 > + notmuch_message_destroy (message);
\r
167 > + return COERCE_STATUS (status, "Error creating ghost message");
\r
170 > +/* Pre-ghost messages _resolve_message_id_to_thread_id */
\r
171 > +static notmuch_status_t
\r
172 > +_resolve_message_id_to_thread_id_old (notmuch_database_t *notmuch,
\r
174 > + const char *message_id,
\r
175 > + const char **thread_id_ret)
\r
177 > notmuch_status_t status;
\r
178 > notmuch_message_t *message;
\r
179 > string thread_id_string;
\r
180 > @@ -2007,7 +2056,7 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t *notmuch,
\r
184 > -/* Given a (mostly empty) 'message' and its corresponding
\r
185 > +/* Given a blank or ghost 'message' and its corresponding
\r
186 > * 'message_file' link it to existing threads in the database.
\r
188 > * The first check is in the metadata of the database to see if we
\r
190 There is quite a lot of comment below this and it is not clear to me how
\r
191 much of it applies to the is_ghost case. In particular does the
\r
193 * Finally, we look in the database for existing message that
\r
194 * reference 'message'.
\r
196 still apply? I would have thought that we would already have done that
\r
197 in the is_ghost case.
\r
199 Of course this also applies to the actual code which seems to call
\r
200 _notmuch_database_link_message_to_children unconditionally. It might be
\r
201 worth a comment in any case.
\r
208 > @@ -2035,16 +2084,22 @@ _consume_metadata_thread_id (void *ctx, notmuch_database_t *notmuch,
\r
209 > static notmuch_status_t
\r
210 > _notmuch_database_link_message (notmuch_database_t *notmuch,
\r
211 > notmuch_message_t *message,
\r
212 > - notmuch_message_file_t *message_file)
\r
213 > + notmuch_message_file_t *message_file,
\r
214 > + notmuch_bool_t is_ghost)
\r
216 > void *local = talloc_new (NULL);
\r
217 > notmuch_status_t status;
\r
218 > - const char *thread_id;
\r
219 > + const char *thread_id = NULL;
\r
221 > /* Check if the message already had a thread ID */
\r
222 > - thread_id = _consume_metadata_thread_id (local, notmuch, message);
\r
224 > - _notmuch_message_add_term (message, "thread", thread_id);
\r
225 > + if (notmuch->features & NOTMUCH_FEATURE_GHOSTS) {
\r
227 > + thread_id = notmuch_message_get_thread_id (message);
\r
229 > + thread_id = _consume_metadata_thread_id (local, notmuch, message);
\r
231 > + _notmuch_message_add_term (message, "thread", thread_id);
\r
234 > status = _notmuch_database_link_message_to_parents (notmuch, message,
\r
236 > @@ -2079,6 +2134,7 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
237 > notmuch_message_t *message = NULL;
\r
238 > notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS, ret2;
\r
239 > notmuch_private_status_t private_status;
\r
240 > + notmuch_bool_t is_ghost = false;
\r
242 > const char *date, *header;
\r
243 > const char *from, *to, *subject;
\r
244 > @@ -2171,12 +2227,20 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
\r
246 > _notmuch_message_add_filename (message, filename);
\r
248 > - /* Is this a newly created message object? */
\r
249 > - if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) {
\r
250 > + /* Is this a newly created message object or a ghost
\r
251 > + * message? We have to be slightly careful: if this is a
\r
252 > + * blank message, it's not safe to call
\r
253 > + * notmuch_message_get_flag yet. */
\r
254 > + if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND ||
\r
255 > + (is_ghost = notmuch_message_get_flag (
\r
256 > + message, NOTMUCH_MESSAGE_FLAG_GHOST))) {
\r
257 > _notmuch_message_add_term (message, "type", "mail");
\r
259 > + /* Convert ghost message to a regular message */
\r
260 > + _notmuch_message_remove_term (message, "type", "ghost");
\r
262 > ret = _notmuch_database_link_message (notmuch, message,
\r
264 > + message_file, is_ghost);
\r
271 > _______________________________________________
\r
272 > notmuch mailing list
\r
273 > notmuch@notmuchmail.org
\r
274 > http://notmuchmail.org/mailman/listinfo/notmuch
\r