You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2009/03/04 04:29:37 UTC
svn commit: r749889 - in /couchdb/branches/rep_security:
share/www/script/couch_tests.js src/couchdb/couch_rep.erl
Author: damien
Date: Wed Mar 4 03:29:35 2009
New Revision: 749889
URL: http://svn.apache.org/viewvc?rev=749889&view=rev
Log:
Added stats check test for doc replication failures
Modified:
couchdb/branches/rep_security/share/www/script/couch_tests.js
couchdb/branches/rep_security/src/couchdb/couch_rep.erl
Modified: couchdb/branches/rep_security/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/couchdb/branches/rep_security/share/www/script/couch_tests.js?rev=749889&r1=749888&r2=749889&view=diff
==============================================================================
--- couchdb/branches/rep_security/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/branches/rep_security/share/www/script/couch_tests.js [utf-8] Wed Mar 4 03:29:35 2009
@@ -3139,7 +3139,6 @@
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
var dbB = new CouchDB("test_suite_db_b",
{"WWW-Authenticate": "X-Couch-Test-Auth Christopher Lenz:dog food"});
- var numDocs = 10;
var xhr;
for (var testPair = 0; testPair < dbPairs.length; testPair++) {
var A = dbPairs[testPair].source
@@ -3189,7 +3188,12 @@
foo2.value = "b";
dbB.save(foo2);
- T(CouchDB.replicate(B, A).ok);
+ var results = CouchDB.replicate(B, A);
+
+ T(results.ok);
+
+ T(results.history[0].docs_written == 2);
+ T(results.history[0].doc_write_failures == 1);
// bad2 should not be on dbA
T(dbA.open("bad2") == null);
Modified: couchdb/branches/rep_security/src/couchdb/couch_rep.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/rep_security/src/couchdb/couch_rep.erl?rev=749889&r1=749888&r2=749889&view=diff
==============================================================================
--- couchdb/branches/rep_security/src/couchdb/couch_rep.erl (original)
+++ couchdb/branches/rep_security/src/couchdb/couch_rep.erl Wed Mar 4 03:29:35 2009
@@ -132,12 +132,21 @@
{ok, {OldRepHistoryProps}};
false ->
% commit changes to both src and tgt. The src because if changes
- % we replicated are lost, we'll record the a seq number of ahead
- % of what was committed and therefore lose future changes with the
- % same seq nums.
+ % we replicated are lost, we'll record the a seq number ahead
+ % of what was committed. If those changes are lost and the seq number
+ % reverts to a previous committed value, we will lose future changes
+ % when new doc updates are given our already replicated seq nums.
- {ok, SrcInstanceStartTime2} = ensure_full_commit(DbSrc),
+ % commit the src async
+ ParentPid = self(),
+ SrcCommitPid = spawn_link(fun() ->
+ ParentPid ! {self(), ensure_full_commit(DbSrc)} end),
+
+ % commit tgt sync
{ok, TgtInstanceStartTime2} = ensure_full_commit(DbTgt),
+
+ receive {SrcCommitPid, {ok, SrcInstanceStartTime2}} -> ok end,
+
RecordSeqNum =
if SrcInstanceStartTime2 == SrcInstanceStartTime andalso
TgtInstanceStartTime2 == TgtInstanceStartTime ->
@@ -150,7 +159,7 @@
end,
[rep_stats | StatsList] = tuple_to_list(Stats),
StatFieldNames =
- [?l2b(tuple_to_list(T)) || T <- record_info(fields, rep_stats)],
+ [?l2b(atom_to_list(T)) || T <- record_info(fields, rep_stats)],
StatProps = lists:zip(StatFieldNames, StatsList),
HistEntries =[
{