From: Pieter Praet <pieter@praet.org>
To: Carl Worth <cworth@cworth.org>,
Mark Anderson <ma.skies@gmail.com>,
Robin Green <greenrd@greenrd.org>
Cc: notmuch@notmuchmail.org
Subject: Re: [PATCH 2/2] [RFC] possible solution for "Race condition for '*' command"
Date: Thu, 30 Jun 2011 21:38:22 +0200 [thread overview]
Message-ID: <87r56brtxt.fsf@praet.org> (raw)
In-Reply-To: <1309450108-2793-2-git-send-email-pieter@praet.org>
On Thu, 30 Jun 2011 18:08:28 +0200, Pieter Praet <pieter@praet.org> wrote:
> `notmuch-search-operate-all' may cause a race condition because
> repeatedly running `notmuch-tag' with the *original* query string
> makes the result list a moving target.
>
> One approach to resolving this, is to feed `notmuch-tag' a static result
> list based on the original query string, instead of the latter itself.
>
> See discussion @ id:"86d3i1d06r.fsf@dragonfly.greenrd.org"
>
> Signed-off-by: Pieter Praet <pieter@praet.org>
> ---
>
> Carl,
>
> I've gone along a different route which assures only matched messages
> are touched, but it does come with quite a performance hit.
>
> Since there isn't a test for the actual race condition(s), I can't be
> sure, but theoretically, at least one of them should be fixed now.
>
> Peace
>
> emacs/notmuch.el | 11 +++++++++--
> 1 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index f11ec24..84c3ee6 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -845,7 +845,8 @@ Each character of the tag name may consist of alphanumeric
> characters as well as `_.+-'.
> "
> (interactive "sOperation (+add -drop): notmuch tag ")
> - (let ((action-split (split-string action " +")))
> + (let ((action-split (split-string action " +"))
> + (query notmuch-search-query-string))
> ;; Perform some validation
> (let ((words action-split))
> (when (null words) (error "No operation given"))
> @@ -853,7 +854,13 @@ characters as well as `_.+-'.
> (unless (string-match-p "^[-+][-+_.[:word:]]+$" (car words))
> (error "Action must be of the form `+thistag -that_tag'"))
> (setq words (cdr words))))
> - (apply 'notmuch-tag notmuch-search-query-string action-split)))
> + (dolist (msgid
> + (split-string
> + (with-output-to-string
> + (with-current-buffer standard-output
> + (apply 'call-process notmuch-command nil t nil "search" "--output=messages" (list query))))
> + "\n+" t))
> + (apply 'notmuch-tag msgid action-split))))
>
> (defun notmuch-search-buffer-title (query)
> "Returns the title for a buffer with notmuch search results."
> --
> 1.7.4.1
>
Ok, even though my very first reply [1] may have created the impression
that I understood the issue, I clearly didn't...
The test [2] needs a more applicable commit message, and the subsequent
patch [3] points more or less in the right direction, but the Message-Id
list should be local to the *search buffer* rather than to the
`notmuch-search-operate-all' function.
`notmuch-search' could:
- run "notmuch-command search" with the "--output=messages" option
instead of a plain search,
- maintain a buffer-local var with a list of returned Message-Id's,
- ...and populate the buffer based on that list.
As such we'd have -for each individual search buffer- a canonical list
of Message-Id's (i.e. messages which actually *match* the query AND are
currently visible in the search buffer), to be used by
`notmuch-search-operate-all' et al.
Peace
--
Pieter
[1] id:"87fwmuxxgd.fsf@praet.org"
[2] id:"1309450108-2793-2-git-send-email-pieter@praet.org"
[3] id:"1309450108-2793-1-git-send-email-pieter@praet.org"
next prev parent reply other threads:[~2011-06-30 19:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-25 22:18 Race condition for '*' command Robin Green
2011-06-25 23:57 ` Jameson Graef Rollins
2011-06-26 9:00 ` Robin Green
2011-06-28 6:49 ` Pieter Praet
2011-06-28 17:36 ` Mark Anderson
2011-06-28 19:48 ` Carl Worth
2011-06-30 16:08 ` [PATCH 1/2] test: add/remove tags from all matching messages with `notmuch-search-operate-all' Pieter Praet
2011-06-30 16:08 ` [PATCH 2/2] [RFC] possible solution for "Race condition for '*' command" Pieter Praet
2011-06-30 19:38 ` Pieter Praet [this message]
2011-07-01 14:55 ` Austin Clements
-- strict thread matches above, loose matches on Subject: below --
2011-07-01 16:37 Austin Clements
2011-07-02 14:20 ` Pieter Praet
2011-07-03 17:17 ` Austin Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r56brtxt.fsf@praet.org \
--to=pieter@praet.org \
--cc=cworth@cworth.org \
--cc=greenrd@greenrd.org \
--cc=ma.skies@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).