summaryrefslogtreecommitdiff
path: root/src/couchdb
diff options
context:
space:
mode:
authorAdam Kocoloski <kocolosk@apache.org>2010-12-08 17:42:08 +0000
committerAdam Kocoloski <kocolosk@apache.org>2010-12-08 17:42:08 +0000
commit2f5e45e43780f4a479f2413fbb5cbbde23e77f3a (patch)
treed30dfe1e43a8e9e2505e3206ea88cd07d9381c86 /src/couchdb
parentae228c7f3177fd79c5dc38b53802999be4152e04 (diff)
Fix compactor crash when .compact file is missing header
Users affected by COUCHDB-968 can take advantage of this patch to force a compaction in retry mode and thus remove the duplicates. Simply create an empty dbname.couch.compact file in the database_dir before triggering the compaction for dbname. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.0.x@1043543 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb')
-rw-r--r--src/couchdb/couch_db_updater.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/couchdb/couch_db_updater.erl b/src/couchdb/couch_db_updater.erl
index bd404c64..633ae230 100644
--- a/src/couchdb/couch_db_updater.erl
+++ b/src/couchdb/couch_db_updater.erl
@@ -869,7 +869,12 @@ start_copy_compact(#db{name=Name,filepath=Filepath}=Db) ->
{ok, Fd} ->
couch_task_status:add_task(<<"Database Compaction">>, <<Name/binary, " retry">>, <<"Starting">>),
Retry = true,
- {ok, Header} = couch_file:read_header(Fd);
+ case couch_file:read_header(Fd) of
+ {ok, Header} ->
+ ok;
+ no_valid_header ->
+ ok = couch_file:write_header(Fd, Header=#db_header{})
+ end;
{error, enoent} ->
couch_task_status:add_task(<<"Database Compaction">>, Name, <<"Starting">>),
{ok, Fd} = couch_file:open(CompactFile, [create]),