Re: [PATCH v4 04/16] Provide _notmuch_crypto_{set,get}_gpg_path
[notmuch-archives.git] / 41 / b01274da9acae510c3db192d4e54884dcfdbac
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id E91D5431FC0\r
6         for <notmuch@notmuchmail.org>; Thu,  1 Jan 2015 10:22:00 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id kwOSoCmIUgiI for <notmuch@notmuchmail.org>;\r
16         Thu,  1 Jan 2015 10:21:57 -0800 (PST)\r
17 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com\r
18         [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 806D4431FAF\r
21         for <notmuch@notmuchmail.org>; Thu,  1 Jan 2015 10:21:57 -0800 (PST)\r
22 Received: by mail-wi0-f174.google.com with SMTP id h11so26827084wiw.1\r
23         for <notmuch@notmuchmail.org>; Thu, 01 Jan 2015 10:21:56 -0800 (PST)\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25         d=1e100.net; s=20130820;\r
26         h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
27         bh=0uSzEjuDOGI7a2nIRhECAFVYQEhm/l4emJvljfVRG9A=;\r
28         b=Lh1iw7qttnpROzfvKwvXkWmJMwO8B+uPQP9lh/tI4KJn1Hv9XgF3BAPpKNyRQVAsLg\r
29         ZLXgRGwJ+gJ9Wf/ZY8FXCjinnWPR4j9oOQ+PmWbX4fDGZBIvijF8qwQMg+Jar74iHxgv\r
30         q+jmTSzNC4e1XD3tXO7ACqiOJstr3fv0NgfN8qsnX7txuXIqJW51sKNa4TqGRX2mYfIw\r
31         bH12k7B1m6PqVV/kgsrvJgE5RSkQFIE/r+yzci8gtV4tRd/K/FDU5hrCQLJ3g7R8Hp6g\r
32         bmm3D1JGopuhpoYGIHcjl8uzKFIMVsahtIfzDHeojEfvS6MlqL1gRai/B5HDJ2dG5dN3\r
33         Sh7w==\r
34 X-Gm-Message-State:\r
35  ALoCoQmJpAWME6es/3LeMYTA+0SElJR0+BjRGS9VnYiSKUZqpxJHcWuePcSg0b8XHGC+teEREdFr\r
36 X-Received: by 10.194.175.69 with SMTP id by5mr139926544wjc.32.1420136516193; \r
37         Thu, 01 Jan 2015 10:21:56 -0800 (PST)\r
38 Received: from localhost (dsl-hkibrasgw2-58c371-91.dhcp.inet.fi.\r
39         [88.195.113.91])\r
40         by mx.google.com with ESMTPSA id lg7sm51493931wic.0.2015.01.01.10.21.55\r
41         (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
42         Thu, 01 Jan 2015 10:21:55 -0800 (PST)\r
43 From: Jani Nikula <jani@nikula.org>\r
44 To: notmuch@notmuchmail.org\r
45 Subject: [PATCH] HACK: lib: add brute and ignorant handling of database lock\r
46         errors\r
47 Date: Thu,  1 Jan 2015 20:22:03 +0200\r
48 Message-Id: <1420136523-27100-1-git-send-email-jani@nikula.org>\r
49 X-Mailer: git-send-email 2.1.4\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Thu, 01 Jan 2015 18:22:01 -0000\r
63 \r
64 From: Jani Nikula <jani.nikula@intel.com>\r
65 \r
66 Instead of failing at first try, back off for an increasing number of\r
67 seconds, and only fail after three attempts.\r
68 \r
69 One of my notmuch installations that gets plenty of mail hits db\r
70 locked exceptions quite often, and even more than before since I\r
71 switched to using notmuch insert. These are quite annoying in the\r
72 Emacs UI as there is virtually no error handling for tagging, and the\r
73 tag change highlighting gets confused.\r
74 \r
75 This is a dirty hack, but for me it's much more preferrable to the the\r
76 db locked exceptions. With the retries and increasing back-off timeout\r
77 I hardly ever see the exceptions now.\r
78 \r
79 Maybe this inspires someone to fix this for real. ;)\r
80 ---\r
81  lib/database.cc | 19 +++++++++++++++++--\r
82  1 file changed, 17 insertions(+), 2 deletions(-)\r
83 \r
84 diff --git a/lib/database.cc b/lib/database.cc\r
85 index 3601f9ded307..50063c55969b 100644\r
86 --- a/lib/database.cc\r
87 +++ b/lib/database.cc\r
88 @@ -819,8 +819,23 @@ notmuch_database_open (const char *path,\r
89         string last_thread_id;\r
90  \r
91         if (mode == NOTMUCH_DATABASE_MODE_READ_WRITE) {\r
92 -           notmuch->xapian_db = new Xapian::WritableDatabase (xapian_path,\r
93 -                                                              Xapian::DB_CREATE_OR_OPEN);\r
94 +           /*\r
95 +            * Brute and ignorant handling of database lock errors.\r
96 +            * Instead of failing at first try, back off for an\r
97 +            * increasing number of seconds.\r
98 +            */\r
99 +           for (unsigned int tries = 1; ! notmuch->xapian_db; tries++) {\r
100 +               try {\r
101 +                   notmuch->xapian_db =\r
102 +                       new Xapian::WritableDatabase (xapian_path,\r
103 +                                                     Xapian::DB_CREATE_OR_OPEN);\r
104 +               } catch (const Xapian::DatabaseLockError &error) {\r
105 +                   if (tries > 3)\r
106 +                       throw;\r
107 +\r
108 +                   sleep(tries);\r
109 +               }\r
110 +           }\r
111         } else {\r
112             notmuch->xapian_db = new Xapian::Database (xapian_path);\r
113         }\r
114 -- \r
115 2.1.4\r
116 \r