From e6566e344939d8403dc70ff32cfbc313744b21f6 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 3 Apr 2016 13:19:01 +2100 Subject: [PATCH] [PATCH 1/2] test thread breakage when messages are removed and re-added --- 8d/a0212b9db3217768b40f22ec6ffcba8f9c4c14 | 204 ++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 8d/a0212b9db3217768b40f22ec6ffcba8f9c4c14 diff --git a/8d/a0212b9db3217768b40f22ec6ffcba8f9c4c14 b/8d/a0212b9db3217768b40f22ec6ffcba8f9c4c14 new file mode 100644 index 000000000..d67973b3d --- /dev/null +++ b/8d/a0212b9db3217768b40f22ec6ffcba8f9c4c14 @@ -0,0 +1,204 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 7ED086DE0243 + for ; Sat, 2 Apr 2016 09:19:24 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.02 +X-Spam-Level: +X-Spam-Status: No, score=-0.02 tagged_above=-999 required=5 tests=[AWL=-0.009, + SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 4cu-_GAnWwKx for ; + Sat, 2 Apr 2016 09:19:16 -0700 (PDT) +Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) + by arlo.cworth.org (Postfix) with ESMTPS id 61F246DE02C2 + for ; Sat, 2 Apr 2016 09:19:16 -0700 (PDT) +Received: from remotemail by fethera.tethera.net with local (Exim 4.84) + (envelope-from ) + id 1amOH5-0004fC-A4; Sat, 02 Apr 2016 12:19:47 -0400 +Received: (nullmailer pid 13159 invoked by uid 1000); + Sat, 02 Apr 2016 16:19:11 -0000 +From: David Bremner +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: [PATCH 1/2] test thread breakage when messages are removed and + re-added +Date: Sat, 2 Apr 2016 13:19:01 -0300 +Message-Id: <1459613942-13098-1-git-send-email-david@tethera.net> +X-Mailer: git-send-email 2.8.0.rc3 +In-Reply-To: <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net> +References: <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net> +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.20 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 02 Apr 2016 16:19:24 -0000 + +From: Daniel Kahn Gillmor + +This test (T590-thread-breakage.sh) currently fails! + +If you have a two-message thread where message "B" is in-reply-to "A", +notmuch rightly sees this as a single thread. + +But if you: + + * remove "A" from the message store + * run "notmuch new" + * add "A" back into the message store + * re-run "notmuch new" + +Then notmuch sees the messages as distinct threads. + +I think this happens because if you insert "B" initially (before +anything is known about "A"), then a "ghost message" gets added to the +database in reference to "A" that is in the same thread, which "A" +takes over when it appears. + +But if "A" is subsequently removed, no ghost message is retained, so +when "A" appears, it is treated as a new thread. + +I don't know how to easily fix this, but i see a few options: + +ghost-on-removal +---------------- + +We could unilaterally add a ghost upon message removal. This has a +few disadvantages: the message index would leak information about what +messages the user has ever been exposed to, and we also create a +perpetually-growing dataset -- the ghosts can never be removed. + +ghost-on-removal-when-shared-thread-exists +------------------------------------------ + +We could add a ghost upon message removal iff there are other +non-ghost messages with the same thread ID. + +We'd also need to remove all ghost messages that share a thread when +the last non-ghost message in that thread is removed. + +This still has a bit of information leakage, though: the message index +would reveal that i've seen a newer message in a thread, even if i had +deleted it from my message store + +track-dependencies +------------------ + +rather than a simple "ghost-message" we could store all the (A,B) +message-reference pairs internally, showing which messages A reference +which other messages B. + +Then removal of message X would require deleting all message-reference +pairs (X,B), and only deleting a ghost message if no (A,X) reference +pair exists. + +This requires modifying the database by adding a new and fairly weird +table that would need to be indexed by both columns. I don't know +whether xapian has nice ways to do that. + +scan-dependencies +----------------- + +Without modifying the database, we could do something less efficient. + +Upon removal of message X, we could scan the headers of all non-ghost +messages that share a thread with X. If any of those messages refers +to X, we would add a ghost message. If none of them do, then we would +just drop X entirely from the table. +--- + +Here I just changed the FAILing test to BROKEN. This reflects our +usual distinction between known bug and regression. + + test/T590-thread-breakage.sh | 67 ++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 67 insertions(+) + create mode 100755 test/T590-thread-breakage.sh + +diff --git a/test/T590-thread-breakage.sh b/test/T590-thread-breakage.sh +new file mode 100755 +index 0000000..8c8e63b +--- /dev/null ++++ b/test/T590-thread-breakage.sh +@@ -0,0 +1,67 @@ ++#!/usr/bin/env bash ++# ++# Copyright (c) 2016 Daniel Kahn Gillmor ++# ++ ++test_description='thread breakage by reindexing (currently broken)' ++ ++. ./test-lib.sh || exit 1 ++ ++message_a() { ++ mkdir -p ${MAIL_DIR}/cur ++ cat > ${MAIL_DIR}/cur/a < ++From: Alice ++To: Bob ++Date: Thu, 31 Mar 2016 20:10:00 -0400 ++ ++This is the first message in the thread. ++EOF ++} ++ ++message_b() { ++ mkdir -p ${MAIL_DIR}/cur ++ cat > ${MAIL_DIR}/cur/b < ++In-Reply-To: ++References: ++From: Bob ++To: Alice ++Date: Thu, 31 Mar 2016 20:15:00 -0400 ++ ++This is the second message in the thread. ++EOF ++} ++ ++ ++test_thread_count() { ++ notmuch new >/dev/null ++ test_begin_subtest "${2:-Expecting $1 thread(s)}" ++ count=$(notmuch count --output=threads) ++ test_expect_equal "$count" "$1" ++} ++ ++test_thread_count 0 'There should be no threads initially' ++ ++message_a ++test_thread_count 1 'One message in: one thread' ++ ++message_b ++test_thread_count 1 'Second message in the same thread: one thread' ++ ++rm -f ${MAIL_DIR}/cur/a ++test_thread_count 1 'First message removed: still only one thread' ++ ++message_a ++# this is known to fail (it shows 2 threads) because no "ghost ++# message" was created for message A when it was removed from the ++# index, despite message B still pointing to it. ++test_begin_subtest 'First message reappears: should return to the same thread' ++test_subtest_known_broken ++notmuch new >/dev/null ++count=$(notmuch count --output=threads) ++test_expect_equal "$count" "1" ++ ++test_done +-- +2.8.0.rc3 + -- 2.26.2