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

jiangphcn pushed a commit to branch 113045-case-clause-mango
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 4a7026d49de2e6dd03d18f6a65b770a325dc0a11
Author: jiangph <[email protected]>
AuthorDate: Fri Nov 2 17:12:10 2018 +0800

    Support out-of-sync in mango when doc is deleted
    
      - under situation where the document is deleted while the mrview
      index for this document is not updated, the returned value from
      mrview is {doc,null}. There is no such consideration in Mango to
      cause case_clause error. This fix is to consider out-of-sync between
      documents in database and their index and not to cause 500 when
      the _find endpoint is called.
---
 src/mango/src/mango_cursor_view.erl | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/mango/src/mango_cursor_view.erl 
b/src/mango/src/mango_cursor_view.erl
index 174381e..749ed35 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -282,6 +282,11 @@ handle_message({meta, _}, Cursor) ->
     {ok, Cursor};
 handle_message({row, Props}, Cursor) ->
     case doc_member(Cursor, Props) of
+        {ok, null, {execution_stats, ExecutionStats1}} ->
+            Cursor1 = Cursor#cursor {
+                execution_stats = ExecutionStats1
+            },
+            {ok, Cursor1};
         {ok, Doc, {execution_stats, ExecutionStats1}} ->
             Cursor1 = Cursor#cursor {
                 execution_stats = ExecutionStats1
@@ -427,7 +432,10 @@ doc_member(Cursor, RowProps) ->
                     match_doc(Selector, Doc, ExecutionStats1);
                 Else ->
                     Else
-            end
+            end;
+        null ->
+            ExecutionStats1 = 
mango_execution_stats:incr_docs_examined(ExecutionStats),
+            {ok, null, {execution_stats, ExecutionStats1}}
     end.
 
 

Reply via email to