You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2010/12/08 18:41:30 UTC

svn commit: r1043542 - /couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl

Author: kocolosk
Date: Wed Dec  8 17:41:29 2010
New Revision: 1043542

URL: http://svn.apache.org/viewvc?rev=1043542&view=rev
Log:
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.

Modified:
    couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl?rev=1043542&r1=1043541&r2=1043542&view=diff
==============================================================================
--- couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.1.x/src/couchdb/couch_db_updater.erl Wed Dec  8 17:41:29 2010
@@ -869,7 +869,12 @@ start_copy_compact(#db{name=Name,filepat
     {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]),