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/05/18 00:59:38 UTC
svn commit: r775776 - in /couchdb/branches/tail_header:
etc/couchdb/local_dev.ini share/www/script/test/delayed_commits.js
src/couchdb/couch_db.erl src/couchdb/couch_db_updater.erl
src/couchdb/couch_file.erl
Author: damien
Date: Sun May 17 22:59:37 2009
New Revision: 775776
URL: http://svn.apache.org/viewvc?rev=775776&view=rev
Log:
Fixed replication and modified the delayed_commit tests for the more robust crash behavior.
Modified:
couchdb/branches/tail_header/etc/couchdb/local_dev.ini
couchdb/branches/tail_header/share/www/script/test/delayed_commits.js
couchdb/branches/tail_header/src/couchdb/couch_db.erl
couchdb/branches/tail_header/src/couchdb/couch_db_updater.erl
couchdb/branches/tail_header/src/couchdb/couch_file.erl
Modified: couchdb/branches/tail_header/etc/couchdb/local_dev.ini
URL: http://svn.apache.org/viewvc/couchdb/branches/tail_header/etc/couchdb/local_dev.ini?rev=775776&r1=775775&r2=775776&view=diff
==============================================================================
--- couchdb/branches/tail_header/etc/couchdb/local_dev.ini (original)
+++ couchdb/branches/tail_header/etc/couchdb/local_dev.ini Sun May 17 22:59:37 2009
@@ -12,7 +12,7 @@
;bind_address = 127.0.0.1
[log]
-level = info
+level = error
[update_notification]
;unique notifier name=/full/path/to/exe -with "cmd line arg"
Modified: couchdb/branches/tail_header/share/www/script/test/delayed_commits.js
URL: http://svn.apache.org/viewvc/couchdb/branches/tail_header/share/www/script/test/delayed_commits.js?rev=775776&r1=775775&r2=775776&view=diff
==============================================================================
--- couchdb/branches/tail_header/share/www/script/test/delayed_commits.js (original)
+++ couchdb/branches/tail_header/share/www/script/test/delayed_commits.js Sun May 17 22:59:37 2009
@@ -18,7 +18,7 @@
// By default, couchdb doesn't fully commit documents to disk right away,
// it waits about a second to batch the full commit flush along with any
- // other updates. If it crashes or is restarted you may lose the most
+ // other updates. If os crashes you may lose the most
// recent commits.
T(db.save({_id:"1",a:2,b:4}).ok);
@@ -26,31 +26,26 @@
restartServer();
- T(db.open("1") == null); // lost the update.
- // note if we waited > 1 sec before the restart, the doc would likely
- // commit.
-
-
- // Retry the same thing but with full commits on.
+ T(db.open("1") != null);
var db2 = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"true"});
- T(db2.save({_id:"1",a:2,b:4}).ok);
- T(db2.open("1") != null);
+ T(db2.save({_id:"2",a:2,b:4}).ok);
+ T(db2.open("2") != null);
restartServer();
- T(db2.open("1") != null);
+ T(db2.open("2") != null);
// You can update but without committing immediately, and then ensure
// everything is commited in the last step.
- T(db.save({_id:"2",a:2,b:4}).ok);
- T(db.open("2") != null);
+ T(db.save({_id:"3",a:2,b:4}).ok);
+ T(db.open("3") != null);
T(db.ensureFullCommit().ok);
restartServer();
- T(db.open("2") != null);
+ T(db.open("3") != null);
// However, it's possible even when flushed, that the server crashed between
// the update and the commit, and you don't want to check to make sure
@@ -64,8 +59,8 @@
var instanceStartTime = db.info().instance_start_time;
- T(db.save({_id:"3",a:2,b:4}).ok);
- T(db.open("3") != null);
+ T(db.save({_id:"4",a:2,b:4}).ok);
+ T(db.open("4") != null);
restartServer();
@@ -73,14 +68,14 @@
T(commitResult.ok && commitResult.instance_start_time != instanceStartTime);
// start times don't match, meaning the server lost our change
- T(db.open("3") == null); // yup lost it
+ T(db.open("4") != null);
// retry with no server restart
var instanceStartTime = db.info().instance_start_time;
- T(db.save({_id:"4",a:2,b:4}).ok);
- T(db.open("4") != null);
+ T(db.save({_id:"5",a:2,b:4}).ok);
+ T(db.open("5") != null);
var commitResult = db.ensureFullCommit();
T(commitResult.ok && commitResult.instance_start_time == instanceStartTime);
@@ -88,11 +83,11 @@
restartServer();
- T(db.open("4") != null);
+ T(db.open("5") != null);
// Now test that when we exceed the max_dbs_open, pending commits are safely
// written.
- T(db.save({_id:"5",foo:"bar"}).ok);
+ T(db.save({_id:"6",foo:"bar"}).ok);
var max = 2;
run_on_modified_server(
[{section: "couchdb",
@@ -105,7 +100,7 @@
dbi.deleteDb();
dbi.createDb();
}
- T(db.open("5").foo=="bar");
+ T(db.open("6").foo=="bar");
for(var i=0; i<max+1; i++) {
var dbi = new CouchDB("test_suite_db" + i);
dbi.deleteDb();
Modified: couchdb/branches/tail_header/src/couchdb/couch_db.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/tail_header/src/couchdb/couch_db.erl?rev=775776&r1=775775&r2=775776&view=diff
==============================================================================
--- couchdb/branches/tail_header/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/tail_header/src/couchdb/couch_db.erl Sun May 17 22:59:37 2009
@@ -568,7 +568,7 @@
flush_binary(Fd, {OtherFd, StreamPointer, Len}) ->
{NewStreamData, Len} =
couch_stream:copy_to_new_stream(OtherFd, StreamPointer, Fd),
- {OtherFd, NewStreamData, Len};
+ {Fd, NewStreamData, Len};
flush_binary(Fd, Bin) when is_binary(Bin) ->
with_stream(Fd, fun(OutputStream) ->
@@ -577,7 +577,6 @@
flush_binary(Fd, {StreamFun, undefined}) when is_function(StreamFun) ->
with_stream(Fd, fun(OutputStream) ->
- io:format("OutputStream:~p~n", [OutputStream]),
% StreamFun(MaxChunkSize, WriterFun) must call WriterFun
% once for each chunk of the attachment,
StreamFun(4096,
Modified: couchdb/branches/tail_header/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/tail_header/src/couchdb/couch_db_updater.erl?rev=775776&r1=775775&r2=775776&view=diff
==============================================================================
--- couchdb/branches/tail_header/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/tail_header/src/couchdb/couch_db_updater.erl Sun May 17 22:59:37 2009
@@ -21,7 +21,6 @@
init({MainPid, DbName, Filepath, Fd, Options}) ->
- io:format("Init fd:~p~n", [Fd]),
case lists:member(create, Options) of
true ->
% create a new header and writes it to the file
Modified: couchdb/branches/tail_header/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/tail_header/src/couchdb/couch_file.erl?rev=775776&r1=775775&r2=775776&view=diff
==============================================================================
--- couchdb/branches/tail_header/src/couchdb/couch_file.erl (original)
+++ couchdb/branches/tail_header/src/couchdb/couch_file.erl Sun May 17 22:59:37 2009
@@ -248,10 +248,8 @@
BinSize = size(Bin),
case Pos rem ?SIZE_BLOCK of
0 ->
- io:format("Writing header at block:~p~n", [(Pos div ?SIZE_BLOCK)]),
Padding = <<>>;
BlockOffset ->
- io:format("Writing header at block:~p~n", [(Pos div ?SIZE_BLOCK) + 1]),
Padding = <<0:(8*(?SIZE_BLOCK-BlockOffset))>>
end,
FinalBin = [Padding, <<1, BinSize:32/integer>> | make_blocks(1, Bin)],
@@ -278,7 +276,6 @@
find_header(Fd, Block) ->
case (catch load_header(Fd, Block)) of
{ok, Bin} ->
- io:format("Found header at block:~p~n", [Block]),
{ok, Bin};
_Error ->
find_header(Fd, Block -1)
@@ -290,7 +287,6 @@
TotalBytes = calculate_total_read_len(1, HeaderLen),
{ok, <<RawBin:TotalBytes/binary>>} =
file:pread(Fd, (Block*?SIZE_BLOCK) + 5, TotalBytes),
- io:format("Foo:~p~n", [RawBin]),
<<Md5Sig:16/binary, HeaderBin/binary>> =
iolist_to_binary(remove_block_prefixes(1, RawBin)),
Md5Sig = erlang:md5(HeaderBin),