diff options
author | Damien F. Katz <damien@apache.org> | 2009-01-05 05:42:52 +0000 |
---|---|---|
committer | Damien F. Katz <damien@apache.org> | 2009-01-05 05:42:52 +0000 |
commit | 10eac24f530b5de1ea30c83518d3971f99890db6 (patch) | |
tree | f5565b0002ec028538c78b65febaddb675297596 /share/www | |
parent | 4228d249b4216d390aa1f8f063d09527c4dcbe6a (diff) |
Delayed commit patch. Allows documents to be saved immediately but fully committed asynchronously. On by default, to fully commit documents synchronously, use X-Couch-Full-Commit=true in the http header. We still needs to prevent committing view indexes ahead of data and to detect when a server has crashed causing potentially lost updates during remote replication (fixed by retrying the incremental replication).
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@731452 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/couch.js | 6 | ||||
-rw-r--r-- | share/www/script/couch_tests.js | 9 |
2 files changed, 14 insertions, 1 deletions
diff --git a/share/www/script/couch.js b/share/www/script/couch.js index 505d653f..e1806d6f 100644 --- a/share/www/script/couch.js +++ b/share/www/script/couch.js @@ -108,6 +108,12 @@ function CouchDB(name, httpHeaders) { } return result; } + + this.ensureFullCommit = function() { + this.last_req = this.request("POST", this.uri + "_ensure_full_commit"); + CouchDB.maybeThrowError(this.last_req); + return JSON.parse(this.last_req.responseText); + } // Applies the map function to the contents of database and returns the results. this.query = function(mapFun, reduceFun, options, keys) { diff --git a/share/www/script/couch_tests.js b/share/www/script/couch_tests.js index f553435e..dbc70325 100644 --- a/share/www/script/couch_tests.js +++ b/share/www/script/couch_tests.js @@ -130,7 +130,11 @@ var tests = { T(db.open(existingDoc._id, {rev: existingDoc._rev}) != null); // make sure restart works + T(db.ensureFullCommit().ok); restartServer(); + + // make sure we can still open + T(db.open(existingDoc._id, {rev: existingDoc._rev}) != null); }, all_docs: function(debug) { var db = new CouchDB("test_suite_db"); @@ -1173,6 +1177,7 @@ var tests = { } T(db.view("test/no_docs").total_rows == 0) T(db.view("test/single_doc").total_rows == 1) + T(db.ensureFullCommit().ok); restartServer(); }; @@ -1214,7 +1219,8 @@ var tests = { T(db.deleteDoc(designDoc).ok); T(db.open(designDoc._id) == null); T(db.view("test/no_docs") == null); - + + T(db.ensureFullCommit().ok); restartServer(); T(db.open(designDoc._id) == null); T(db.view("test/no_docs") == null); @@ -2327,6 +2333,7 @@ var tests = { // compaction isn't instantaneous, loop until done while (db.info().compact_running) {}; + T(db.ensureFullCommit().ok); restartServer(); var xhr = CouchDB.request("GET", "/test_suite_db/bin_doc/foo.txt"); T(xhr.responseText == "This is a base64 encoded text") |