Author: kocolosk
Date: Fri Sep 23 19:50:51 2011
New Revision: 1174979
URL: http://svn.apache.org/viewvc?rev=1174979&view=rev
Log:
Write header before handing over compacted group
Writing the header first ensures that the index will not be reset if
the server crashes in between the handoff and the next delayed_commit.
See COUCHDB-994
Modified:
couchdb/branches/1.1.x/src/couchdb/couch_view_compactor.erl
couchdb/branches/1.1.x/src/couchdb/couch_view_group.erl
Modified: couchdb/branches/1.1.x/src/couchdb/couch_view_compactor.erl
URL:
http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_view_compactor.erl?rev=1174979&r1=1174978&r2=1174979&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_view_compactor.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_view_compactor.erl Fri Sep 23
19:50:51 2011
@@ -79,6 +79,9 @@ compact_group(Group, EmptyGroup, DbName)
maybe_retry_compact(Db, GroupId, NewGroup).
maybe_retry_compact(#db{name = DbName} = Db, GroupId, NewGroup) ->
+ #group{sig = Sig, fd = NewFd} = NewGroup,
+ Header = {Sig, couch_view_group:get_index_header_data(NewGroup)},
+ ok = couch_file:write_header(NewFd, Header),
Pid = couch_view:get_group_server(DbName, GroupId),
case gen_server:call(Pid, {compact_done, NewGroup}) of
ok ->
Modified: couchdb/branches/1.1.x/src/couchdb/couch_view_group.erl
URL:
http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_view_group.erl?rev=1174979&r1=1174978&r2=1174979&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_view_group.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_view_group.erl Fri Sep 23 19:50:51
2011
@@ -17,6 +17,9 @@
-export([start_link/1, request_group/2, request_group_info/1]).
-export([open_db_group/2, open_temp_group/5,
design_doc_to_view_group/1,design_root/2]).
+%% Exports for the compactor
+-export([get_index_header_data/1]).
+
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).