This is an automated email from the ASF dual-hosted git repository. nickva pushed a commit to branch unform-search-unavailable-error in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit d23ef4ce4814417b3f5e5203671142968211b75b Author: Nick Vatamaniuc <[email protected]> AuthorDate: Fri Oct 2 11:55:42 2026 -0400 Make search unvailable error more uniform When running elixir tests with clouseau enabled, as opposed to disabled as we do in Jenkins, noticed a few different shapes of "search unavailable" error. That makes the tests flaky and may be confusing in the API results as well. While at it fix an unused warnign from elixir tests about `@lists` --- src/fabric/src/fabric_rpc.erl | 18 +++++++++++++++--- test/elixir/test/index_info_test.exs | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/fabric/src/fabric_rpc.erl b/src/fabric/src/fabric_rpc.erl index 5760fc54d..a05d59f96 100644 --- a/src/fabric/src/fabric_rpc.erl +++ b/src/fabric/src/fabric_rpc.erl @@ -66,6 +66,8 @@ -include_lib("couch/include/couch_db.hrl"). -include_lib("couch_mrview/include/couch_mrview.hrl"). +-define(SEARCH_UNAVAILABLE, {service_unavailable, ~"Search is not available"}). + % How many design docs an index_info/3 worker can process concurrently -define(INDEX_INFO_CONCURRENCY, 8). @@ -398,14 +400,24 @@ view_info(ShardName, DDoc) -> end. search_info(false, _ShardName, _DDoc, _IndexName) -> - {error, {service_unavailable, ~"Search is not available"}}; + {error, ?SEARCH_UNAVAILABLE}; search_info(true, ShardName, DDoc, IndexName) -> try - norm_error(dreyfus_index:info(ShardName, DDoc, IndexName)) + search_error(norm_error(dreyfus_index:info(ShardName, DDoc, IndexName))) catch - _Tag:Error -> {error, Error} + _Tag:Error -> search_error({error, Error}) end. +% search (clouseau) may return different exit/noconnection shapes depending if +% it was cached in dreyfus:available() or at what point after that we noticed +% it wasn't connected make the error more uniform and less flaky +search_error({error, {'EXIT', noconnection}}) -> + {error, ?SEARCH_UNAVAILABLE}; +search_error({error, {noconnection, _}}) -> + {error, ?SEARCH_UNAVAILABLE}; +search_error(Else) -> + Else. + nouveau_info(false, _ShardName, _DDoc, _IndexName) -> {error, {service_unavailable, ~"nouveau is not enabled"}}; nouveau_info(true, ShardName, DDoc, IndexName) -> diff --git a/test/elixir/test/index_info_test.exs b/test/elixir/test/index_info_test.exs index e5ecac039..7c59b48d8 100644 --- a/test/elixir/test/index_info_test.exs +++ b/test/elixir/test/index_info_test.exs @@ -8,7 +8,6 @@ defmodule IndexInfoTest do """ @pending_keys ["copies", "copies_expected", "maximum", "minimum", "preferred", "total"] - @lists ["nouveau_indexes", "search_indexes", "view_indexes"] # expected keys in every response @keys ["bookmark", "nouveau_indexes", "search_indexes", "total_rows", "view_indexes"]
