Skip to content

Commit

Permalink
MB-52142: Fix default for bucket throttle setting
Browse files Browse the repository at this point in the history
Change-Id: I41714681d25c22d117da4f7e96eda54f919b8a5b
Reviewed-on: https://review.couchbase.org/c/ns_server/+/179373
Tested-by: Navdeep S Boparai <navdeep.boparai@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Steve Watanabe <steve.watanabe@couchbase.com>
  • Loading branch information
boparai11 committed Aug 31, 2022
1 parent f5a5200 commit dd4f8b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
26 changes: 1 addition & 25 deletions src/bucket_info_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
build_short_bucket_info/3,
build_name_and_locator/2,
build_vbucket_map/2,
build_ddocs/2,
get_throttle_attributes/0]).
build_ddocs/2]).

%% for diagnostics
-export([submit_full_reset/0]).
Expand Down Expand Up @@ -193,7 +192,6 @@ build_short_bucket_info(Id, BucketConfig, Snapshot) ->
build_num_vbuckets(BucketConfig),
build_bucket_capabilities(BucketConfig),
build_storage_limits(BucketConfig),
build_throttle_limits(BucketConfig),
build_collections_manifest_id(Id, Snapshot)].

build_num_vbuckets(BucketConfig) ->
Expand Down Expand Up @@ -327,28 +325,6 @@ build_storage_limits(BucketConfig) ->
{searchStorageLimit, ns_bucket:fts_storage_limit(BucketConfig)}]
end.

get_throttle_attributes() ->
[{dataThrottleLimit,
kv_throttle_limit, ?DEFAULT_KV_THROTTLE_LIMIT},
{indexThrottleLimit,
index_throttle_limit, ?DEFAULT_INDEX_THROTTLE_LIMIT},
{searchThrottleLimit,
fts_throttle_limit, ?DEFAULT_FTS_THROTTLE_LIMIT},
{queryThrottleLimit,
n1ql_throttle_limit, ?DEFAULT_N1QL_THROTTLE_LIMIT},
{sgwReadThrottleLimit,
sgw_read_throttle_limit, ?DEFAULT_SGW_READ_THROTTLE_LIMIT},
{sgwWriteThrottleLimit,
sgw_write_throttle_limit, ?DEFAULT_SGW_WRITE_THROTTLE_LIMIT}].

build_throttle_limits(BucketConfig) ->
case config_profile:get_bool(enable_throttle_limits) of
false -> [];
true ->
[{Param, proplists:get_value(Key, BucketConfig, Default)} ||
{Param, Key, Default} <- get_throttle_attributes()]
end.

%% Clients expect these revisions to grow monotonically.
%% This doesn't handle chronicle quorum failovers, but we may
%% deal with it later.
Expand Down
6 changes: 6 additions & 0 deletions src/menelaus_event.erl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ is_interesting_to_watchers({significant_buckets_change, _}) -> true;
is_interesting_to_watchers({memcached, _}) -> true;
is_interesting_to_watchers({{node, _, memcached}, _}) -> true;
is_interesting_to_watchers({{node, _, membership}, _}) -> true;
is_interesting_to_watchers({kv_throttle_limit, _}) -> true;
is_interesting_to_watchers({index_throttle_limit, _}) -> true;
is_interesting_to_watchers({fts_throttle_limit, _}) -> true;
is_interesting_to_watchers({n1ql_throttle_limit, _}) -> true;
is_interesting_to_watchers({sgw_read_throttle_limit, _}) -> true;
is_interesting_to_watchers({sgw_write_throttle_limit, _}) -> true;
is_interesting_to_watchers({rebalance_status, _}) -> true;
is_interesting_to_watchers({recovery_status, _}) -> true;
is_interesting_to_watchers({nodes_wanted, _}) -> true;
Expand Down
31 changes: 30 additions & 1 deletion src/menelaus_web_buckets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,37 @@ build_bucket_info(Id, Ctx, InfoLevel, MayExposeAuth, SkipMap) ->
build_purge_interval_info(BucketConfig),
build_replica_index(BucketConfig),
build_bucket_placer_params(BucketConfig),
build_throttle_limits(BucketConfig),
build_dynamic_bucket_info(InfoLevel, Id, BucketConfig, Ctx),
[build_sasl_password(BucketConfig) || MayExposeAuth]])}.

get_throttle_attributes() ->
[{dataThrottleLimit,
kv_throttle_limit, ?DEFAULT_KV_THROTTLE_LIMIT},
{indexThrottleLimit,
index_throttle_limit, ?DEFAULT_INDEX_THROTTLE_LIMIT},
{searchThrottleLimit,
fts_throttle_limit, ?DEFAULT_FTS_THROTTLE_LIMIT},
{queryThrottleLimit,
n1ql_throttle_limit, ?DEFAULT_N1QL_THROTTLE_LIMIT},
{sgwReadThrottleLimit,
sgw_read_throttle_limit, ?DEFAULT_SGW_READ_THROTTLE_LIMIT},
{sgwWriteThrottleLimit,
sgw_write_throttle_limit, ?DEFAULT_SGW_WRITE_THROTTLE_LIMIT}].

get_throttle_default(Key, Default) ->
ns_config:read_key_fast(Key, Default).

build_throttle_limits(BucketConfig) ->
case config_profile:get_bool(enable_throttle_limits) of
false -> [];
true ->
[{Param, proplists:get_value(Key,
BucketConfig,
get_throttle_default(Key, Default))} ||
{Param, Key, Default} <- get_throttle_attributes()]
end.

build_authType(BucketConfig) ->
case cluster_compat_mode:is_cluster_71() of
false ->
Expand Down Expand Up @@ -1932,7 +1960,8 @@ parse_validate_throttle_limits(Params, BucketConfig, IsNew, IsEnabled) ->
[do_parse_validate_limit(Param, Key, LimitFunc(atom_to_list(Param)),
BucketConfig,
IsNew, IsEnabled) ||
{Param, Key, _} <- bucket_info_cache:get_throttle_attributes()].
{Param, Key, _} <- get_throttle_attributes(),
proplists:is_defined(atom_to_list(Param), Params)].

do_parse_validate_limit(_Param, _InternalName, undefined, _BucketConfig,
_IsNew, false = _IsEnabled) ->
Expand Down

0 comments on commit dd4f8b6

Please sign in to comment.