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:44:01 UTC

svn commit: r1043544 - /couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl

Author: kocolosk
Date: Wed Dec  8 17:44:01 2010
New Revision: 1043544

URL: http://svn.apache.org/viewvc?rev=1043544&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/0.11.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl?rev=1043544&r1=1043543&r2=1043544&view=diff
==============================================================================
--- couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl Wed Dec  8 17:44:01 2010
@@ -854,7 +854,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]),