Add DQT to vhost metadata on recovery
Vhosts that currently don't have their own default queue type, now inherit it from the node configuration and store it in their metadata going forward.
This commit is contained in:
parent
0e743b5fe7
commit
9d0f01b45b
|
@ -57,6 +57,38 @@ recover(VHost) ->
|
||||||
ok = rabbit_file:ensure_dir(VHostStubFile),
|
ok = rabbit_file:ensure_dir(VHostStubFile),
|
||||||
ok = file:write_file(VHostStubFile, VHost),
|
ok = file:write_file(VHostStubFile, VHost),
|
||||||
ok = ensure_config_file(VHost),
|
ok = ensure_config_file(VHost),
|
||||||
|
|
||||||
|
%% in the past, a vhost didn't necessarily have a default queue type
|
||||||
|
%% and queues declared in that vhost defaulted to the type configured
|
||||||
|
%% on the node level (in the config file). Now each vhost has its default
|
||||||
|
%% queue type in the metadata. For vhosts updated from older versions,
|
||||||
|
%% we need to add the default type to the metadata
|
||||||
|
case rabbit_db_vhost:get(VHost) of
|
||||||
|
undefined ->
|
||||||
|
rabbit_log:warning("Cannot check metadata for vhost '~ts' during recovery, record not found.",
|
||||||
|
[VHost]);
|
||||||
|
VHostRecord ->
|
||||||
|
Metadata = vhost:get_metadata(VHostRecord),
|
||||||
|
case maps:is_key(default_queue_type, Metadata) of
|
||||||
|
true ->
|
||||||
|
rabbit_log:debug("Default queue type for vhost '~ts' is ~p.",
|
||||||
|
[VHost, maps:get(default_queue_type, Metadata)]),
|
||||||
|
ok;
|
||||||
|
false ->
|
||||||
|
DefaultType = rabbit_queue_type:default_alias(),
|
||||||
|
rabbit_log:info("Setting missing default queue type to '~p' for vhost '~ts'.",
|
||||||
|
[DefaultType, VHost]),
|
||||||
|
case rabbit_db_vhost:merge_metadata(VHost, #{default_queue_type => DefaultType}) of
|
||||||
|
{ok, _UpdatedVHostRecord} ->
|
||||||
|
ok;
|
||||||
|
{error, Reason} ->
|
||||||
|
% Log the error but continue recovery
|
||||||
|
rabbit_log:warning("Failed to set the default queue type for vhost '~ts': ~p",
|
||||||
|
[VHost, Reason])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
{Recovered, Failed} = rabbit_amqqueue:recover(VHost),
|
{Recovered, Failed} = rabbit_amqqueue:recover(VHost),
|
||||||
AllQs = Recovered ++ Failed,
|
AllQs = Recovered ++ Failed,
|
||||||
QNames = [amqqueue:get_name(Q) || Q <- AllQs],
|
QNames = [amqqueue:get_name(Q) || Q <- AllQs],
|
||||||
|
|
Loading…
Reference in New Issue