Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47BE69461 for ; Wed, 16 Nov 2011 15:51:01 +0000 (UTC) Received: (qmail 51838 invoked by uid 500); 16 Nov 2011 15:51:01 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 51801 invoked by uid 500); 16 Nov 2011 15:51:01 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 51794 invoked by uid 99); 16 Nov 2011 15:51:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2011 15:51:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.114] (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Nov 2011 15:50:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 935EC54959; Wed, 16 Nov 2011 15:50:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: fdmanana@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: Fix database compaction retry after server restart Message-Id: <20111116155037.935EC54959@tyr.zones.apache.org> Date: Wed, 16 Nov 2011 15:50:37 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Updated Branches: refs/heads/master 5d4b8d876 -> 4aa872359 Fix database compaction retry after server restart If we attempt to compact a database which has a .compact file left from a previous compaction attempt, and the current attempt is the first one, the server will crash because the task was not registered before. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4aa87235 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4aa87235 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4aa87235 Branch: refs/heads/master Commit: 4aa872359e64a51dabcf5a4d3c49f3d93e6f1def Parents: 5d4b8d8 Author: Filipe David Borba Manana Authored: Wed Nov 16 14:11:10 2011 +0000 Committer: Filipe David Borba Manana Committed: Wed Nov 16 14:11:10 2011 +0000 ---------------------------------------------------------------------- src/couchdb/couch_db_updater.erl | 2 +- src/couchdb/couch_task_status.erl | 5 +++++ 2 files changed, 6 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/4aa87235/src/couchdb/couch_db_updater.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl index 8009f5b..e15a944 100644 --- a/src/couchdb/couch_db_updater.erl +++ b/src/couchdb/couch_db_updater.erl @@ -932,7 +932,7 @@ copy_compact(Db, NewDb0, Retry) -> {changes_done, 0}, {total_changes, TotalChanges} ], - case Retry of + case Retry and couch_task_status:is_task_added() of true -> couch_task_status:update([ {retry, true}, http://git-wip-us.apache.org/repos/asf/couchdb/blob/4aa87235/src/couchdb/couch_task_status.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_task_status.erl b/src/couchdb/couch_task_status.erl index d3d7481..e23b560 100644 --- a/src/couchdb/couch_task_status.erl +++ b/src/couchdb/couch_task_status.erl @@ -26,6 +26,7 @@ -export([start_link/0, stop/0]). -export([all/0, add_task/1, update/1, get/1, set_update_frequency/1]). +-export([is_task_added/0]). -export([init/1, terminate/2, code_change/3]). -export([handle_call/3, handle_cast/2, handle_info/2]). @@ -56,6 +57,10 @@ add_task(Props) -> gen_server:call(?MODULE, {add_task, TaskProps}). +is_task_added() -> + is_list(erlang:get(task_status_props)). + + set_update_frequency(Msecs) -> put(task_status_update, {{0, 0, 0}, Msecs * 1000}).