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 20:10:51 UTC
[couchdb] branch 3.x updated: Fix meta result for views when limit
= 0
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git
The following commit(s) were added to refs/heads/3.x by this push:
new a36e730 Fix meta result for views when limit = 0
a36e730 is described below
commit a36e7308ab4a2cfead6da64a9f83b7776722382d
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,