@@ -57,6 +57,38 @@ recover(VHost) ->
57
57
ok = rabbit_file :ensure_dir (VHostStubFile ),
58
58
ok = file :write_file (VHostStubFile , VHost ),
59
59
ok = ensure_config_file (VHost ),
60
+
61
+ % % in the past, a vhost didn't necessarily have a default queue type
62
+ % % and queues declared in that vhost defaulted to the type configured
63
+ % % on the node level (in the config file). Now each vhost has its default
64
+ % % queue type in the metadata. For vhosts updated from older versions,
65
+ % % we need to add the default type to the metadata
66
+ case rabbit_db_vhost :get (VHost ) of
67
+ undefined ->
68
+ rabbit_log :warning (" Cannot check metadata for vhost '~ts ' during recovery, record not found." ,
69
+ [VHost ]);
70
+ VHostRecord ->
71
+ Metadata = vhost :get_metadata (VHostRecord ),
72
+ case maps :is_key (default_queue_type , Metadata ) of
73
+ true ->
74
+ rabbit_log :debug (" Default queue type for vhost '~ts ' is ~p ." ,
75
+ [VHost , maps :get (default_queue_type , Metadata )]),
76
+ ok ;
77
+ false ->
78
+ DefaultType = rabbit_queue_type :default_alias (),
79
+ rabbit_log :info (" Setting missing default queue type to '~p ' for vhost '~ts '." ,
80
+ [DefaultType , VHost ]),
81
+ case rabbit_db_vhost :merge_metadata (VHost , #{default_queue_type => DefaultType }) of
82
+ {ok , _UpdatedVHostRecord } ->
83
+ ok ;
84
+ {error , Reason } ->
85
+ % Log the error but continue recovery
86
+ rabbit_log :warning (" Failed to set the default queue type for vhost '~ts ': ~p " ,
87
+ [VHost , Reason ])
88
+ end
89
+ end
90
+ end ,
91
+
60
92
{Recovered , Failed } = rabbit_amqqueue :recover (VHost ),
61
93
AllQs = Recovered ++ Failed ,
62
94
QNames = [amqqueue :get_name (Q ) || Q <- AllQs ],
0 commit comments