couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject svn commit: r1043540 - /couchdb/trunk/src/couchdb/couch_db_updater.erl
Date Wed, 08 Dec 2010 17:39:20 GMT
Author: kocolosk
Date: Wed Dec  8 17:39:20 2010
New Revision: 1043540

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

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=1043540&r1=1043539&r2=1043540&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Wed Dec  8 17:39:20 2010
@@ -848,7 +848,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]),



Mime
View raw message