From commits-return-7721-apmail-couchdb-commits-archive=couchdb.apache.org@couchdb.apache.org Tue Jan 3 20:07:15 2012 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 1E42B9F92 for ; Tue, 3 Jan 2012 20:07:15 +0000 (UTC) Received: (qmail 83197 invoked by uid 500); 3 Jan 2012 20:07:14 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 83158 invoked by uid 500); 3 Jan 2012 20:07:14 -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 83142 invoked by uid 99); 3 Jan 2012 20:07:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jan 2012 20:07:14 +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; Tue, 03 Jan 2012 20:07:13 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 33CEC3157EC; Tue, 3 Jan 2012 20:06:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [2/2] git commit: COUCHDB-1258 - Checkpoint views less often Message-Id: <20120103200629.33CEC3157EC@tyr.zones.apache.org> Date: Tue, 3 Jan 2012 20:06:28 +0000 (UTC) COUCHDB-1258 - Checkpoint views less often Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/98719282 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/98719282 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/98719282 Branch: refs/heads/1.1.x Commit: 98719282744b93d03d0207d8a2819f643035b50d Parents: 3e24328 Author: Robert Newson Authored: Tue Jan 3 18:26:04 2012 +0000 Committer: Robert Newson Committed: Tue Jan 3 19:50:01 2012 +0000 ---------------------------------------------------------------------- src/couchdb/couch_view_group.erl | 25 +++++++++++++++++-------- 1 files changed, 17 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/98719282/src/couchdb/couch_view_group.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl index 9c5372a..532dd58 100644 --- a/src/couchdb/couch_view_group.erl +++ b/src/couchdb/couch_view_group.erl @@ -228,16 +228,25 @@ handle_cast({partial_update, Pid, NewGroup}, #group_state{updater_pid=Pid} = State) -> #group_state{ db_name = DbName, - waiting_commit = WaitingCommit + waiting_commit = WaitingCommit, + group = Group } = State, NewSeq = NewGroup#group.current_seq, - ?LOG_INFO("checkpointing view update at seq ~p for ~s ~s", [NewSeq, - DbName, NewGroup#group.name]), - if not WaitingCommit -> - erlang:send_after(1000, self(), delayed_commit); - true -> ok - end, - {noreply, State#group_state{group=NewGroup, waiting_commit=true}}; + CheckpointInterval = list_to_integer( + couch_config:get("couchdb","view_checkpoint_interval","100")), + case NewSeq > CheckpointInterval + Group#group.current_seq of + true -> + ?LOG_INFO("checkpointing view update at seq ~p for ~s ~s", [NewSeq, + DbName, NewGroup#group.name]), + if not WaitingCommit -> + erlang:send_after(1000, self(), delayed_commit); + true -> ok + end, + {noreply, State#group_state{group=NewGroup, waiting_commit=true}}; + false -> + {noreply, State} + end; + handle_cast({partial_update, _, _}, State) -> %% message from an old (probably pre-compaction) updater; ignore {noreply, State}.