summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorPaul Joseph Davis <davisp@apache.org>2009-11-26 02:10:06 +0000
committerPaul Joseph Davis <davisp@apache.org>2009-11-26 02:10:06 +0000
commitff623f039a9ab209768a33f03475e5ae54f09e21 (patch)
tree1557fc630ad3df928008c68b7ff7aa6bc9a62565 /src/couchdb
parenta320015ab1e34cefdeef9bd151197d80f87b932d (diff)
Refactored the fix for active_dbs timeouts.
I was getting a bit of weirdness with the old test version so I updated to be more straight forward in its testing. I've also updated the patch to couch_db_updater.erl to only to the db_updated call when a delayed commit changes the db because it was interacting badly with compaction. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@884369 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_db_updater.erl20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index 51a81efd..db5c43bc 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -208,7 +208,13 @@ handle_info({update_docs, Client, GroupedDocs, NonRepDocs, MergeConflicts,
{noreply, Db}
end;
handle_info(delayed_commit, Db) ->
- {noreply, commit_data(Db)}.
+ case commit_data(Db) of
+ Db ->
+ {noreply, Db};
+ Db2 ->
+ ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
+ {noreply, Db2}
+ end.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
@@ -656,10 +662,8 @@ commit_data(#db{fd=Fd,header=OldHeader,fsync_options=FsyncOptions}=Db, Delay) ->
if OldHeader == Header ->
Db;
Delay and (Db#db.waiting_delayed_commit == nil) ->
- Db2 = Db#db{waiting_delayed_commit=
- erlang:send_after(1000, self(), delayed_commit)},
- ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
- Db2;
+ Db#db{waiting_delayed_commit=
+ erlang:send_after(1000, self(), delayed_commit)};
Delay ->
Db;
true ->
@@ -682,11 +686,9 @@ commit_data(#db{fd=Fd,header=OldHeader,fsync_options=FsyncOptions}=Db, Delay) ->
_ -> ok
end,
- Db2 = Db#db{waiting_delayed_commit=nil,
+ Db#db{waiting_delayed_commit=nil,
header=Header,
- committed_update_seq=Db#db.update_seq},
- ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
- Db2
+ committed_update_seq=Db#db.update_seq}
end.