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 2011/09/16 19:09:35 UTC
svn commit: r1171675 - in /couchdb/trunk/src/couch_index/src:
couch_index.erl couch_index_compactor.erl couch_index_updater.erl
Author: davisp
Date: Fri Sep 16 17:09:34 2011
New Revision: 1171675
URL: http://svn.apache.org/viewvc?rev=1171675&view=rev
Log:
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.
Modified:
couchdb/trunk/src/couch_index/src/couch_index.erl
couchdb/trunk/src/couch_index/src/couch_index_compactor.erl
couchdb/trunk/src/couch_index/src/couch_index_updater.erl
Modified: couchdb/trunk/src/couch_index/src/couch_index.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_index/src/couch_index.erl?rev=1171675&r1=1171674&r2=1171675&view=diff
==============================================================================
--- couchdb/trunk/src/couch_index/src/couch_index.erl (original)
+++ couchdb/trunk/src/couch_index/src/couch_index.erl Fri Sep 16 17:09:34 2011
@@ -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}, Stat
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=[]}}.
Modified: couchdb/trunk/src/couch_index/src/couch_index_compactor.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_index/src/couch_index_compactor.erl?rev=1171675&r1=1171674&r2=1171675&view=diff
==============================================================================
--- couchdb/trunk/src/couch_index/src/couch_index_compactor.erl (original)
+++ couchdb/trunk/src/couch_index/src/couch_index_compactor.erl Fri Sep 16 17:09:34 2011
@@ -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.
Modified: couchdb/trunk/src/couch_index/src/couch_index_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couch_index/src/couch_index_updater.erl?rev=1171675&r1=1171674&r2=1171675&view=diff
==============================================================================
--- couchdb/trunk/src/couch_index/src/couch_index_updater.erl (original)
+++ couchdb/trunk/src/couch_index/src/couch_index_updater.erl Fri Sep 16 17:09:34 2011
@@ -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) ->