couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1026916 - /couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl
Date Sun, 24 Oct 2010 23:41:14 GMT
Author: fdmanana
Date: Sun Oct 24 23:41:14 2010
New Revision: 1026916

URL: http://svn.apache.org/viewvc?rev=1026916&view=rev
Log:
New replicator: fixes for determining the next checkpoint source sequence number.

Modified:
    couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl

Modified: couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl?rev=1026916&r1=1026915&r2=1026916&view=diff
==============================================================================
--- couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl (original)
+++ couchdb/branches/new_replicator/src/couchdb/couch_replicator.erl Sun Oct 24 23:41:14 2010
@@ -666,21 +666,26 @@ process_seq_changes_done({Seq, NumChange
     } = State,
 
     Total = gb_trees:get(Seq, SeqsInProgress),
-    SeqsInProgress2 = case Total - NumChangesDone of
+    {ThroughSeq2, SeqsInProgress2, DoneSeqs2} = case Total - NumChangesDone of
     0 ->
-        gb_trees:delete(Seq, SeqsInProgress);
+        {NewDoneSeqs, NewThroughSeq} = case gb_trees:smallest(SeqsInProgress) of
+        {Seq, Total} ->
+            {DoneSeqs, Seq};
+        _ ->
+            {ordsets:add_element(Seq, DoneSeqs), ThroughSeq}
+        end,
+        {NewThroughSeq, gb_trees:delete(Seq, SeqsInProgress), NewDoneSeqs};
     NewTotal when NewTotal > 0 ->
-        gb_trees:update(Seq, NewTotal, SeqsInProgress)
+        {ThroughSeq, gb_trees:update(Seq, NewTotal, SeqsInProgress), DoneSeqs}
     end,
 
-    DoneSeqs2 = ordsets:add_element(Seq, DoneSeqs),
-    {NewThroughSeq, DoneSeqs3} =
-        get_next_through_seq(ThroughSeq, SeqsInProgress2, DoneSeqs2),
+    {ThroughSeq3, DoneSeqs3} =
+        get_next_through_seq(ThroughSeq2, SeqsInProgress2, DoneSeqs2),
 
     State#rep_state{
         seqs_in_progress = SeqsInProgress2,
         next_through_seqs = DoneSeqs3,
-        current_through_seq = NewThroughSeq
+        current_through_seq = ThroughSeq3
     }.
 
 



Mime
View raw message