unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: notmuch@notmuchmail.org
Subject: notmuch modifies DB while iterating?
Date: Tue, 27 Feb 2018 22:44:14 +0000	[thread overview]
Message-ID: <20180227224414.GA31804@dcvr> (raw)

Hello, I'm neither a notmuch user or proficient in C++.

However, I noticed a bug while working on public-inbox (in Perl)
which shares Xapian thread linking logic with notmuch, and I
suspect notmuch is affected by the same problem as public-inbox.

The problem is in the _merge_threads function in add-message.cc
While the Xapian::PostingIterator for loser is iterating, the
Xapian DB is being modified by replace_document via
_notmuch_message_sync.

This was causing DatabaseCorruptError exceptions in public-inbox
with my dataset.

I fixed it in public-inbox by stashing docid scalars into a
Perl array while iterating with the PostingIterator, and then
doing lookups + replacements independently of the
PostingIterator by iterating through the Perl array:

	https://public-inbox.org/meta/20180227221302.7308-1-e@80x24.org/raw


I initially thought this was a bug in the glass backend, but
I've also hit it with chert.

I have a standalone Perl script to reproduce the bug at
https://yhbt.net/skel.bug.perl and 81M gzipped dataset which
reproduces the problem at https://yhbt.net/skel.bug.gz

(each line is: MID [REFERENCES-SEPARATED-BY-SPACES])

Usage:

For failure:
  curl https://yhbt.net/skel.bug.gz | zcat | perl -w /path/to/skel.bug.perl

For success:
  curl https://yhbt.net/skel.bug.gz | zcat | \
	BATCH_SIZE=1000 perl -w /path/to/skel.bug.perl

                 reply	other threads:[~2018-02-27 22:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20180227224414.GA31804@dcvr \
    --to=e@80x24.org \
    --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).