--- /dev/null
+Return-Path: <eg@gaute.vetsj.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id AB025431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 11 Aug 2014 05:18:08 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 74MwyFmpTj8R for <notmuch@notmuchmail.org>;\r
+ Mon, 11 Aug 2014 05:17:58 -0700 (PDT)\r
+Received: from mail-qg0-f48.google.com (mail-qg0-f48.google.com\r
+ [209.85.192.48]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 120CA431FAE\r
+ for <notmuch@notmuchmail.org>; Mon, 11 Aug 2014 05:17:58 -0700 (PDT)\r
+Received: by mail-qg0-f48.google.com with SMTP id i50so8336100qgf.35\r
+ for <notmuch@notmuchmail.org>; Mon, 11 Aug 2014 05:17:56 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:mime-version:date:message-id:subject:from:to\r
+ :content-type;\r
+ bh=zNSOgcDHBtBfm3lylf7EplrsfpI2eV7SX6iIlF1Edyw=;\r
+ b=iJGTIxnT6TTZvB4t035d2YqzXuipL/xpGjKKS2j5qkRRLr8y3VtD1mKdlR4Fnh808x\r
+ +zO4X0DZVdJDxt/yc/rg++Dv3YsNeGjhswW0u1FB7LkZJ5g1UfLw39955YNysjhCDu9J\r
+ dys2bONIS/02aJKdO75wX3W8dnq/cQ7BjhB6FbVff5OCGS02+3M7uKfv14UwxyXr1XCu\r
+ 4FZelACrz+r65HIDNPHD4XroZX3lqnK3IW2/Wvjd3iIIarv7B0XKd0PvAlWCmwRwqXEq\r
+ nafGEiN2rLvxKRCxzYzigNTL8eY8Ss3+3Pot4iaj0JyamjNBKr1TRfGW8+KV/gpXE+IV\r
+ Ugdg==\r
+X-Gm-Message-State:\r
+ ALoCoQnNRkazZ2Ia8zvIDNVivGrJr7+FDOg+ha5SzL2v7T8U88SuHDsLk1uxoWIiWinreLZosh9V\r
+MIME-Version: 1.0\r
+X-Received: by 10.224.137.65 with SMTP id v1mr62602608qat.53.1407759475308;\r
+ Mon, 11 Aug 2014 05:17:55 -0700 (PDT)\r
+Received: by 10.140.86.148 with HTTP; Mon, 11 Aug 2014 05:17:54 -0700 (PDT)\r
+Date: Mon, 11 Aug 2014 14:17:54 +0200\r
+Message-ID:\r
+ <CABKe4MvEdcsq8BZ-vq6R0Vnw87zEgBvqW_2F-Wysf5GNchqweg@mail.gmail.com>\r
+Subject: DatabaseModifiedErrors causing troubles\r
+From: Gaute Hope <eg@gaute.vetsj.com>\r
+To: notmuch <notmuch@notmuchmail.org>\r
+Content-Type: multipart/mixed; boundary=001a11c2cc3074c37c0500598b50\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 11 Aug 2014 12:18:08 -0000\r
+\r
+--001a11c2cc3074c37c0500598b50\r
+Content-Type: text/plain; charset=UTF-8\r
+\r
+Hi,\r
+\r
+I've been working on an application that keeps a read-only handle on\r
+the notmuch database open for a long time. In some cases when a new\r
+message is added along with some renames of other messages using\r
+'notmuch new' while the application is running I get an Xapian\r
+exception: DatabaseModifiedError:\r
+\r
+ A Xapian exception occurred performing query: The revision being\r
+read has been discarded - you\r
+ should call Xapian::Database::reopen() and retry the operation.\r
+\r
+Which seems to be printed from: notmuch_query_search_threads ->\r
+notmuch_query_search_messages:294.\r
+\r
+I have not been able to make a smaller test case at the moment (this\r
+happens with offlineimap updating an maildir and notmuch new run\r
+afterwards + some tagging).\r
+\r
+I can work around this by checking for a NULL pointer returned from\r
+notmuch_query_search_threads () and re-open the database\r
+(notmuch_database_close () -> notmuch_database_open ()). But I have no\r
+way of knowing programatically if this really is the error that has\r
+happened. There should be some way of propagating the error\r
+information or (even better for my case; for notmuch to reopen the\r
+database), one option is the Gmime way of passing an pointer to an\r
+error structure that is filled up by the notmuch interface function.\r
+\r
+I made some attempts at exposing the ::reopen() function as suggested\r
+by Xapian (http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#af140b1f8d948d13cf7be4a11a7c699a4),\r
+but I end up with other errors afterwards. Possibly from leftover\r
+structures created with the original database handle:\r
+\r
+after notmuch_database_reopen (see attached patch for your reference):\r
+ A Xapian exception occurred when reading header: Expected block\r
+24615 to be level 1, not 0\r
+ A Xapian exception occurred when reading header: Error reading block\r
+419480589: got end of file\r
+ A Xapian exception occurred when reading date: Error reading block\r
+419480589: got end of file\r
+ A Xapian exception occurred when reading header: Error reading block\r
+419480589: got end of file\r
+\r
+\r
+as mentioned, doing a manual _close and _open works. Again, the best\r
+would be a consistent way to really know that this (or something else)\r
+is the error that really happened.\r
+\r
+Cheers, Gaute\r
+\r
+--001a11c2cc3074c37c0500598b50\r
+Content-Type: text/x-patch; charset=US-ASCII; \r
+ name="0001-lib-expose-XapianDatabae-reopen-through-notmuch_data.patch"\r
+Content-Disposition: attachment; \r
+ filename="0001-lib-expose-XapianDatabae-reopen-through-notmuch_data.patch"\r
+Content-Transfer-Encoding: base64\r
+X-Attachment-Id: f_hyprlohc0\r
+\r
+RnJvbSA5MDM0MGZlNTlkNjc3Yzk4OTM1MmYwOGU4MmY5MDgwMTZjMjVmYWZhIE1vbiBTZXAgMTcg\r
+MDA6MDA6MDAgMjAwMQpGcm9tOiBHYXV0ZSBIb3BlIDxlZ0BnYXV0ZS52ZXRzai5jb20+CkRhdGU6\r
+IE1vbiwgMTEgQXVnIDIwMTQgMTQ6MTY6MTIgKzAyMDAKU3ViamVjdDogW1BBVENIXSBsaWI6IGV4\r
+cG9zZSBYYXBpYW5EYXRhYmFlOjpyZW9wZW4oKSB0aHJvdWdoCiBub3RtdWNoX2RhdGFiYXNlX3Jl\r
+b3BlbigpCgotLS0KIGxpYi9kYXRhYmFzZS5jYyB8IDE4ICsrKysrKysrKysrKysrKysrKwogbGli\r
+L25vdG11Y2guaCAgIHwgMjIgKysrKysrKysrKysrKysrKysrKysrKwogMiBmaWxlcyBjaGFuZ2Vk\r
+LCA0MCBpbnNlcnRpb25zKCspCgpkaWZmIC0tZ2l0IGEvbGliL2RhdGFiYXNlLmNjIGIvbGliL2Rh\r
+dGFiYXNlLmNjCmluZGV4IGM3NjAyOTAuLjgwYWY0MTAgMTAwNjQ0Ci0tLSBhL2xpYi9kYXRhYmFz\r
+ZS5jYworKysgYi9saWIvZGF0YWJhc2UuY2MKQEAgLTc3OCw2ICs3NzgsMjQgQEAgbm90bXVjaF9k\r
+YXRhYmFzZV9vcGVuIChjb25zdCBjaGFyICpwYXRoLAogfQogCiBub3RtdWNoX3N0YXR1c190Citu\r
+b3RtdWNoX2RhdGFiYXNlX3Jlb3BlbiAobm90bXVjaF9kYXRhYmFzZV90ICpub3RtdWNoKQorewor\r
+ICB0cnkgeworICAgIG5vdG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