From 1b647035d01538651da18169f82218e7128ce4dc Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Fri, 8 Mar 2024 17:39:46 +0100 Subject: [PATCH] chore(dsrepl): make dialyzer a bit happier --- apps/emqx/src/emqx_rpc.erl | 1 - .../src/emqx_ds_replication_layer_meta.erl | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/emqx/src/emqx_rpc.erl b/apps/emqx/src/emqx_rpc.erl index 61aa2a8ca..5cc8ca4df 100644 --- a/apps/emqx/src/emqx_rpc.erl +++ b/apps/emqx/src/emqx_rpc.erl @@ -37,7 +37,6 @@ badrpc/0, call_result/1, call_result/0, - cast_result/0, multicall_result/1, multicall_result/0, erpc/1, diff --git a/apps/emqx_durable_storage/src/emqx_ds_replication_layer_meta.erl b/apps/emqx_durable_storage/src/emqx_ds_replication_layer_meta.erl index 75b1a225a..2ecc8b27f 100644 --- a/apps/emqx_durable_storage/src/emqx_ds_replication_layer_meta.erl +++ b/apps/emqx_durable_storage/src/emqx_ds_replication_layer_meta.erl @@ -98,6 +98,17 @@ %% Peristent term key: -define(emqx_ds_builtin_site, emqx_ds_builtin_site). +%% Make Dialyzer happy +-define(NODE_PAT(), + %% Equivalent of `#?NODE_TAB{_ = '_'}`: + erlang:make_tuple(record_info(size, ?NODE_TAB), '_') +). + +-define(SHARD_PAT(SHARD), + %% Equivalent of `#?SHARD_TAB{shard = SHARD, _ = '_'}` + erlang:make_tuple(record_info(size, ?SHARD_TAB), '_', [{#?SHARD_TAB.shard, SHARD}]) +). + %%================================================================================ %% API funcions %%================================================================================ @@ -264,14 +275,14 @@ allocate_shards_trans(DB, Opts) -> ReplicationFactor = maps:get(replication_factor, Opts), NReplicas = min(NSites, ReplicationFactor), Shards = [integer_to_binary(I) || I <- lists:seq(0, NShards - 1)], - AllSites = mnesia:match_object(?NODE_TAB, #?NODE_TAB{_ = '_'}, read), + AllSites = mnesia:match_object(?NODE_TAB, ?NODE_PAT(), read), case length(AllSites) of N when N >= NSites -> ok; _ -> mnesia:abort({insufficient_sites_online, NSites, AllSites}) end, - case mnesia:match_object(?SHARD_TAB, #?SHARD_TAB{shard = {DB, '_'}, _ = '_'}, write) of + case mnesia:match_object(?SHARD_TAB, ?SHARD_PAT({DB, '_'}), write) of [] -> ok; Records ->