Return-Path: Delivered-To: apmail-incubator-couchdb-commits-archive@locus.apache.org Received: (qmail 40313 invoked from network); 25 Jul 2008 20:12:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Jul 2008 20:12:46 -0000 Received: (qmail 66343 invoked by uid 500); 25 Jul 2008 20:12:45 -0000 Delivered-To: apmail-incubator-couchdb-commits-archive@incubator.apache.org Received: (qmail 66312 invoked by uid 500); 25 Jul 2008 20:12:45 -0000 Mailing-List: contact couchdb-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-commits@incubator.apache.org Received: (qmail 66303 invoked by uid 99); 25 Jul 2008 20:12:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2008 13:12:45 -0700 X-ASF-Spam-Status: No, hits=-1998.5 required=10.0 tests=ALL_TRUSTED,WEIRD_PORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jul 2008 20:11:48 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A67F3238889B; Fri, 25 Jul 2008 13:11:43 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r679891 - in /incubator/couchdb/branches/0.8.x: ./ bin/ share/www/script/ src/couchdb/ src/mochiweb/ Date: Fri, 25 Jul 2008 20:11:42 -0000 To: couchdb-commits@incubator.apache.org From: cmlenz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080725201143.A67F3238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cmlenz Date: Fri Jul 25 13:11:42 2008 New Revision: 679891 URL: http://svn.apache.org/viewvc?rev=679891&view=rev Log: Merged revisions 673634-673777,673779-674333,674335-675698,675700-677086,677088-679850 via svnmerge from https://svn.apache.org/repos/asf/incubator/couchdb/trunk ........ r673634 | jan | 2008-07-03 11:19:40 +0200 (Do, 03 Jul 2008) | 7 lines Improve error message. If the couch_erl_driver.so is no good for some reason (linking e.g.) you get something along the lines of {"init terminating in do_boot","Driver is an inappropriate Mach-O file"} instead of {"init terminating in do_boot",{error,{open_error,-12}}} Patch by Dale Johnson ........ r675780 | jan | 2008-07-11 00:07:10 +0200 (Fr, 11 Jul 2008) | 1 line Wait for the OS to flush our newly written data to disk without timing out too quickly. ........ r677373 | jan | 2008-07-16 20:39:03 +0200 (Mi, 16 Jul 2008) | 1 line Increase more filesystem layer timeouts. Patch by randall leeds gmail ........ r677426 | damien | 2008-07-16 22:55:14 +0200 (Mi, 16 Jul 2008) | 1 line Fixed replication problems where read ad write queues can get backed up. With this fixed, throughput might be reduced. ........ r677682 | jan | 2008-07-17 20:52:46 +0200 (Do, 17 Jul 2008) | 1 line Allow for empty attachments. ........ r677892 | damien | 2008-07-18 14:57:07 +0200 (Fr, 18 Jul 2008) | 1 line Fix for problem when saving bulk documents with invalid ids ........ r678743 | nslater | 2008-07-22 14:50:10 +0200 (Di, 22 Jul 2008) | 1 line added OpenSSL dependancy to README ........ r678923 | damien | 2008-07-23 00:04:58 +0200 (Mi, 23 Jul 2008) | 1 line Fix for compacted databases reporting 0 documents after compaction ........ r679636 | damien | 2008-07-25 02:35:11 +0200 (Fr, 25 Jul 2008) | 1 line Fix for problem with Safari and mochiweb. ........ r679821 | nslater | 2008-07-25 16:54:32 +0200 (Fr, 25 Jul 2008) | 1 line couchdb script no longer uses awk for configuration checks ........ r679823 | nslater | 2008-07-25 16:55:22 +0200 (Fr, 25 Jul 2008) | 1 line removed awk subst from automake ........ r679840 | cmlenz | 2008-07-25 17:49:36 +0200 (Fr, 25 Jul 2008) | 1 line Use a method compatible with Erlang R11B to put the Erlang OTP version in the HTTP Server response header. ........ r679843 | cmlenz | 2008-07-25 17:57:20 +0200 (Fr, 25 Jul 2008) | 1 line Fix to previous commit r679840. ........ r679846 | cmlenz | 2008-07-25 18:05:01 +0200 (Fr, 25 Jul 2008) | 1 line Apply patch by Yoan Blanc to fix the view selector in Futon for Opera and IE. Closes COUCHDB-81. ........ r679850 | cmlenz | 2008-07-25 18:13:43 +0200 (Fr, 25 Jul 2008) | 1 line Update NEWS and CHANGES for 0.8.1 release. ........ Modified: incubator/couchdb/branches/0.8.x/ (props changed) incubator/couchdb/branches/0.8.x/CHANGES incubator/couchdb/branches/0.8.x/NEWS incubator/couchdb/branches/0.8.x/README incubator/couchdb/branches/0.8.x/THANKS incubator/couchdb/branches/0.8.x/bin/Makefile.am incubator/couchdb/branches/0.8.x/bin/couchdb.tpl.in incubator/couchdb/branches/0.8.x/share/www/script/browse.js incubator/couchdb/branches/0.8.x/share/www/script/couch_tests.js incubator/couchdb/branches/0.8.x/src/couchdb/couch_db.erl incubator/couchdb/branches/0.8.x/src/couchdb/couch_doc.erl incubator/couchdb/branches/0.8.x/src/couchdb/couch_file.erl incubator/couchdb/branches/0.8.x/src/couchdb/couch_httpd.erl incubator/couchdb/branches/0.8.x/src/couchdb/couch_rep.erl incubator/couchdb/branches/0.8.x/src/couchdb/couch_util.erl incubator/couchdb/branches/0.8.x/src/mochiweb/mochiweb_response.erl Propchange: incubator/couchdb/branches/0.8.x/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Jul 25 13:11:42 2008 @@ -1 +1 @@ -/incubator/couchdb/trunk:1-668227,668231-668248,668269-670737,670739-671610 +/incubator/couchdb/trunk:1-668227,668231-668248,668269-670737,670739-671610,673634-673777,673779-674333,674335-675698,675700-677086,677088-679850 Modified: incubator/couchdb/branches/0.8.x/CHANGES URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/CHANGES?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/CHANGES (original) +++ incubator/couchdb/branches/0.8.x/CHANGES Fri Jul 25 13:11:42 2008 @@ -1,6 +1,47 @@ Apache CouchDB CHANGES ====================== +Version 0.8.1-incubating +------------------------ + +Database Core: + + * Fix for replication problems where the write queues can get backed up if the + writes aren't happening fast enough to keep up with the reads. For a large + replication, this can exhaust memory and crash, or slow down the machine + dramatically. The fix keeps only one document in the write queue at a time. + * Fix for databases sometimes incorrectly reporting that they contain 0 + documents after compaction. + +HTTP Interface: + + * Fix for chunked responses where chunks were always being split into multiple + TCP packets, which caused problems with the test suite under Safari, and in + some other cases. + * Fix for an invalid JSON response body being returned for some kinds of + views. (COUCHDB-84) + * Fix for connections not getting closed after rejecting a chunked request. + (COUCHDB-55) + * CouchDB can now be bound to IPv6 addresses. + * The HTTP Server header now contains the versions of CouchDB and Erlang. + +Javascript View Server: + + * Fix for sealing of nested data structure in documents in the Javascript view + server. + * Improve error handling for undefined values emitted by map functions. + (COUCHDB-83) + +Packaging and System Integration: + + * The `couchdb` script no longer uses `awk` for configuration checks as this + was causing portability problems. + +Futon Utility Client: + + * The view selector dropdown should now work in Opera and Internet Explorer + even when it includes optgroups for design documents. (COUCHDB-81) + Version 0.8.0-incubating ------------------------ Modified: incubator/couchdb/branches/0.8.x/NEWS URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/NEWS?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/NEWS (original) +++ incubator/couchdb/branches/0.8.x/NEWS Fri Jul 25 13:11:42 2008 @@ -5,6 +5,12 @@ http://wiki.apache.org/couchdb/BreakingChanges +Version 0.8.1-incubating +------------------------ + + * Various bug fixes for replication, compaction, the HTTP interface and the + Javascript View Server. + Version 0.8.0-incubating ------------------------ Modified: incubator/couchdb/branches/0.8.x/README URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/README?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/README (original) +++ incubator/couchdb/branches/0.8.x/README Fri Jul 25 13:11:42 2008 @@ -53,9 +53,10 @@ * [Erlang OTP][07] (>=R11B) (required) * [ICU][08] (required) - * [Mozilla SpiderMonkey][09] (required) - * [GNU Make][10] (required) - * [GNU Compiler Collection][11] (required) + * [OpenSSL][09] (required) + * [Mozilla SpiderMonkey][10] (required) + * [GNU Make][11] (required) + * [GNU Compiler Collection][12] (required) ### UNIX-like Operating Systems (inc. OS X) ### @@ -140,7 +141,7 @@ OS X provides the standard Accounts option from the System Preferences application or you can optionally use the Workgroup Manager application which -can be downloaded as part of the [Server Admin Tools][12]. +can be downloaded as part of the [Server Admin Tools][13]. You should make sure that the `couchdb` user has a working POSIX shell and set the home directory to `/usr/local/var/lib/couchdb` which is the Apache CouchDB @@ -167,7 +168,7 @@ Relax. To check that everything has worked point your web browser to -[http://localhost:5984/_utils/index.html][13] and run the test suite. +[http://localhost:5984/_utils/index.html][14] and run the test suite. ##### OS X ##### @@ -250,8 +251,9 @@ [06]: http://incubator.apache.org/couchdb/community/code.html [07]: http://erlang.org/ [08]: http://icu.sourceforge.net/ -[09]: http://www.mozilla.org/js/spidermonkey/ -[10]: http://www.gnu.org/software/make/ -[11]: http://gcc.gnu.org/ -[12]: http://www.apple.com/support/downloads/serveradmintools1047.html -[13]: http://localhost:5984/_utils/index.html +[09]: http://www.openssl.org/ +[10]: http://www.mozilla.org/js/spidermonkey/ +[11]: http://www.gnu.org/software/make/ +[12]: http://gcc.gnu.org/ +[13]: http://www.apple.com/support/downloads/serveradmintools1047.html +[14]: http://localhost:5984/_utils/index.html Modified: incubator/couchdb/branches/0.8.x/THANKS URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/THANKS?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/THANKS (original) +++ incubator/couchdb/branches/0.8.x/THANKS Fri Jul 25 13:11:42 2008 @@ -8,6 +8,7 @@ * Chris Anderson * William Beh + * Yoan Blanc * Benoit Chesneau * Paul Joseph Davis * Till Klampaeckel Modified: incubator/couchdb/branches/0.8.x/bin/Makefile.am URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/bin/Makefile.am?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/bin/Makefile.am (original) +++ incubator/couchdb/branches/0.8.x/bin/Makefile.am Fri Jul 25 13:11:42 2008 @@ -25,7 +25,6 @@ couchdb: couchdb.tpl sed -e "s|%ERL%|$(ERL)|g" \ -e "s|%ICU_CONFIG%|$(ICU_CONFIG)|g" \ - -e "s|%AWK%|$(AWK)|g" \ -e "s|%bindir%|@bindir@|g" \ -e "s|%localerlangbindir%|@localerlangbindir@|g" \ -e "s|%localerlanglibdir%|@localerlanglibdir@|g" \ Modified: incubator/couchdb/branches/0.8.x/bin/couchdb.tpl.in URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/bin/couchdb.tpl.in?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/bin/couchdb.tpl.in (original) +++ incubator/couchdb/branches/0.8.x/bin/couchdb.tpl.in Fri Jul 25 13:11:42 2008 @@ -96,17 +96,6 @@ exit $SCRIPT_ERROR } -_load_configuration () { - dbrootdir_ini_value=`%AWK% -F = "/^DbRootDir=/{print \\$2}" < $INI_FILE` - if test -n "$dbrootdir_ini_value"; then - LIB_DIRECTORY=$dbrootdir_ini_value - fi - logfile_ini_value=`%AWK% -F = "/^LogFile=/{print \\$2}" < $INI_FILE` - if test -n "$logfile_ini_value"; then - LOG_DIRECTORY=`dirname $logfile_ini_value` - fi -} - _get_pid () { if test -f $PID_FILE; then PID=`cat $PID_FILE` @@ -132,59 +121,37 @@ } check_environment () { + if test "$BACKGROUND_BOOLEAN" != "true"; then + return + fi + touch $PID_FILE 2> /dev/null || true + touch $STDOUT_FILE 2> /dev/null || true + touch $STDERR_FILE 2> /dev/null || true message_prefix="Apache CouchDB needs write permission on the" - if test ! -w $LIB_DIRECTORY; then - echo "$message_prefix data directory: $LIB_DIRECTORY" >&2 + if test ! -w $PID_FILE; then + echo "$message_prefix PID file: $PID_FILE" >&2 exit $SCRIPT_ERROR fi - if test ! -w $LOG_DIRECTORY; then - echo "$message_prefix log directory: $LOG_DIRECTORY" >&2 + if test ! -w $STDOUT_FILE; then + echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2 exit $SCRIPT_ERROR fi - message_prefix="Apache CouchDB needs write permission on data file" - for file in `find $LIB_DIRECTORY -type f`; do - if test ! -w $file; then - echo "$message_prefix: $file" >&2 - exit $SCRIPT_ERROR - fi - done - message_prefix="Apache CouchDB needs write permission on log file" - for file in `find $LOG_DIRECTORY -type f`; do - if test ! -w $file; then - echo "$message_prefix: $file" >&2 - exit $SCRIPT_ERROR - fi - done - if test "$BACKGROUND_BOOLEAN" = "true"; then - touch $PID_FILE 2> /dev/null || true - touch $STDOUT_FILE 2> /dev/null || true - touch $STDERR_FILE 2> /dev/null || true - message_prefix="Apache CouchDB needs write permission on the" - if test ! -w $PID_FILE; then - echo "$message_prefix PID file: $PID_FILE" >&2 - exit $SCRIPT_ERROR - fi - if test ! -w $STDOUT_FILE; then - echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2 - exit $SCRIPT_ERROR - fi - if test ! -w $STDERR_FILE; then - echo "$message_prefix STDERR file: $STDERR_FILE" >&2 - exit $SCRIPT_ERROR - fi - message_prefix="Apache CouchDB needs a regular" - if ! echo 2> /dev/null >> $PID_FILE; then - echo "$message_prefix PID file: $PID_FILE" >&2 - exit $SCRIPT_ERROR - fi - if ! echo 2> /dev/null >> $STDOUT_FILE; then - echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2 - exit $SCRIPT_ERROR - fi - if ! echo 2> /dev/null >> $STDERR_FILE; then - echo "$message_prefix STDERR file: $STDERR_FILE" >&2 - exit $SCRIPT_ERROR - fi + if test ! -w $STDERR_FILE; then + echo "$message_prefix STDERR file: $STDERR_FILE" >&2 + exit $SCRIPT_ERROR + fi + message_prefix="Apache CouchDB needs a regular" + if ! echo 2> /dev/null >> $PID_FILE; then + echo "$message_prefix PID file: $PID_FILE" >&2 + exit $SCRIPT_ERROR + fi + if ! echo 2> /dev/null >> $STDOUT_FILE; then + echo "$message_prefix STDOUT file: $STDOUT_FILE" >&2 + exit $SCRIPT_ERROR + fi + if ! echo 2> /dev/null >> $STDERR_FILE; then + echo "$message_prefix STDERR file: $STDERR_FILE" >&2 + exit $SCRIPT_ERROR fi } @@ -307,7 +274,6 @@ *) display_error "Unknown option: $1" >&2;; esac done - _load_configuration if test "$KILL_BOOLEAN" = "true" -o "$SHUTDOWN_BOOLEAN" = "true"; then stop_couchdb $KILL_BOOLEAN else Modified: incubator/couchdb/branches/0.8.x/share/www/script/browse.js URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/share/www/script/browse.js?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/share/www/script/browse.js [utf-8] (original) +++ incubator/couchdb/branches/0.8.x/share/www/script/browse.js [utf-8] Fri Jul 25 13:11:42 2008 @@ -178,9 +178,12 @@ db.openDoc(resp.rows[i].id, { success: function(doc) { var optGroup = $("").attr("label", doc._id.substr(8)); + var optGroup = $(document.createElement("optgroup")) + .attr("label", doc._id.substr(8)); for (var name in doc.views) { if (!doc.views.hasOwnProperty(name)) continue; - var option = $("").attr("value", doc._id + "/" + name).text(name) + var option = $(document.createElement("option")) + .attr("value", doc._id + "/" + name).text(name) .appendTo(optGroup); if (doc._id + "/" + name == viewName) { option[0].selected = true; Modified: incubator/couchdb/branches/0.8.x/share/www/script/couch_tests.js URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/share/www/script/couch_tests.js?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/share/www/script/couch_tests.js [utf-8] (original) +++ incubator/couchdb/branches/0.8.x/share/www/script/couch_tests.js [utf-8] Fri Jul 25 13:11:42 2008 @@ -556,8 +556,32 @@ T(db.save(binAttDoc).ok); var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt"); - T(xhr.responseText == "This is a base64 encoded text") - T(xhr.getResponseHeader("Content-Type") == "text/plain") + T(xhr.responseText == "This is a base64 encoded text"); + T(xhr.getResponseHeader("Content-Type") == "text/plain"); + + // empty attachments + var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt", { + headers:{"Content-Type":"text/plain;charset=utf-8"}, + body:"" + }); + T(xhr.status == 201); + var rev = JSON.parse(xhr.responseText).rev; + + var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt"); + T(xhr.status == 200); + T(xhr.responseText.length == 0); + + // overwrite previsously empty attachment + var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc4/attachment.txt?rev=" + rev, { + headers:{"Content-Type":"text/plain;charset=utf-8"}, + body:"This is a string" + }); + T(xhr.status == 201); + + var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc4/attachment.txt"); + T(xhr.status == 200); + T(xhr.responseText == "This is a string"); + }, content_negotiation: function(debug) { @@ -1179,14 +1203,13 @@ T(xhr.status == 202); // compaction isn't instantaneous, loop until done while (db.info().compact_running) {}; - + + restartServer(); var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt"); T(xhr.responseText == "This is a base64 encoded text") T(xhr.getResponseHeader("Content-Type") == "text/plain") - - var compactedsize = db.info().disk_size; - - T(compactedsize < deletesize); + T(db.info().doc_count == 1); + T(db.info().disk_size < deletesize); } }; Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_db.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_db.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_db.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_db.erl Fri Jul 25 13:11:42 2008 @@ -298,13 +298,13 @@ % flush unwritten binaries to disk. DocBuckets3 = [[doc_flush_binaries(Doc, Db#db.fd) || Doc <- Bucket] || Bucket <- DocBuckets2], - case gen_server:call(MainPid, {update_docs, DocBuckets3, [new_edits | Options]}) of + case gen_server:call(MainPid, {update_docs, DocBuckets3, [new_edits | Options]}, infinity) of ok -> {ok, NewRevs}; retry -> Db2 = get_db(MainPid), DocBuckets4 = [[doc_flush_binaries(Doc, Db2#db.fd) || Doc <- Bucket] || Bucket <- DocBuckets3], % We only retry once - case gen_server:call(MainPid, {update_docs, DocBuckets4, [new_edits | Options]}) of + case gen_server:call(MainPid, {update_docs, DocBuckets4, [new_edits | Options]}, infinity) of ok -> {ok, NewRevs}; Else -> throw(Else) end; @@ -320,7 +320,7 @@ Db = get_db(MainPid), DocBuckets = group_alike_docs(Docs), DocBuckets2 = [[doc_flush_binaries(Doc, Db#db.fd) || Doc <- Bucket] || Bucket <- DocBuckets], - ok = gen_server:call(MainPid, {update_docs, DocBuckets2, Options}). + ok = gen_server:call(MainPid, {update_docs, DocBuckets2, Options}, infinity). doc_flush_binaries(Doc, Fd) -> @@ -367,7 +367,7 @@ end, {{0,0}, 0}), {Fd, NewStreamPointer, Len}; - Bin when is_binary(Bin), size(Bin) > 0 -> + Bin when is_binary(Bin) -> {ok, StreamPointer} = couch_stream:write(OutputStream, Bin), {Fd, StreamPointer, size(Bin)} end, @@ -568,16 +568,17 @@ init_db(Name, CompactFilepath, NewFd, NewHeader), case Db#db.update_seq == NewSeq of true -> + NewDb2 = commit_data( + NewDb#db{ + main_pid = Db#db.main_pid, + doc_count = Db#db.doc_count, + doc_del_count = Db#db.doc_del_count, + filepath = Filepath}), + ?LOG_DEBUG("CouchDB swapping files ~s and ~s.", [Filepath, CompactFilepath]), ok = file:rename(Filepath, Filepath ++ ".old"), ok = file:rename(CompactFilepath, Filepath), - NewDb2 = NewDb#db{ - main_pid = Db#db.main_pid, - doc_count = Db#db.doc_count, - doc_del_count = Db#db.doc_del_count, - filepath = Filepath}, - couch_stream:close(Db#db.summary_stream), % close file handle async. % wait 5 secs before closing, allowing readers to finish Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_doc.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_doc.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_doc.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_doc.erl Fri Jul 25 13:11:42 2008 @@ -110,13 +110,18 @@ Revs0 -> Revs0 end, - #doc{ - id = proplists:get_value("_id", Props, ""), - revs = Revs, - deleted = proplists:get_value("_deleted", Props, false), - body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]}, - attachments = Bins - }. + case proplists:get_value("_id", Props, "") of + Id when is_list(Id) -> + #doc{ + id = Id, + revs = Revs, + deleted = proplists:get_value("_deleted", Props, false), + body = {obj, [{Key, Value} || {[FirstChar|_]=Key, Value} <- Props, FirstChar /= $_]}, + attachments = Bins + }; + _ -> + throw({invalid_document_id, "Document id is not a string"}) + end. to_doc_info(#full_doc_info{id=Id,update_seq=Seq,rev_tree=Tree}) -> Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_file.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_file.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_file.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_file.erl Fri Jul 25 13:11:42 2008 @@ -105,7 +105,7 @@ %%---------------------------------------------------------------------- append_binary(Fd, Bin) -> - gen_server:call(Fd, {append_bin, Bin}). + gen_server:call(Fd, {append_bin, Bin}, infinity). %%---------------------------------------------------------------------- @@ -127,7 +127,7 @@ %%---------------------------------------------------------------------- pread_binary(Fd, Pos) -> - gen_server:call(Fd, {pread_bin, Pos}). + gen_server:call(Fd, {pread_bin, Pos}, infinity). %%---------------------------------------------------------------------- @@ -156,7 +156,7 @@ %%---------------------------------------------------------------------- sync(Fd) -> - gen_server:call(Fd, sync). + gen_server:call(Fd, sync, infinity). %%---------------------------------------------------------------------- %% Purpose: Close the file. Is performed asynchronously. Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_httpd.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_httpd.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_httpd.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_httpd.erl Fri Jul 25 13:11:42 2008 @@ -959,5 +959,6 @@ end. server_header() -> + OTPVersion = "R" ++ integer_to_list(erlang:system_info(compat_rel)) ++ "B", [{"Server", "CouchDB/" ++ couch_server:get_version() ++ - " (Erlang OTP/" ++ erlang:system_info(otp_release) ++ ")"}]. + " (Erlang OTP/" ++ OTPVersion ++ ")"}]. Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_rep.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_rep.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_rep.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_rep.erl Fri Jul 25 13:11:42 2008 @@ -113,13 +113,15 @@ end. pull_rep(DbTarget, DbSource, SourceSeqNum) -> - Parent = self(), SaveDocsPid = spawn_link(fun() -> - save_docs_loop(Parent, DbTarget, 0) end), + save_docs_loop(DbTarget, 0) end), OpenDocsPid = spawn_link(fun() -> - open_doc_revs_loop(Parent, DbSource, SaveDocsPid, 0) end), + open_doc_revs_loop(DbSource, SaveDocsPid, 0) end), + OpenDocsPid ! got_it, % prime queue with got_it MissingRevsPid = spawn_link(fun() -> - get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, 0, 0) end), + get_missing_revs_loop(DbTarget, OpenDocsPid, 0, 0) end), + MissingRevsPid ! got_it, % prime queue with got_it + self() ! got_it, {ok, NewSeq} = enum_docs_since(DbSource, SourceSeqNum, fun(SrcDocInfo, _, _) -> #doc_info{id=Id, @@ -128,73 +130,73 @@ deleted_conflict_revs=DelConflicts, update_seq=Seq} = SrcDocInfo, SrcRevs = [Rev | Conflicts] ++ DelConflicts, - MissingRevsPid ! {Id, SrcRevs}, % send to the missing revs process + receive got_it -> ok end, + MissingRevsPid ! {self(), Id, SrcRevs}, % send to the missing revs process {ok, Seq} end, SourceSeqNum), - MissingRevsPid ! shutdown, + + receive got_it -> ok end, + + MissingRevsPid ! {self(), shutdown}, receive {done, MissingRevsPid, Stats1} -> ok end, - OpenDocsPid ! shutdown, + OpenDocsPid ! {self(), shutdown}, receive {done, OpenDocsPid, Stats2} -> ok end, - SaveDocsPid ! shutdown, + SaveDocsPid ! {self(), shutdown}, receive {done, SaveDocsPid, Stats3} -> ok end, {NewSeq, Stats1 ++ Stats2 ++ Stats3}. -receive_id_revs() -> - receive - {Id, Revs} -> - [{Id, Revs} | receive_id_revs()] - after 1 -> - [] - end. - -get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, RevsChecked, MissingFound) -> +get_missing_revs_loop(DbTarget, OpenDocsPid, RevsChecked, MissingFound) -> + receive got_it -> ok end, receive - {Id, Revs} -> - Changed = [{Id, Revs} | receive_id_revs()], - {ok, Missing} = get_missing_revs(DbTarget, Changed), - [OpenDocsPid ! {Id0, MissingRevs} || {Id0, MissingRevs} <- Missing], - get_missing_revs_loop(Parent, DbTarget, OpenDocsPid, - RevsChecked + length(Changed), - MissingFound + length(Missing)); - shutdown -> - Parent ! {done, self(), [{"missing_checked", RevsChecked}, + {Src, Id, Revs} -> + Src ! got_it, + MissingRevs = + case get_missing_revs(DbTarget, [{Id, Revs}]) of + {ok, [{Id, MissingRevs0}]} -> + OpenDocsPid ! {self(), Id, MissingRevs0}, + MissingRevs0; + {ok, []} -> + % prime our message queue + self() ! got_it, + [] + end, + get_missing_revs_loop(DbTarget, OpenDocsPid, + RevsChecked + length(Revs), + MissingFound + length(MissingRevs)); + {Src, shutdown} -> + Src ! {done, self(), [{"missing_checked", RevsChecked}, {"missing_found", MissingFound}]} end. -open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead) -> +open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead) -> + receive got_it -> ok end, receive - {Id, MissingRevs} -> + {Src, Id, MissingRevs} -> + Src ! got_it, {ok, DocResults} = open_doc_revs(DbSource, Id, MissingRevs, [latest]), % only save successful reads Docs = [RevDoc || {ok, RevDoc} <- DocResults], - SaveDocsPid ! Docs, - open_doc_revs_loop(Parent, DbSource, SaveDocsPid, DocsRead + length(Docs)); - shutdown -> - Parent ! {done, self(), [{"docs_read", DocsRead}]} + SaveDocsPid ! {self(), docs, Docs}, + open_doc_revs_loop(DbSource, SaveDocsPid, DocsRead + length(Docs)); + {Src, shutdown} -> + Src ! {done, self(), [{"docs_read", DocsRead}]} end. -receive_docs() -> - receive - Docs when is_list(Docs) -> - Docs ++ receive_docs() - after 1 -> - [] - end. -save_docs_loop(Parent, DbTarget, DocsWritten) -> +save_docs_loop(DbTarget, DocsWritten) -> receive - Docs0 when is_list(Docs0) -> - Docs = Docs0 ++ receive_docs(), + {Src, docs, Docs} -> + Src ! got_it, ok = save_docs(DbTarget, Docs, []), - save_docs_loop(Parent, DbTarget, DocsWritten + length(Docs)); - shutdown -> - Parent ! {done, self(), [{"docs_written", DocsWritten}]} + save_docs_loop(DbTarget, DocsWritten + length(Docs)); + {Src, shutdown} -> + Src ! {done, self(), [{"docs_written", DocsWritten}]} end. @@ -239,7 +241,7 @@ enum_docs_since(DbUrl, StartSeq, InFun, InAcc) when is_list(DbUrl) -> - Url = DbUrl ++ "_all_docs_by_seq?startkey=" ++ integer_to_list(StartSeq), + Url = DbUrl ++ "_all_docs_by_seq?count=100&startkey=" ++ integer_to_list(StartSeq), {obj, Results} = do_http_request(Url, get), DocInfoList= lists:map(fun({obj, RowInfoList}) -> @@ -254,7 +256,14 @@ tuple_to_list(proplists:get_value("deleted_conflicts", RowValueProps, {})), deleted = proplists:get_value("deleted", RowValueProps, false)} end, tuple_to_list(proplists:get_value("rows", Results))), - {ok, enum_docs0(InFun, DocInfoList, InAcc)}; + case DocInfoList of + [] -> + {ok, InAcc}; + _ -> + Acc2 = enum_docs0(InFun, DocInfoList, InAcc), + #doc_info{update_seq=LastSeq} = lists:last(DocInfoList), + enum_docs_since(DbUrl, LastSeq, InFun, Acc2) + end; enum_docs_since(DbSource, StartSeq, Fun, Acc) -> couch_db:enum_docs_since(DbSource, StartSeq, Fun, Acc). Modified: incubator/couchdb/branches/0.8.x/src/couchdb/couch_util.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/couchdb/couch_util.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/couchdb/couch_util.erl (original) +++ incubator/couchdb/branches/0.8.x/src/couchdb/couch_util.erl Fri Jul 25 13:11:42 2008 @@ -28,7 +28,7 @@ case erl_ddll:load_driver(LibDir, "couch_erl_driver") of ok -> ok; {error, already_loaded} -> ok; - Error -> exit(Error) + {error, Error} -> exit(erl_ddll:format_error(Error)) end. Modified: incubator/couchdb/branches/0.8.x/src/mochiweb/mochiweb_response.erl URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/0.8.x/src/mochiweb/mochiweb_response.erl?rev=679891&r1=679890&r2=679891&view=diff ============================================================================== --- incubator/couchdb/branches/0.8.x/src/mochiweb/mochiweb_response.erl (original) +++ incubator/couchdb/branches/0.8.x/src/mochiweb/mochiweb_response.erl Fri Jul 25 13:11:42 2008 @@ -50,8 +50,7 @@ case Request:get(version) of Version when Version >= {1, 1} -> Length = iolist_size(Data), - send(io_lib:format("~.16b\r\n", [Length])), - send([Data, <<"\r\n">>]); + send([io_lib:format("~.16b\r\n", [Length]), Data, <<"\r\n">>]); _ -> send(Data) end.