fix(kafka-based bridges): avoid trying to get raw config for replayq dir

Fixes https://emqx.atlassian.net/browse/EMQX-12049
This commit is contained in:
Thales Macedo Garitezi 2024-03-21 11:49:00 -03:00
parent 34c3c4e892
commit e837791f94
1 changed files with 9 additions and 2 deletions

View File

@ -668,9 +668,8 @@ partitioner(random) -> random;
partitioner(key_dispatch) -> first_key_dispatch. partitioner(key_dispatch) -> first_key_dispatch.
replayq_dir(BridgeType, BridgeName) -> replayq_dir(BridgeType, BridgeName) ->
RawConf = emqx_conf:get_raw([actions, BridgeType, BridgeName]),
DirName = iolist_to_binary([ DirName = iolist_to_binary([
emqx_bridge_lib:downgrade_type(BridgeType, RawConf), maybe_v1_type_name(BridgeType),
":", ":",
BridgeName, BridgeName,
":", ":",
@ -678,6 +677,14 @@ replayq_dir(BridgeType, BridgeName) ->
]), ]),
filename:join([emqx:data_dir(), "kafka", DirName]). filename:join([emqx:data_dir(), "kafka", DirName]).
%% To avoid losing queued data on disk, we must use the same directory as the old v1
%% bridges, if any. Among the Kafka-based bridges that exist since v1, only Kafka changed
%% its type name. Other bridges are either unchanged, or v2-only, and should use their v2
%% type names.
maybe_v1_type_name(Type) when is_atom(Type) -> maybe_v1_type_name(atom_to_binary(Type));
maybe_v1_type_name(<<"kafka_producer">>) -> <<"kafka">>;
maybe_v1_type_name(Type) -> Type.
with_log_at_error(Fun, Log) -> with_log_at_error(Fun, Log) ->
try try
Fun() Fun()