Skip to content

Handle cases where virtual host config file does not yet exist #3068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions deps/rabbit/src/rabbit_vhost.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
-export([parse_tags/1, update_metadata/2, tag_with/2, untag_from/2, update_tags/2, update_tags/3]).
-export([lookup/1]).
-export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1]).
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1, ensure_config_file/1]).
-export([delete_storage/1]).
-export([vhost_down/1]).
-export([put_vhost/5]).
Expand Down Expand Up @@ -85,7 +85,7 @@ ensure_config_file(VHost) ->
%% default of 16384 for forward compatibility. Historic
%% default calculated as trunc(math:pow(2,?REL_SEQ_BITS)).
_ ->
16384
?LEGACY_INDEX_SEGMENT_ENTRY_COUNT
end,
rabbit_log:info("Setting segment_entry_count for vhost '~s' with ~b queues to '~b'",
[VHost, length(QueueDirs), SegmentEntryCount]),
Expand All @@ -96,8 +96,15 @@ ensure_config_file(VHost) ->
end.

read_config(VHost) ->
{ok, Config} = file:consult(config_file_path(VHost)),
maps:from_list(Config).
Config = case file:consult(config_file_path(VHost)) of
{ok, Val} -> Val;
%% the file does not exist yet, likely due to an upgrade from a pre-3.7
%% message store layout so use the history default.
{error, _} -> #{
segment_entry_count => ?LEGACY_INDEX_SEGMENT_ENTRY_COUNT
}
end,
rabbit_data_coercion:to_map(Config).

-define(INFO_KEYS, vhost:info_keys()).

Expand Down
3 changes: 3 additions & 0 deletions deps/rabbit_common/include/rabbit.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,6 @@
%% Execution timeout of connection and channel tracking operations
-define(TRACKING_EXECUTION_TIMEOUT,
rabbit_misc:get_env(rabbit, tracking_execution_timeout, 5000)).

%% 3.6, 3.7, early 3.8
-define(LEGACY_INDEX_SEGMENT_ENTRY_COUNT, 16384).