You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2020/02/16 12:07:07 UTC

[couchdb] 01/01: Reset if we don't get a view header

This is an automated email from the ASF dual-hosted git repository.

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

commit 140e3fa6b3080d44449c9c52900e8086925f631b
Author: Robert Newson <ro...@uk.ibm.com>
AuthorDate: Sun Feb 16 12:05:29 2020 +0000

    Reset if we don't get a view header
    
    I found a .view file with a db_header in production (cause unknown but
    I'm hoping it's manual intervention).
    
    This patch means we'll reset the index if we find something other than
    a view header when looking for one.
---
 src/couch_mrview/src/couch_mrview_index.erl | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index c96d871..cc013c5 100644
--- a/src/couch_mrview/src/couch_mrview_index.erl
+++ b/src/couch_mrview/src/couch_mrview_index.erl
@@ -133,6 +133,12 @@ open(Db, State0) ->
                     NewSt = couch_mrview_util:reset_index(Db, Fd, State),
                     ensure_local_purge_doc(Db, NewSt),
                     {ok, NewSt};
+                {ok, Else} ->
+                    couch_log:error("~s has a bad header: got ~p",
+                        [IndexFName, Else]),
+                    NewSt = couch_mrview_util:reset_index(Db, Fd, State),
+                    ensure_local_purge_doc(Db, NewSt),
+                    {ok, NewSt};
                 no_valid_header ->
                     NewSt = couch_mrview_util:reset_index(Db, Fd, State),
                     ensure_local_purge_doc(Db, NewSt),