Skip to content

Commit 7b126e4

Browse files
Merge pull request #3068 from rabbitmq/mk-segment-entry-count-fallback-during-3.6-upgrade
Handle cases where virtual host config file does not yet exist (cherry picked from commit e91c918)
1 parent af3d64d commit 7b126e4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

deps/rabbit/src/rabbit_vhost.erl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
set_limits/2, vhost_cluster_state/1, is_running_on_all_nodes/1, await_running_on_all_nodes/2,
1616
list/0, count/0, list_names/0, all/0, parse_tags/1]).
1717
-export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
18-
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1]).
18+
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1, ensure_config_file/1]).
1919
-export([delete_storage/1]).
2020
-export([vhost_down/1]).
2121
-export([put_vhost/5]).
@@ -80,7 +80,7 @@ ensure_config_file(VHost) ->
8080
%% default of 16384 for forward compatibility. Historic
8181
%% default calculated as trunc(math:pow(2,?REL_SEQ_BITS)).
8282
_ ->
83-
16384
83+
?LEGACY_INDEX_SEGMENT_ENTRY_COUNT
8484
end,
8585
_ = rabbit_log:info("Setting segment_entry_count for vhost '~s' with ~b queues to '~b'",
8686
[VHost, length(QueueDirs), SegmentEntryCount]),
@@ -91,8 +91,15 @@ ensure_config_file(VHost) ->
9191
end.
9292

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

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

deps/rabbit_common/include/rabbit.hrl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,6 @@
266266
%% Execution timeout of connection and channel tracking operations
267267
-define(TRACKING_EXECUTION_TIMEOUT,
268268
rabbit_misc:get_env(rabbit, tracking_execution_timeout, 5000)).
269+
270+
%% 3.6, 3.7, early 3.8
271+
-define(LEGACY_INDEX_SEGMENT_ENTRY_COUNT, 16384).

0 commit comments

Comments
 (0)