summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2009-08-15 01:55:32 +0000
committerAdam Kocoloski <kocolosk@apache.org>2009-08-15 01:55:32 +0000
commitbff8b7d9751fad8319124fbfa238446170885b21 (patch)
tree0e0883ab715ddda6a132eb247240a7d9f0a0f370 /src/couchdb
parent3180e5aa8541d7969c95296607989c88056b598e (diff)
delayed commits are now a config option, off by default. Closes COUCHDB-449
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@804427 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_db.erl20
-rw-r--r--src/couchdb/couch_httpd_db.erl8
2 files changed, 25 insertions, 3 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl
index aff5b743..7118145d 100644
--- a/src/couchdb/couch_db.erl
+++ b/src/couchdb/couch_db.erl
@@ -567,9 +567,27 @@ make_first_doc_on_disk(Db, Id, Pos, [{_Rev, {IsDel, Sp, _Seq}} |_]=DocPath) ->
Revs = [Rev || {Rev, _} <- DocPath],
make_doc(Db, Id, IsDel, Sp, {Pos, Revs}).
+set_commit_option(Options) ->
+ CommitSettings = {
+ [true || O <- Options, O==full_commit orelse O==delay_commit],
+ couch_config:get("couchdb", "delayed_commits", "false")
+ },
+ case CommitSettings of
+ {[true], _} ->
+ Options; % user requested explicit commit setting, do not change it
+ {_, "true"} ->
+ Options; % delayed commits are enabled, do nothing
+ {_, "false"} ->
+ [full_commit|Options];
+ {_, Else} ->
+ ?LOG_ERROR("[couchdb] delayed_commits setting must be true/false, not ~p",
+ [Else]),
+ [full_commit|Options]
+ end.
write_and_commit(#db{update_pid=UpdatePid, user_ctx=Ctx}=Db, DocBuckets,
- NonRepDocs, Options) ->
+ NonRepDocs, Options0) ->
+ Options = set_commit_option(Options0),
case gen_server:call(UpdatePid,
{update_docs, DocBuckets, NonRepDocs, Options}, infinity) of
{ok, Results} -> {ok, Results};
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 55429cef..915a5eae 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -313,9 +313,11 @@ db_req(#httpd{method='POST',path_parts=[_,<<"_bulk_docs">>]}=Req, Db) ->
couch_stats_collector:increment({httpd, bulk_requests}),
{JsonProps} = couch_httpd:json_body_obj(Req),
DocsArray = proplists:get_value(<<"docs">>, JsonProps),
- case couch_httpd:header_value(Req, "X-Couch-Full-Commit", "false") of
+ case couch_httpd:header_value(Req, "X-Couch-Full-Commit") of
"true" ->
Options = [full_commit];
+ "false" ->
+ Options = [delay_commit];
_ ->
Options = []
end,
@@ -770,9 +772,11 @@ update_doc(Req, Db, DocId, Json) ->
update_doc(Req, Db, DocId, Json, Headers) ->
#doc{deleted=Deleted} = Doc = couch_doc_from_req(Req, DocId, Json),
- case couch_httpd:header_value(Req, "X-Couch-Full-Commit", "false") of
+ case couch_httpd:header_value(Req, "X-Couch-Full-Commit") of
"true" ->
Options = [full_commit];
+ "false" ->
+ Options = [delay_commit];
_ ->
Options = []
end,