diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2010-11-18 00:11:18 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2010-11-18 00:11:18 +0000 |
commit | 5e05bcd220251d4b1c4e826156c50efb9e22ee12 (patch) | |
tree | 150e07ab5d3548aa11bb4f538820afaead83f75e /src/couchdb/couch_db.erl | |
parent | c9b4d1a56a52aef712b7e71c9ea2a727631c1a4e (diff) |
Make sure that after a database compaction the old database reference counters don't get unreleased forever.
Closes COUCHDB-926.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@1036294 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_db.erl')
-rw-r--r-- | src/couchdb/couch_db.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/couchdb/couch_db.erl b/src/couchdb/couch_db.erl index 7d8d195f..c8a93c26 100644 --- a/src/couchdb/couch_db.erl +++ b/src/couchdb/couch_db.erl @@ -27,6 +27,7 @@ -export([init/1,terminate/2,handle_call/3,handle_cast/2,code_change/3,handle_info/2]). -export([changes_since/5,changes_since/6,read_doc/2,new_revid/1]). -export([check_is_admin/1, check_is_reader/1]). +-export([reopen/1]). -include("couch_db.hrl"). @@ -86,6 +87,18 @@ open(DbName, Options) -> Else -> Else end. +reopen(#db{main_pid = Pid, fd_ref_counter = OldRefCntr}) -> + {ok, #db{fd_ref_counter = NewRefCntr} = NewDb} = + gen_server:call(Pid, get_db, infinity), + case NewRefCntr =:= OldRefCntr of + true -> + {ok, NewDb}; + false -> + couch_ref_counter:add(NewRefCntr), + couch_ref_counter:drop(OldRefCntr), + {ok, NewDb} + end. + ensure_full_commit(#db{update_pid=UpdatePid,instance_start_time=StartTime}) -> ok = gen_server:call(UpdatePid, full_commit, infinity), {ok, StartTime}. |