summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <robert.newson@uk.ibm.com>2020-02-16 12:05:29 +0000
committerjiangph <jiangph@cn.ibm.com>2020-11-09 17:30:57 +0800
commit9d8ea3188c79a29929d38fa5dcf93b01029e5531 (patch)
tree04cd3335d39ad8b3a5bbc8f9a3f1179a3c3fad2c
parent9a0c55be85852621c88b7ff166183b388987f57c (diff)
downloadcouchdb-3.x-reset-corrupt-view-index-2.tar.gz
Reset if we don't get a view header3.x-reset-corrupt-view-index-2
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.
-rw-r--r--src/couch_mrview/src/couch_mrview_index.erl6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/couch_mrview/src/couch_mrview_index.erl b/src/couch_mrview/src/couch_mrview_index.erl
index 018060f83..68f1d2322 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),