couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject svn commit: r911545 - in /couchdb/branches/0.11.x: ./ etc/default/couchdb share/Makefile.am src/couchdb/couch_view.erl src/couchdb/couch_view_group.erl test/etap/150-invalid-view-seq.t test/etap/Makefile.am
Date Thu, 18 Feb 2010 20:04:01 GMT
Author: davisp
Date: Thu Feb 18 20:04:01 2010
New Revision: 911545

URL: http://svn.apache.org/viewvc?rev=911545&view=rev
Log:
Back porting fix for COUCHDB-640 - r911544


Added:
    couchdb/branches/0.11.x/test/etap/150-invalid-view-seq.t
      - copied unchanged from r911544, couchdb/trunk/test/etap/150-invalid-view-seq.t
Modified:
    couchdb/branches/0.11.x/   (props changed)
    couchdb/branches/0.11.x/etc/default/couchdb   (props changed)
    couchdb/branches/0.11.x/share/Makefile.am
    couchdb/branches/0.11.x/src/couchdb/couch_view.erl
    couchdb/branches/0.11.x/src/couchdb/couch_view_group.erl
    couchdb/branches/0.11.x/test/etap/Makefile.am

Propchange: couchdb/branches/0.11.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 18 20:04:01 2010
@@ -6,4 +6,4 @@
 /couchdb/branches/list-iterator:782292-784593
 /couchdb/branches/tail_header:775760-778477
 /couchdb/tags/0.10.0:825400
-/couchdb/trunk:909247,910054,910696
+/couchdb/trunk:909247,910054,910696,911544

Propchange: couchdb/branches/0.11.x/etc/default/couchdb
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 18 20:04:01 2010
@@ -6,5 +6,5 @@
 /couchdb/branches/list-iterator/etc/default/couchdb:782292-784593
 /couchdb/branches/tail_header/etc/default/couchdb:775760-778477
 /couchdb/tags/0.10.0/etc/default/couchdb:825400
-/couchdb/trunk/etc/default/couchdb:909247,910054,910696
+/couchdb/trunk/etc/default/couchdb:909247,910054,910696,911544
 /incubator/couchdb/trunk/etc/default/couchdb:642419-694440

Modified: couchdb/branches/0.11.x/share/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/Makefile.am?rev=911545&r1=911544&r2=911545&view=diff
==============================================================================
--- couchdb/branches/0.11.x/share/Makefile.am (original)
+++ couchdb/branches/0.11.x/share/Makefile.am Thu Feb 18 20:04:01 2010
@@ -34,8 +34,10 @@
 
 EXTRA_DIST = $(JS_FILE_COMPONENTS) $(JS_FILE_COMPONENTS_LAST)
 
+nobase_localdata_SCRIPTS = \
+    $(JS_FILE)
+
 nobase_dist_localdata_DATA = \
-    $(JS_FILE) \
     www/config.html \
     www/couch_tests.html \
     www/custom_test.html \

Modified: couchdb/branches/0.11.x/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_view.erl?rev=911545&r1=911544&r2=911545&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_view.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_view.erl Thu Feb 18 20:04:01 2010
@@ -284,6 +284,15 @@
         {ok, NewPid} ->
             add_to_ets(NewPid, DbName, Sig),
             {reply, {ok, NewPid}, Server};
+        {error, invalid_view_seq} ->
+            do_reset_indexes(DbName, Root),
+            case (catch couch_view_group:start_link({Root, DbName, Group})) of
+            {ok, NewPid} ->
+                add_to_ets(NewPid, DbName, Sig),
+                {reply, {ok, NewPid}, Server};
+            Error ->
+                {reply, Error, Server}
+            end;
         Error ->
             {reply, Error, Server}
         end;
@@ -292,6 +301,10 @@
     end.
 
 handle_cast({reset_indexes, DbName}, #server{root_dir=Root}=Server) ->
+    do_reset_indexes(DbName, Root),
+    {noreply, Server}.
+
+do_reset_indexes(DbName, Root) ->
     % shutdown all the updaters and clear the files, the db got changed
     Names = ets:lookup(couch_groups_by_db, DbName),
     lists:foreach(
@@ -304,8 +317,7 @@
             end
         end, Names),
     delete_index_dir(Root, DbName),
-    file:delete(Root ++ "/." ++ binary_to_list(DbName) ++ "_temp"),
-    {noreply, Server}.
+    file:delete(Root ++ "/." ++ ?b2l(DbName) ++ "_temp").
 
 handle_info({'EXIT', FromPid, Reason}, Server) ->
     case ets:lookup(couch_groups_by_updater, FromPid) of

Modified: couchdb/branches/0.11.x/src/couchdb/couch_view_group.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_view_group.erl?rev=911545&r1=911544&r2=911545&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_view_group.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_view_group.erl Thu Feb 18 20:04:01 2010
@@ -78,17 +78,25 @@
 init({InitArgs, ReturnPid, Ref}) ->
     process_flag(trap_exit, true),
     case prepare_group(InitArgs, false) of
-    {ok, #group{db=Db, fd=Fd}=Group} ->
-        couch_db:monitor(Db),
-        Owner = self(),
-        Pid = spawn_link(fun()-> couch_view_updater:update(Owner, Group) end),
-        {ok, RefCounter} = couch_ref_counter:start([Fd]),
-        {ok, #group_state{
-                db_name=couch_db:name(Db),
-                init_args=InitArgs,
-                updater_pid = Pid,
-                group=Group,
-                ref_counter=RefCounter}};
+    {ok, #group{db=Db, fd=Fd, current_seq=Seq}=Group} ->
+        case Seq > couch_db:get_update_seq(Db) of
+        true ->
+            ReturnPid ! {Ref, self(), {error, invalid_view_seq}},
+            ignore;
+        _ ->
+            couch_db:monitor(Db),
+            Owner = self(),
+            Pid = spawn_link(
+                fun()-> couch_view_updater:update(Owner, Group) end
+            ),
+            {ok, RefCounter} = couch_ref_counter:start([Fd]),
+            {ok, #group_state{
+                    db_name=couch_db:name(Db),
+                    init_args=InitArgs,
+                    updater_pid = Pid,
+                    group=Group,
+                    ref_counter=RefCounter}}
+        end;
     Error ->
         ReturnPid ! {Ref, self(), Error},
         ignore

Modified: couchdb/branches/0.11.x/test/etap/Makefile.am
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/test/etap/Makefile.am?rev=911545&r1=911544&r2=911545&view=diff
==============================================================================
--- couchdb/branches/0.11.x/test/etap/Makefile.am (original)
+++ couchdb/branches/0.11.x/test/etap/Makefile.am Thu Feb 18 20:04:01 2010
@@ -61,4 +61,8 @@
     120-stats-collect.t \
     121-stats-aggregates.cfg \
     121-stats-aggregates.ini \
-    121-stats-aggregates.t
+    121-stats-aggregates.t \
+    130-attachments-md5.t \
+    140-attachment-comp.t \
+    150-invalid-view-seq.t
+



Mime
View raw message