[PATCH v2 11/14] cli/reply: return internet address list from get header funcs
[notmuch-archives.git] / 37 / b54d1c3d7a018e2e3b2ba8893e15fb6956ffcc
1 Return-Path: <dkg@fifthhorseman.net>\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 arlo.cworth.org (Postfix) with ESMTP id E85A96DE02CA\r
6  for <notmuch@notmuchmail.org>; Thu, 31 Mar 2016 10:44:47 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.021\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.021 tagged_above=-999 required=5\r
12  tests=[AWL=-0.021] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id 7qPI6LgS_KEz for <notmuch@notmuchmail.org>;\r
16  Thu, 31 Mar 2016 10:44:39 -0700 (PDT)\r
17 X-Greylist: delayed 584 seconds by postgrey-1.35 at arlo;\r
18  Thu, 31 Mar 2016 10:44:39 PDT\r
19 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
20  by arlo.cworth.org (Postfix) with ESMTP id 4EABF6DE014A\r
21  for <notmuch@notmuchmail.org>; Thu, 31 Mar 2016 10:44:39 -0700 (PDT)\r
22 Received: from fifthhorseman.net (unknown [38.109.115.130])\r
23  by che.mayfirst.org (Postfix) with ESMTPSA id B3AE4F997\r
24  for <notmuch@notmuchmail.org>; Thu, 31 Mar 2016 13:34:53 -0400 (EDT)\r
25 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
26  id 0F95F2003D; Thu, 31 Mar 2016 13:34:53 -0400 (EDT)\r
27 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
28 To: Notmuch Mail <notmuch@notmuchmail.org>\r
29 Subject: [PATCH] test thread breakage when messages are removed and re-added\r
30 Date: Thu, 31 Mar 2016 13:34:53 -0400\r
31 Message-Id: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net>\r
32 X-Mailer: git-send-email 2.8.0.rc3\r
33 X-BeenThere: notmuch@notmuchmail.org\r
34 X-Mailman-Version: 2.1.20\r
35 Precedence: list\r
36 List-Id: "Use and development of the notmuch mail system."\r
37  <notmuch.notmuchmail.org>\r
38 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
39  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
40 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
41 List-Post: <mailto:notmuch@notmuchmail.org>\r
42 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
43 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
45 X-List-Received-Date: Thu, 31 Mar 2016 17:44:48 -0000\r
46 \r
47 This test (T590-thread-breakage.sh) currently fails!\r
48 \r
49 If you have a two-message thread where message "B" is in-reply-to "A",\r
50 notmuch rightly sees this as a single thread.\r
51 \r
52 But if you:\r
53 \r
54  * remove "A" from the message store\r
55  * run "notmuch new"\r
56  * add "A" back into the message store\r
57  * re-run "notmuch new"\r
58 \r
59 Then notmuch sees the messages as distinct threads.\r
60 \r
61 I think this happens because if you insert "B" initially (before\r
62 anything is known about "A"), then a "ghost message" gets added to the\r
63 database in reference to "A" that is in the same thread, which "A"\r
64 takes over when it appears.\r
65 \r
66 But if "A" is subsequently removed, no ghost message is retained, so\r
67 when "A" appears, it is treated as a new thread.\r
68 \r
69 I don't know how to easily fix this, but i see a few options:\r
70 \r
71 ghost-on-removal\r
72 ----------------\r
73 \r
74 We could unilaterally add a ghost upon message removal.  This has a\r
75 few disadvantages: the message index would leak information about what\r
76 messages the user has ever been exposed to, and we also create a\r
77 perpetually-growing dataset -- the ghosts can never be removed.\r
78 \r
79 ghost-on-removal-when-shared-thread-exists\r
80 ------------------------------------------\r
81 \r
82 We could add a ghost upon message removal iff there are other\r
83 non-ghost messages with the same thread ID.\r
84 \r
85 We'd also need to remove all ghost messages that share a thread when\r
86 the last non-ghost message in that thread is removed.\r
87 \r
88 This still has a bit of information leakage, though: the message index\r
89 would reveal that i've seen a newer message in a thread, even if i had\r
90 deleted it from my message store\r
91 \r
92 track-dependencies\r
93 ------------------\r
94 \r
95 rather than a simple "ghost-message" we could store all the (A,B)\r
96 message-reference pairs internally, showing which messages A reference\r
97 which other messages B.\r
98 \r
99 Then removal of message X would require deleting all message-reference\r
100 pairs (X,B), and only deleting a ghost message if no (A,X) reference\r
101 pair exists.\r
102 \r
103 This requires modifying the database by adding a new and fairly weird\r
104 table that would need to be indexed by both columns.  I don't know\r
105 whether xapian has nice ways to do that.\r
106 \r
107 scan-dependencies\r
108 -----------------\r
109 \r
110 Without modifying the database, we could do something less efficient.\r
111 \r
112 Upon removal of message X, we could scan the headers of all non-ghost\r
113 messages that share a thread with X.  If any of those messages refers\r
114 to X, we would add a ghost message.  If none of them do, then we would\r
115 just drop X entirely from the table.\r
116 ---\r
117  test/T590-thread-breakage.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++\r
118  1 file changed, 63 insertions(+)\r
119  create mode 100755 test/T590-thread-breakage.sh\r
120 \r
121 diff --git a/test/T590-thread-breakage.sh b/test/T590-thread-breakage.sh\r
122 new file mode 100755\r
123 index 0000000..704f504\r
124 --- /dev/null\r
125 +++ b/test/T590-thread-breakage.sh\r
126 @@ -0,0 +1,63 @@\r
127 +#!/usr/bin/env bash\r
128 +#\r
129 +# Copyright (c) 2016 Daniel Kahn Gillmor\r
130 +#\r
131 +\r
132 +test_description='thread breakage by reindexing (currently broken)'\r
133 +\r
134 +. ./test-lib.sh || exit 1\r
135 +\r
136 +message_a() {\r
137 +    mkdir -p ${MAIL_DIR}/cur\r
138 +    cat > ${MAIL_DIR}/cur/a <<EOF\r
139 +Subject: First message\r
140 +Message-ID: <a@example.net>\r
141 +From: Alice <alice@example.net>\r
142 +To: Bob <bob@example.net>\r
143 +Date: Thu, 31 Mar 2016 20:10:00 -0400\r
144 +\r
145 +This is the first message in the thread.\r
146 +EOF\r
147 +}\r
148 +\r
149 +message_b() {\r
150 +    mkdir -p ${MAIL_DIR}/cur\r
151 +    cat > ${MAIL_DIR}/cur/b <<EOF\r
152 +Subject: Second message\r
153 +Message-ID: <b@example.net>\r
154 +In-Reply-To: <a@example.net>\r
155 +References: <a@example.net>\r
156 +From: Bob <bob@example.net>\r
157 +To: Alice <alice@example.net>\r
158 +Date: Thu, 31 Mar 2016 20:15:00 -0400\r
159 +\r
160 +This is the second message in the thread.\r
161 +EOF\r
162 +}\r
163 +\r
164 +\r
165 +test_thread_count() {\r
166 +    notmuch new >/dev/null\r
167 +    test_begin_subtest "${2:-Expecting $1 thread(s)}"\r
168 +    count=$(notmuch count --output=threads)\r
169 +    test_expect_equal "$count" "$1"\r
170 +}\r
171 +\r
172 +test_thread_count 0 'There should be no threads initially'\r
173 +\r
174 +message_a\r
175 +test_thread_count 1 'One message in: one thread'\r
176 +\r
177 +message_b\r
178 +test_thread_count 1 'Second message in the same thread: one thread'\r
179 +\r
180 +rm -f ${MAIL_DIR}/cur/a\r
181 +test_thread_count 1 'First message removed: still only one thread'\r
182 +\r
183 +message_a\r
184 +# this is known to fail (it shows 2 threads) because no "ghost\r
185 +# message" was created for message A when it was removed from the\r
186 +# index, despite message B still pointing to it.\r
187 +test_thread_count 1 'First message reappears: should return to the same thread'\r
188 +\r
189 +test_done\r
190 -- \r
191 2.8.0.rc3\r
192 \r