couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [couchdb] 01/01: Don't reset_index if read_header fails
Date Thu, 11 Apr 2019 12:54:10 GMT
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch dont-reset-index
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 66dc0ebf363e0f8e1d69ab48cc9890d88b8e7130
Author: Robert Newson <rnewson@apache.org>
AuthorDate: Thu Apr 11 13:41:41 2019 +0100

    Don't reset_index if read_header fails
    
    This decision is an old one, I think, and took the view that an error
    from read_header meant something fatally wrong with this index
    file. These days, it's far more likely to be something else, a process
    crash at the wrong moment, and therefore wiping the index out is an
    overreaction.
---
 src/couch_mrview/src/couch_mrview_index.erl | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index ac43333..46c8345 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -122,7 +122,7 @@ open(Db, State0) ->
 
     case couch_mrview_util:open_file(IndexFName) of
         {ok, Fd} ->
-            case (catch couch_file:read_header(Fd)) of
+            case couch_file:read_header(Fd) of
                 % upgrade code for <= 1.2.x
                 {ok, {OldSig, Header}} ->
                     % Matching view signatures.
@@ -135,10 +135,8 @@ open(Db, State0) ->
                     NewSt = couch_mrview_util:init_state(Db, Fd, State, Header),
                     ensure_local_purge_doc(Db, NewSt),
                     {ok, NewSt};
-                _ ->
-                    NewSt = couch_mrview_util:reset_index(Db, Fd, State),
-                    ensure_local_purge_doc(Db, NewSt),
-                    {ok, NewSt}
+                {error, Reason} ->
+                    {error, Reason}
             end;
         {error, Reason} = Error ->
             couch_log:error("Failed to open view file '~s': ~s",


Mime
View raw message