From 567041f36175d7ae4de566f3ae028f039a9b02d6 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Tue, 5 Apr 2016 09:53:34 +0300 Subject: [PATCH] Re: [PATCH v2 3/7] fix thread breakage via ghost-on-removal --- df/3ef580593652b2e9b121f880fc9f360cd84a12 | 171 ++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 df/3ef580593652b2e9b121f880fc9f360cd84a12 diff --git a/df/3ef580593652b2e9b121f880fc9f360cd84a12 b/df/3ef580593652b2e9b121f880fc9f360cd84a12 new file mode 100644 index 000000000..6826382f3 --- /dev/null +++ b/df/3ef580593652b2e9b121f880fc9f360cd84a12 @@ -0,0 +1,171 @@ +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 90E146DE034D + for ; Mon, 4 Apr 2016 23:53:31 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.625 +X-Spam-Level: +X-Spam-Status: No, score=0.625 tagged_above=-999 required=5 tests=[AWL=-0.027, + SPF_NEUTRAL=0.652] 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 Kw2KJrRbRnui for ; + Mon, 4 Apr 2016 23:53:21 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id 9E2F56DE02C2 + for ; Mon, 4 Apr 2016 23:53:20 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id ED20F1000E0; + Tue, 5 Apr 2016 09:53:34 +0300 (EEST) +From: Tomi Ollila +To: Daniel Kahn Gillmor , + Notmuch Mail +Subject: Re: [PATCH v2 3/7] fix thread breakage via ghost-on-removal +In-Reply-To: <1459606541-23889-3-git-send-email-dkg@fifthhorseman.net> +References: <1459445693-3900-1-git-send-email-dkg@fifthhorseman.net> + <1459606541-23889-1-git-send-email-dkg@fifthhorseman.net> + <1459606541-23889-3-git-send-email-dkg@fifthhorseman.net> +User-Agent: Notmuch/0.21+99~g7cbc880 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Tue, 05 Apr 2016 06:53:31 -0000 + +On Sat, Apr 02 2016, Daniel Kahn Gillmor wrote: + +> ghost-on-removal the solution to T590-thread-breakage.sh that just +> adds a ghost message after removing each message. +> +> It leaks information about whether we've ever seen a given message id, +> but it's a fairly simple implementation. +> +> Note that _resolve_message_id_to_thread_id also introduces new +> message_ids to the database, so i think just searching for a given +> message ID may introduce the same metadata leakage. +> +> This differs from v1 of this changeset in that we implement the change +> in _notmuch_message_delete, a more "internal" function. + +I fetched your changes from lair.fifthhorseman.net yesterday and diffed +against master; looks pretty good, some quick comments (this email has +most relevant changes related to those changes): + +> --- +> lib/database.cc | 2 +- +> lib/message.cc | 29 ++++++++++++++++++++++++++--- +> 2 files changed, 27 insertions(+), 4 deletions(-) +> +> diff --git a/lib/database.cc b/lib/database.cc +> index 3b342f1..d5733c9 100644 +> --- a/lib/database.cc +> +++ b/lib/database.cc +> @@ -2557,7 +2557,7 @@ notmuch_database_remove_message (notmuch_database_t *notmuch, +> +> if (status == NOTMUCH_STATUS_SUCCESS && message) { +> status = _notmuch_message_remove_filename (message, filename); +> - if (status == NOTMUCH_STATUS_SUCCESS) +> + if (status == NOTMUCH_STATUS_SUCCESS) + +It looks to be that this change is insignificant enough so it could be +dropped ;) + +> _notmuch_message_delete (message); +> else if (status == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) +> _notmuch_message_sync (message); +> diff --git a/lib/message.cc b/lib/message.cc +> index 8d72ea2..e414e9c 100644 +> --- a/lib/message.cc +> +++ b/lib/message.cc +> @@ -1037,20 +1037,43 @@ _notmuch_message_sync (notmuch_message_t *message) +> message->modified = FALSE; +> } +> +> -/* Delete a message document from the database. */ +> +/* Delete a message document from the database, leaving a ghost +> + * message in its place */ + +This comment could tell the condition when ghost message is left -- +versus the case all ghost messages are dropped (thread becomes empty of +mail messages). + +> notmuch_status_t +> _notmuch_message_delete (notmuch_message_t *message) +> { +> notmuch_status_t status; +> Xapian::WritableDatabase *db; +> + const char *mid, *tid; +> + notmuch_message_t *ghost; +> + notmuch_private_status_t private_status; +> + notmuch_database_t *notmuch; +> + +> + mid = notmuch_message_get_message_id (message); +> + tid = notmuch_message_get_thread_id (message); +> + notmuch = message->notmuch; +> +> status = _notmuch_database_ensure_writable (message->notmuch); +> if (status) +> return status; +> +> - db = static_cast (message->notmuch->xapian_db); +> + db = static_cast (notmuch->xapian_db); +> db->delete_document (message->doc_id); +> - return NOTMUCH_STATUS_SUCCESS; +> + +> + /* and reintroduce a ghost in its place */ +> + ghost = _notmuch_message_create_for_message_id (notmuch, mid, &private_status); + +In next lines the expected case NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND +could be first. Although the performance difference is negligible to me +it looks silly do this first check and basically always fail there and +then do 'else if' which is likely to succeeed... +(your latest version in lair does not return in this first case but sets +status to NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID. Perhaps later messages in this +thread does the same but those are somewhat out-of-context for this reply). + +> + if (private_status == NOTMUCH_PRIVATE_STATUS_SUCCESS) { +> + /* this is deeply weird, and we should not have gotten into +> + this state. is there a better error message to return +> + here? */ +> + return NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; +> + } else if (private_status == NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND) { +> + private_status = _notmuch_message_initialize_ghost (ghost, tid); +> + if (! private_status) +> + _notmuch_message_sync (ghost); +> + } +> + notmuch_message_destroy (ghost); +> + return COERCE_STATUS (private_status, "Error converting to ghost message"); +> } + +Outside of this patch, but in some of the next messages, adds functions +_notmuch_message_has_term() and _notmuch_message_has_term_st(). Perhaps +the _notmuch_message_has_term() could be left unimplemented? + +> +> /* Transform a blank message into a ghost message. The caller must +> -- +> 2.8.0.rc3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> https://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2