From 8719f7ab34d0b6feb08ccf30f4494a0225850196 Mon Sep 17 00:00:00 2001 From: Matt Armstrong Date: Wed, 3 Aug 2016 08:26:43 +1700 Subject: [PATCH] A systematic way of handling Xapian lock errors? --- 3c/630faf4f61dfd4c29e9a042e49e3d4febdd739 | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 3c/630faf4f61dfd4c29e9a042e49e3d4febdd739 diff --git a/3c/630faf4f61dfd4c29e9a042e49e3d4febdd739 b/3c/630faf4f61dfd4c29e9a042e49e3d4febdd739 new file mode 100644 index 000000000..8da82c625 --- /dev/null +++ b/3c/630faf4f61dfd4c29e9a042e49e3d4febdd739 @@ -0,0 +1,105 @@ +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 614A16DE00BD + for ; Tue, 2 Aug 2016 08:26:54 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.924 +X-Spam-Level: +X-Spam-Status: No, score=-0.924 tagged_above=-999 required=5 tests=[AWL=0.098, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.211, SPF_PASS=-0.001, + T_RP_MATCHES_RCVD=-0.01] 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 kCwxpYkKRXiE for ; + Tue, 2 Aug 2016 08:26:46 -0700 (PDT) +Received: from mail-pf0-f172.google.com (mail-pf0-f172.google.com + [209.85.192.172]) + by arlo.cworth.org (Postfix) with ESMTPS id A65856DE00B8 + for ; Tue, 2 Aug 2016 08:26:46 -0700 (PDT) +Received: by mail-pf0-f172.google.com with SMTP id h186so67298282pfg.3 + for ; Tue, 02 Aug 2016 08:26:46 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; + s=20120113; h=from:to:subject:user-agent:date:message-id:mime-version; + bh=ffRJGbD5vRd7RuYrRx7W82o+QEU4NMc1xAvYrFV93qQ=; + b=PSR8Ok7Kkb68Pq8N232rXqEyY04XaZEmaumHaHDiXRbvhPeksrPF2QYtpIiibShYR4 + LzzsTmmy5hc7DYpwgQk/ya3bYe1oQSwbt1qjs9u06Sa5S1WwFQZiNe0z45jTfsoPkPno + H1gHzY6H9twsCeWKpbkoKUU2EPMierUPRaXtIjSQ9R+eqHVc6PlWxo+2+xpQN3obiEog + r+cqD9ah6ZnBdEJDMHBpC5zTabCpU8lKLGoFUT6Ua6IV8SsIuNXTQdvKcm0+a7fQHT+M + LK5PiLlFidrufFzzn4p828IUU+J2o2FnCa4C28rigHx+py8pC+IzjTS6TKp60Cp78gXJ gIfA== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:user-agent:date:message-id + :mime-version; + bh=ffRJGbD5vRd7RuYrRx7W82o+QEU4NMc1xAvYrFV93qQ=; + b=AYpTdK9MFyxOjFf51AHRmLF+Kikrmlnu3TvQjAsMvgLB65VPvELQ99GtSsyvFCrX4l + zkO5YGtWD+adoElyC29+AjNRja+HbsdI0T6lssi7JCA7pXAZ3WlbSDB52cwNwcTca1LW + FkLECq90ZYXfZLJctMT8xtOQ32DcccaWnExmYxXTiwUBi+Yas2KzyVUYtIiNmfSUtXBQ + vJXXK+ucJ1KIAGBt4Ed1GGvT/S7EgPke8QcVrm1oo8R36uFveeUtlGh8QbVfJ6qHqJov + r8UI8nqg+7bmjFJWM9ngLMMZaftZMCPFwtDKdQ1FKBxyh6Rv6FjILujAVCE8CcCFm+l+ + GGYw== +X-Gm-Message-State: + AEkooutuhwv4MOUdqvrR2wMWBNbjx7lYXJP5GhWemalsXVtD9VhD22M+uuQE1GWeZGWnF3At +X-Received: by 10.98.89.23 with SMTP id n23mr106972651pfb.34.1470151605729; + Tue, 02 Aug 2016 08:26:45 -0700 (PDT) +Received: from marmstrong-linux.kir.corp.google.com + ([2620:0:1008:1101:419b:e62d:4938:a6b6]) + by smtp.gmail.com with ESMTPSA id x66sm5700831pfb.86.2016.08.02.08.26.44 + for + (version=TLS1_2 cipher=AES128-SHA bits=128/128); + Tue, 02 Aug 2016 08:26:44 -0700 (PDT) +From: Matt Armstrong +To: notmuch@notmuchmail.org +Subject: A systematic way of handling Xapian lock errors? +User-Agent: Notmuch/0.21 (https://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Tue, 02 Aug 2016 08:26:43 -0700 +Message-ID: +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, 02 Aug 2016 15:26:54 -0000 + +Simple notmuch commands like "notmuch tag" can fail to grab the Xapian +lock. When this occurs they bail with: + +A Xapian exception occurred opening database: Unable to get write lock on /example/.notmuch/xapian: already locked + +I've noticed a few issues with this: + +1) The notmuch command line doesn't define semantics for exit codes. I +notice that notmuch exits with 1 for "xapian write lock error". I +suspect this code is not reserved for write lock errors? That would be +needed for any sensible downgrade of the write lock error into a soft +failure with a retry loop in things like shell scripts. + +2) The notmuch Emacs client just bails whatever it was trying when this +occurs. I run background mail fetching, which I expect is typical, and +this makes for an unpleasant experience as errors are thrown at me +randomly. Since my post-injection filter commands run quickly, I'd +rather Emacs simply spin a short while against the lock trying to +perform the command. Even a one second spin attempt is likely to +succeed most of the time. But I would happily configure an infinite +retry loop -- Emacs can show me a spinning ball, and I'd rather not be +subject to odd effects due to failures. + +To address both, has something like this ever been considered: + + notmuch --lock_timeout COMMAND ARG... + +Then frontends like Emacs could lean on retry logic written in C. If +this seems workable, it is something I can try implementing. -- 2.26.2