Handle the #doc_info case in changes_enumerator mem3-rep-always-use-fdi 1/head 31/head
authorRussell Branca <chewbranca@apache.org>
Wed, 18 Jun 2014 22:04:35 +0000 (15:04 -0700)
committerRussell Branca <chewbranca@apache.org>
Wed, 18 Jun 2014 22:04:35 +0000 (15:04 -0700)
This is to handle the special case where the user migrates a CouchDB
database to BigCouch and they have not yet compacted the
database. Once the database has been compacted, this #doc_info clause
should never be encountered.

src/mem3_rep.erl

index 373bc3f2e89ee78f3e92ced632c38ebdc2ebda7d..a4aadb5e407104d5dcec6a9e63c3797089c398b5 100644 (file)
@@ -28,7 +28,8 @@
     localid,
     source,
     target,
     localid,
     source,
     target,
-    filter
+    filter,
+    db
 }).
 
 go(Source, Target) ->
 }).
 
 go(Source, Target) ->
@@ -60,9 +61,10 @@ go(#shard{} = Source, #shard{} = Target, Opts) ->
     },
     go(Acc).
 
     },
     go(Acc).
 
-go(#acc{source=Source, batch_count=BC}=Acc) ->
+go(#acc{source=Source, batch_count=BC}=Acc0) ->
     case couch_db:open(Source#shard.name, [{user_ctx,?CTX}]) of
     {ok, Db} ->
     case couch_db:open(Source#shard.name, [{user_ctx,?CTX}]) of
     {ok, Db} ->
+        Acc = Acc0#acc{db=Db},
         Resp = try
             repl(Db, Acc)
         catch error:{not_found, no_db_file} ->
         Resp = try
             repl(Db, Acc)
         catch error:{not_found, no_db_file} ->
@@ -107,7 +109,11 @@ make_local_id(#shard{node=SourceNode}, #shard{node=TargetNode}, Filter) ->
     end,
     <<"_local/shard-sync-", S/binary, "-", T/binary, F/binary>>.
 
     end,
     <<"_local/shard-sync-", S/binary, "-", T/binary, F/binary>>.
 
-changes_enumerator(FDI, _, #acc{revcount=C, infos=Infos}=Acc0) ->
+changes_enumerator(#doc_info{id=DocId}, Reds, #acc{db=Db}=Acc) ->
+    {ok, FDI} = couch_db:get_full_doc_info(Db, DocId),
+    changes_enumerator(FDI, Reds, Acc);
+changes_enumerator(#full_doc_info{}=FDI, _,
+  #acc{revcount=C, infos=Infos}=Acc0) ->
     #doc_info{
         high_seq=Seq,
         revs=Revs
     #doc_info{
         high_seq=Seq,
         revs=Revs