You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/09/15 19:39:59 UTC

[couchdb] branch fix-limit0-for-views created (now d9d2bac)

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

vatamane pushed a change to branch fix-limit0-for-views
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at d9d2bac  Fix meta result for views when limit = 0

This branch includes the following new commits:

     new d9d2bac  Fix meta result for views when limit = 0

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[couchdb] 01/01: Fix meta result for views when limit = 0

Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fix-limit0-for-views
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit d9d2bacd402921e08db78cc818106836ce3685af
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Wed Sep 15 15:31:34 2021 -0400

    Fix meta result for views when limit = 0
    
    Previously, as soon as one row returned, we immediately stopped, erroneously
    assuming that meta for all ranges have already been received. However, it was
    possible that we'd get meta from range 00-7f, then a row from 00-7f before
    getting meta from 7f-ff and thus we'd return an empty result.
    
    To fix the issue we simply re-use the already existing limit=0 clause from the
    fabric_view:maybe_send_row/1 function which will wait until there is a complete
    ring before returning. That relies on updating the counters (the ring) only
    with meta return and not with view rows, so if the ring is complete, we know we
    only completed with meta.
    
    The other issue with limit=0 clause was that it wasn't properly ack-ing the
    received row. Rows are acked for sorted=false case below and for the regular
    limit>0, sorted=true case in fabric_view:get_next_row/1.
    
    Issue: https://github.com/apache/couchdb/issues/3750
---
 src/fabric/src/fabric_view_map.erl | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/fabric/src/fabric_view_map.erl b/src/fabric/src/fabric_view_map.erl
index b8d0d39..6477654 100644
--- a/src/fabric/src/fabric_view_map.erl
+++ b/src/fabric/src/fabric_view_map.erl
@@ -146,10 +146,11 @@ handle_message({meta, Meta0}, {Worker, From}, State) ->
         }}
     end;
 
-handle_message(#view_row{}, {_, _}, #collector{limit=0} = State) ->
-    #collector{callback=Callback} = State,
-    {_, Acc} = Callback(complete, State#collector.user_acc),
-    {stop, State#collector{user_acc=Acc}};
+handle_message(#view_row{}, {_, From}, #collector{limit=0} = State) ->
+    rexi:stream_ack(From),
+    % Rely on limit=0 clause in maybe_send_row/1 to wait until all
+    % shard ranges reply with meta
+    fabric_view:maybe_send_row(State);
 
 handle_message(#view_row{} = Row, {_,From}, #collector{sorted=false} = St) ->
     #collector{callback=Callback, user_acc=AccIn, limit=Limit} = St,