You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 23:08:16 UTC

[02/32] git commit: Add logging for indexer events.

Add logging for indexer events.

This includes info messages for update start/finish, compaction
start/finish and index close on db exit. There are also debug
messages that display the update_seq during updates.



git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1171675 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/commit/e29573b9
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/tree/e29573b9
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/diff/e29573b9

Branch: refs/heads/import
Commit: e29573b955e5fb059bd821fe0118c85b8b1fae9a
Parents: dc11f92
Author: Paul Joseph Davis <da...@apache.org>
Authored: Fri Sep 16 17:09:34 2011 +0000
Committer: Paul Joseph Davis <da...@apache.org>
Committed: Fri Sep 16 17:09:34 2011 +0000

----------------------------------------------------------------------
 src/couch_index.erl           | 19 ++++++++++++++++++-
 src/couch_index_compactor.erl | 13 +++++++++++--
 src/couch_index_updater.erl   | 10 ++++++++--
 3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/e29573b9/src/couch_index.erl
----------------------------------------------------------------------
diff --git a/src/couch_index.erl b/src/couch_index.erl
index d9b0835..bfaf884 100644
--- a/src/couch_index.erl
+++ b/src/couch_index.erl
@@ -24,6 +24,9 @@
 -export([handle_call/3, handle_cast/2, handle_info/2]).
 
 
+-include("couch_db.hrl").
+
+
 -record(st, {
     mod,
     idx_state,
@@ -88,6 +91,12 @@ init({Mod, IdxState}) ->
                 compactor=CPid,
                 commit_delay=MsDelay
             },
+            Args = [
+                Mod:get(db_name, IdxState),
+                Mod:get(idx_name, IdxState),
+                Mod:get(signature, IdxState)
+            ],
+            ?LOG_INFO("Opening index for db: ~s idx: ~s~n    sig: ~p", Args),
             proc_lib:init_ack({ok, self()}),
             gen_server:enter_loop(?MODULE, [], State);
         Other ->
@@ -183,6 +192,12 @@ handle_cast({updated, NewIdxState}, State) ->
 handle_cast({new_state, NewIdxState}, State) ->
     #st{mod=Mod, commit_delay=Delay} = State,
     CurrSeq = Mod:get(update_seq, NewIdxState),
+    Args = [
+        Mod:get(db_name, NewIdxState),
+        Mod:get(idx_name, NewIdxState),
+        CurrSeq
+    ],
+    ?LOG_DEBUG("Updated index for db: ~s idx: ~s seq: ~B", Args),
     Rest = send_replies(State#st.waiters, CurrSeq, NewIdxState),
     case State#st.committed of
         true -> erlang:send_after(Delay, self(), commit);
@@ -228,7 +243,9 @@ handle_info(commit, State) ->
             erlang:send_after(Delay, self(), commit),
             {noreply, State}
     end;
-handle_info({'DOWN', _, _, _Pid, _}, State) ->
+handle_info({'DOWN', _, _, _Pid, _}, #st{mod=Mod, idx_state=IdxState}=State) ->
+    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    ?LOG_INFO("Index shutdown by monitor notice for db: ~s idx: ~s", Args),
     catch send_all(State#st.waiters, shutdown),
     {stop, normal, State#st{waiters=[]}}.
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/e29573b9/src/couch_index_compactor.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_compactor.erl b/src/couch_index_compactor.erl
index 7388324..9b71a16 100644
--- a/src/couch_index_compactor.erl
+++ b/src/couch_index_compactor.erl
@@ -22,6 +22,9 @@
 -export([handle_call/3, handle_cast/2, handle_info/2]).
 
 
+-include("couch_db.hrl").
+
+
 -record(st, {
     idx,
     mod,
@@ -103,8 +106,14 @@ compact(Parent, Mod, IdxState) ->
     compact(Parent, Mod, IdxState, []).
 
 compact(Idx, Mod, IdxState, Opts) ->
+    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    ?LOG_INFO("Compaction started for db: ~s idx: ~s", Args),
     {ok, NewIdxState} = Mod:compact(IdxState, Opts),
     case gen_server:call(Idx, {compacted, NewIdxState}) of
-        recompact -> compact(Idx, Mod, NewIdxState, [recompact]);
-        _ -> ok
+        recompact ->
+            ?LOG_INFO("Compaction restarting for db: ~s idx: ~s", Args),
+            compact(Idx, Mod, NewIdxState, [recompact]);
+        _ ->
+            ?LOG_INFO("Compaction finished for db: ~s idx: ~s", Args),
+            ok
     end.

http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/e29573b9/src/couch_index_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_updater.erl b/src/couch_index_updater.erl
index af245f2..1b90d2a 100644
--- a/src/couch_index_updater.erl
+++ b/src/couch_index_updater.erl
@@ -59,9 +59,13 @@ terminate(_Reason, State) ->
 handle_call({update, _IdxState}, _From, #st{pid=Pid}=State) when is_pid(Pid) ->
     {reply, ok, State};
 handle_call({update, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
+    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    ?LOG_INFO("Starting index update for db: ~s idx: ~s", Args),
     Pid = spawn_link(fun() -> update(Idx, Mod, IdxState) end),
     {reply, ok, State#st{pid=Pid}};
-handle_call({restart, IdxState}, _From, #st{idx=Idx}=State) ->
+handle_call({restart, IdxState}, _From, #st{idx=Idx, mod=Mod}=State) ->
+    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    ?LOG_INFO("Restarting index update for db: ~s idx: ~s", Args),
     case is_pid(State#st.pid) of
         true -> couch_util:shutdown_sync(State#st.pid);
         _ -> ok
@@ -78,7 +82,9 @@ handle_cast(_Mesg, State) ->
     {stop, unknown_cast, State}.
 
 
-handle_info({'EXIT', Pid, {updated, IdxState}}, #st{pid=Pid}=State) ->
+handle_info({'EXIT', Pid, {updated, IdxState}}, #st{mod=Mod, pid=Pid}=State) ->
+    Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
+    ?LOG_INFO("Index update finished for db: ~s idx: ~s", Args),
     ok = gen_server:cast(State#st.idx, {updated, IdxState}),
     {noreply, State#st{pid=undefined}};
 handle_info({'EXIT', Pid, reset}, #st{idx=Idx, pid=Pid}=State) ->