From ff623f039a9ab209768a33f03475e5ae54f09e21 Mon Sep 17 00:00:00 2001 From: Paul Joseph Davis Date: Thu, 26 Nov 2009 02:10:06 +0000 Subject: 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 --- src/couchdb/couch_db_updater.erl | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') 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. -- cgit v1.2.3