You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2020/08/26 20:59:04 UTC

[couchdb] 01/01: bypass partition query limit for mango

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

tonysun83 pushed a commit to branch fix-partition-query-limit
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c2670f9c80b55f958d305369eacce392c977b05e
Author: Tony Sun <to...@gmail.com>
AuthorDate: Wed Aug 26 13:56:14 2020 -0700

    bypass partition query limit for mango
    
    When partition_query_limit is set for couch_mrview, it limits how many
    docs can be scanned when executing partitioned queries. But this limits
    mango's doc scans internally. This leads to documents not being scanned
    to fulfill a query. This fixes:
    https://github.com/apache/couchdb/issues/2795
---
 src/couch_mrview/src/couch_mrview_util.erl | 9 ++++++---
 src/mango/src/mango_cursor_view.erl        | 3 ++-
 test/elixir/test/partition_mango_test.exs  | 3 +++
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/couch_mrview/src/couch_mrview_util.erl b/src/couch_mrview/src/couch_mrview_util.erl
index e971720..d318a3f 100644
--- a/src/couch_mrview/src/couch_mrview_util.erl
+++ b/src/couch_mrview/src/couch_mrview_util.erl
@@ -425,9 +425,12 @@ validate_args(#mrst{} = State, Args0) ->
 
 
 apply_limit(ViewPartitioned, Args) ->
-    LimitType = case ViewPartitioned of
-        true -> "partition_query_limit";
-        false -> "query_limit"
+    Options = Args#mrargs.extra,
+    IgnorePQLimit = lists:keyfind(ignore_partition_query_limit, 1, Options),
+    LimitType = case {ViewPartitioned, IgnorePQLimit} of
+        {true, false} -> "partition_query_limit";
+        {true, _} -> "query_limit";
+        {false, _} -> "query_limit"
     end,
 
     MaxLimit = config:get_integer("query_server_config",
diff --git a/src/mango/src/mango_cursor_view.erl b/src/mango/src/mango_cursor_view.erl
index 240ef50..eebece3 100644
--- a/src/mango/src/mango_cursor_view.erl
+++ b/src/mango/src/mango_cursor_view.erl
@@ -116,7 +116,8 @@ base_args(#cursor{index = Idx, selector = Selector} = Cursor) ->
         start_key = StartKey,
         end_key = EndKey,
         include_docs = true,
-        extra = [{callback, {?MODULE, view_cb}}, {selector, Selector}]
+        extra = [{callback, {?MODULE, view_cb}}, {selector, Selector},
+            {ignore_partition_query_limit, true}]
     }.
 
 
diff --git a/test/elixir/test/partition_mango_test.exs b/test/elixir/test/partition_mango_test.exs
index 992999f..7ccf5cd 100644
--- a/test/elixir/test/partition_mango_test.exs
+++ b/test/elixir/test/partition_mango_test.exs
@@ -502,6 +502,9 @@ defmodule PartitionMangoTest do
     create_partition_docs(db_name)
     create_index(db_name, ["value"])
 
+    # this is to test that we bypass partition_query_limit for mango
+    set_config({"query_server_config", "partition_query_limit", "1"})
+
     url = "/#{db_name}/_partition/foo/_find"
 
     resp =