Skip to content

Commit e91c918

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
2 parents f36751a + 6acee76 commit e91c918

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
@@ -17,7 +17,7 @@
1717
-export([parse_tags/1, update_metadata/2, tag_with/2, untag_from/2, update_tags/2, update_tags/3]).
1818
-export([lookup/1]).
1919
-export([info/1, info/2, info_all/0, info_all/1, info_all/2, info_all/3]).
20-
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1]).
20+
-export([dir/1, msg_store_dir_path/1, msg_store_dir_wildcard/0, config_file_path/1, ensure_config_file/1]).
2121
-export([delete_storage/1]).
2222
-export([vhost_down/1]).
2323
-export([put_vhost/5]).
@@ -85,7 +85,7 @@ ensure_config_file(VHost) ->
8585
%% default of 16384 for forward compatibility. Historic
8686
%% default calculated as trunc(math:pow(2,?REL_SEQ_BITS)).
8787
_ ->
88-
16384
88+
?LEGACY_INDEX_SEGMENT_ENTRY_COUNT
8989
end,
9090
rabbit_log:info("Setting segment_entry_count for vhost '~s' with ~b queues to '~b'",
9191
[VHost, length(QueueDirs), SegmentEntryCount]),
@@ -96,8 +96,15 @@ ensure_config_file(VHost) ->
9696
end.
9797

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

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

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)