Re: [PATCH v2 5/5] compact: provide user more information on after-compaction failures
authorJani Nikula <jani@nikula.org>
Thu, 14 Nov 2013 14:13:25 +0000 (15:13 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:18 +0000 (09:58 -0800)
20/9f6f793032ac3058fbc9e2d7a640c9c79f6ec7 [new file with mode: 0644]

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