Skip to content

Instantly share code, notes, and snippets.

@tilgovi
Created August 19, 2010 22:49
Show Gist options
  • Save tilgovi/539133 to your computer and use it in GitHub Desktop.
Save tilgovi/539133 to your computer and use it in GitHub Desktop.
diff --git a/src/couchdb/couch_rep.erl b/src/couchdb/couch_rep.erl
index 57b3008..301facb 100644
--- a/src/couchdb/couch_rep.erl
+++ b/src/couchdb/couch_rep.erl
@@ -648,7 +648,7 @@ do_checkpoint(State) ->
?LOG_INFO("recording a checkpoint for ~s -> ~s at source update_seq ~p",
[dbname(Source), dbname(Target), NewSeqNum]),
SessionId = couch_uuids:random(),
- NewHistoryEntry = {[
+ NewHistory = lists:sublist([{[
{<<"session_id">>, SessionId},
{<<"start_time">>, list_to_binary(ReplicationStartTime)},
{<<"end_time">>, list_to_binary(httpd_util:rfc1123_date())},
@@ -661,22 +661,23 @@ do_checkpoint(State) ->
{<<"docs_written">>, ets:lookup_element(Stats, docs_written, 2)},
{<<"doc_write_failures">>,
ets:lookup_element(Stats, doc_write_failures, 2)}
- ]},
+ ]} | OldHistory], 50),
% limit history to 50 entries
- NewRepHistory = {[
+ NewLog = {[
{<<"session_id">>, SessionId},
{<<"source_last_seq">>, NewSeqNum},
- {<<"history">>, lists:sublist([NewHistoryEntry | OldHistory], 50)}
+ {<<"history">>, NewHistory}
]},
try
{SrcRevPos,SrcRevId} =
- update_local_doc(Source, SourceLog#doc{body=NewRepHistory}),
+ update_local_doc(Source, SourceLog#doc{body=NewLog}),
{TgtRevPos,TgtRevId} =
- update_local_doc(Target, TargetLog#doc{body=NewRepHistory}),
+ update_local_doc(Target, TargetLog#doc{body=NewLog}),
State#state{
+ history = NewHistory,
checkpoint_scheduled = nil,
- checkpoint_history = NewRepHistory,
+ checkpoint_history = NewLog,
source_log = SourceLog#doc{revs={SrcRevPos, [SrcRevId]}},
target_log = TargetLog#doc{revs={TgtRevPos, [TgtRevId]}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment