From 594780a1e9f4c2ebc99fe17fe4522d091e17f1e7 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 14 Nov 2013 15:13:25 +0100 Subject: [PATCH] Re: [PATCH v2 5/5] compact: provide user more information on after-compaction failures --- 20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 | 160 ++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 diff --git a/20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 b/20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 new file mode 100644 index 000000000..5bf77645b --- /dev/null +++ b/20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 @@ -0,0 +1,160 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 0C95D431FC4 + for ; Thu, 14 Nov 2013 06:13:51 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id kkIJaMV5eigk for ; + Thu, 14 Nov 2013 06:13:43 -0800 (PST) +Received: from mail-we0-f179.google.com (mail-we0-f179.google.com + [74.125.82.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 628A9431FB6 + for ; Thu, 14 Nov 2013 06:13:43 -0800 (PST) +Received: by mail-we0-f179.google.com with SMTP id x55so1979632wes.38 + for ; Thu, 14 Nov 2013 06:13:42 -0800 (PST) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:cc:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=d5XhcYFpOR8ALgBzeY07/d9sZ9uB0ZGDrV5X0B3O2AY=; + b=BqriVgFvLAHrIjcByGhmfPlIDi+/naHwFTMd/qEDKxol2sNKKzM68P01t29olDA6Qq + S5sMMHxihIvY9YWeSfhWlA0Kz1+AA/yp661g6YhsVvCJPTMPHrWJWCb7Yc8e4V2CwPTg + D15zvoM6AdNTBVsO30MBlZIiBXLsVNROwyr5T4+7TAWZ9nnruiTYpODixMZ0KvpTbh3V + vEvwIV3BGgJK+DbjllqtcU98R67z+lW8CrPAjvoL4+1r7T2kydJ1Sr5oLOvPH1eBVgJA + 5y/lru6d38xHNadFre50FwxbAiQOz/S6gPM0X9NWHr3OLDKsq1Lmevi87T1EFs5EuGa2 + 3+Ow== +X-Gm-Message-State: + ALoCoQm88QTY/kjQ5fB52dKmEPLsqIm5S/l6PQjWwOdTMFw7RKcSaH5JZ7GpfoI0FCvJ/yrJnKOM +X-Received: by 10.180.39.238 with SMTP id s14mr2949815wik.60.1384438422023; + Thu, 14 Nov 2013 06:13:42 -0800 (PST) +Received: from localhost ([2001:4b98:dc0:43:216:3eff:fe1b:25f3]) + by mx.google.com with ESMTPSA id + uc12sm14290859wib.3.2013.11.14.06.13.40 for + (version=TLSv1.1 cipher=RC4-SHA bits=128/128); + Thu, 14 Nov 2013 06:13:41 -0800 (PST) +From: Jani Nikula +To: Tomi Ollila , notmuch@notmuchmail.org +Subject: Re: [PATCH v2 5/5] compact: provide user more information on + after-compaction failures +In-Reply-To: <1384362167-12740-6-git-send-email-tomi.ollila@iki.fi> +References: <1384362167-12740-1-git-send-email-tomi.ollila@iki.fi> + <1384362167-12740-6-git-send-email-tomi.ollila@iki.fi> +User-Agent: Notmuch/0.16+115~gd647c65 (http://notmuchmail.org) Emacs/23.2.1 + (x86_64-pc-linux-gnu) +Date: Thu, 14 Nov 2013 15:13:25 +0100 +Message-ID: <871u2jnkai.fsf@nikula.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +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: Thu, 14 Nov 2013 14:13:51 -0000 + +On Wed, 13 Nov 2013, Tomi Ollila wrote: +> After database has been compacted, there are steps to put the new +> database into place -- and these steps may fail. In case such +> failure happens, provide better information how to resolve it. + +I disagree with having a library spew all this information out. For each +case, I think it should be sufficient to just say what happened +(e.g. "rename a -> b failed" + strerror). I don't think a library's +error messages should be a tutorial on how to fix things. + +We may need to amend notmuch compact man page though. + +BR, +Jani. + + + +> +> Thanks to Ben Gamari for most of the information content. +> --- +> lib/database.cc | 39 +++++++++++++++++++++++++++++++++++---- +> 1 file changed, 35 insertions(+), 4 deletions(-) +> +> diff --git a/lib/database.cc b/lib/database.cc +> index 4b5ac64..a6daac6 100644 +> --- a/lib/database.cc +> +++ b/lib/database.cc +> @@ -939,19 +939,50 @@ notmuch_database_compact (const char *path, +> } +> +> if (rename (xapian_path, backup_path)) { +> - fprintf (stderr, "Error moving old database out of the way\n"); +> + fprintf (stderr, "Error moving old database out of the way:\n" +> + "Old database: %s\n" +> + "Backup database: %s\n" +> + "Error: %s\n", xapian_path, backup_path, strerror (errno)); +> ret = NOTMUCH_STATUS_FILE_ERROR; +> goto DONE; +> } +> +> if (rename (compact_xapian_path, xapian_path)) { +> - fprintf (stderr, "Error moving compacted database\n"); +> + fprintf (stderr, "Error moving compacted database into place: %s\n", +> + strerror (errno)); +> + fprintf (stderr, "\n" +> + "Encountered error while moving the compacted database\n" +> + "\n" +> + " %s\n" +> + "\n" +> + "to\n" +> + "\n" +> + " %s\n" +> + "\n" +> + "Please identify the reason for this and move the compacted database\n" +> + "into place manually.\n" +> + "\n" +> + "Alternatively you can revert to the uncompacted database with\n" +> + "\n" +> + " mv '%s' '%s'\n" +> + "\n", compact_xapian_path, xapian_path, +> + backup_path, xapian_path); +> ret = NOTMUCH_STATUS_FILE_ERROR; +> goto DONE; +> } +> +> - if (! keep_backup) +> - rmtree (backup_path); +> + if (! keep_backup) { +> + if (rmtree (backup_path)) { +> + fprintf (stderr, "Error removing backup database: %s\n", +> + strerror (errno)); +> + fprintf (stderr, "\n" +> + "Please remove the backup database with\n" +> + "\n" +> + " rm -rf '%s'\n" "\n", backup_path); +> + ret = NOTMUCH_STATUS_FILE_ERROR; +> + goto DONE; +> + } +> + } +> +> DONE: +> if (notmuch) +> -- +> 1.8.3.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2