summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2011-09-23 19:50:51 +0000
committerAdam Kocoloski <kocolosk@apache.org>2011-09-23 19:50:51 +0000
commitbefbdfb11f45bd2a5ccffb6b0d5ac04435ac9e55 (patch)
tree38122bc420095f23fc4fd8b4b466a796ba760761 /src
parent8a7696145241c4752379271c8253fa0c15093322 (diff)
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 git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1174979 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_view_compactor.erl3
-rw-r--r--src/couchdb/couch_view_group.erl3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/couchdb/couch_view_compactor.erl b/src/couchdb/couch_view_compactor.erl
index 43fdbc98..0063ef1d 100644
--- a/src/couchdb/couch_view_compactor.erl
+++ b/src/couchdb/couch_view_compactor.erl
@@ -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 ->
diff --git a/src/couchdb/couch_view_group.erl b/src/couchdb/couch_view_group.erl
index ef9b02ad..9c5372a8 100644
--- a/src/couchdb/couch_view_group.erl
+++ b/src/couchdb/couch_view_group.erl
@@ -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]).