You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2012/01/03 21:06:28 UTC

[2/2] git commit: COUCHDB-1258 - Checkpoint views less often

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 <rn...@apache.org>
Authored: Tue Jan 3 18:26:04 2012 +0000
Committer: Robert Newson <rn...@apache.org>
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}.