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/08/09 18:20:27 UTC
[2/2] git commit: Assert that #group.sig never changes in the
lifetime of a couch_view_group process
Assert that #group.sig never changes in the lifetime of a couch_view_group process
COUCHDB-1444 demonstrates that init_args and group get out of sync
somehow, leading to unexpected 404's (missing_named_view) and
200's. This patch ensures that #group.sig never changes in the hope
that it will lead to the cause of 1444 and prevent other occurrences
of the same class of bug.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/bb839770
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bb839770
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bb839770
Branch: refs/heads/1.2.x
Commit: bb8397707c5a84be89292073950eee13335ef595
Parents: bce1e60
Author: Robert Newson <rn...@apache.org>
Authored: Thu Aug 9 15:24:32 2012 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu Aug 9 15:24:32 2012 +0100
----------------------------------------------------------------------
src/couchdb/couch_view_group.erl | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bb839770/src/couchdb/couch_view_group.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl
index d5bd928..fee2547 100644
--- a/src/couchdb/couch_view_group.erl
+++ b/src/couchdb/couch_view_group.erl
@@ -180,11 +180,11 @@ handle_call({start_compact, _}, _From, State) ->
%% compact already running, this is a no-op
{reply, {ok, State#group_state.compactor_pid}, State};
-handle_call({compact_done, #group{current_seq=NewSeq} = NewGroup}, _From,
- #group_state{group = #group{current_seq=OldSeq}} = State)
+handle_call({compact_done, #group{sig=GroupSig, current_seq=NewSeq} = NewGroup}, _From,
+ #group_state{group = #group{sig=GroupSig, current_seq=OldSeq}} = State)
when NewSeq >= OldSeq ->
#group_state{
- group = #group{name=GroupId, fd=OldFd, sig=GroupSig},
+ group = #group{name=GroupId, fd=OldFd},
init_args = {RootDir, DbName, _},
updater_pid = UpdaterPid,
compactor_pid = CompactorPid,
@@ -222,7 +222,8 @@ handle_call({compact_done, #group{current_seq=NewSeq} = NewGroup}, _From,
compactor_pid=nil,
updater_pid=NewUpdaterPid
}};
-handle_call({compact_done, NewGroup}, _From, State) ->
+handle_call({compact_done, #group{sig=GroupSig} = NewGroup}, _From,
+ #group_state{group = #group{sig=GroupSig}} = State) ->
#group_state{
group = #group{name = GroupId, current_seq = CurrentSeq},
init_args={_RootDir, DbName, _}
@@ -245,8 +246,8 @@ handle_call(cancel_compact, _From, #group_state{compactor_pid = Pid} = State) ->
{reply, ok, State#group_state{compactor_pid = nil}}.
-handle_cast({partial_update, Pid, NewGroup}, #group_state{updater_pid=Pid}
- = State) ->
+handle_cast({partial_update, Pid, #group{sig=GroupSig}=NewGroup}, #group_state{updater_pid=Pid}
+ = #group_state{group = #group{sig=GroupSig}}=State) ->
#group_state{
db_name = DbName,
waiting_commit = WaitingCommit,
@@ -316,8 +317,9 @@ handle_info(delayed_commit, #group_state{db_name=DbName,group=Group}=State) ->
{noreply, State#group_state{waiting_commit=true}}
end;
-handle_info({'EXIT', FromPid, {new_group, Group}},
+handle_info({'EXIT', FromPid, {new_group, #group{sig=GroupSig} = Group}},
#group_state{db_name=DbName,
+ group=#group{sig=GroupSig},
updater_pid=UpPid,
ref_counter=RefCounter,
waiting_list=WaitList,