Merge pull request #12764 from zhongwencool/fix-bpapi-undef
fix: bpapi undef on old node
This commit is contained in:
commit
2926518b3d
|
@ -86,8 +86,36 @@ supported_version(API) ->
|
|||
-spec announce(node(), atom()) -> ok.
|
||||
announce(Node, App) ->
|
||||
{ok, Data} = file:consult(?MODULE:versions_file(App)),
|
||||
%% replicant(5.6.0) will call old core(<5.6.0) announce_fun/2 is undef on old core
|
||||
%% so we just use anonymous function to update.
|
||||
try
|
||||
{atomic, ok} = mria:transaction(?COMMON_SHARD, fun ?MODULE:announce_fun/2, [Node, Data]),
|
||||
ok.
|
||||
ok
|
||||
catch
|
||||
error:undef ->
|
||||
{atomic, ok} = mria:transaction(
|
||||
?COMMON_SHARD,
|
||||
fun() ->
|
||||
MS = ets:fun2ms(fun(#?TAB{key = {N, API}}) when N =:= Node ->
|
||||
{N, API}
|
||||
end),
|
||||
OldKeys = mnesia:select(?TAB, MS, write),
|
||||
_ = [
|
||||
mnesia:delete({?TAB, Key})
|
||||
|| Key <- OldKeys
|
||||
],
|
||||
%% Insert new records:
|
||||
_ = [
|
||||
mnesia:write(#?TAB{key = {Node, API}, version = Version})
|
||||
|| {API, Version} <- Data
|
||||
],
|
||||
%% Update maximum supported version:
|
||||
_ = [update_minimum(API) || {API, _} <- Data],
|
||||
ok
|
||||
end
|
||||
),
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec versions_file(atom()) -> file:filename_all().
|
||||
versions_file(App) ->
|
||||
|
|
Loading…
Reference in New Issue