-
Notifications
You must be signed in to change notification settings - Fork 103
Addressing Mnesia backend failing on erldns_zone_cache functions #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* added type bag on table creation (zone_records, zone_records_typed) * set explicit type set on table creation (zones) * refactored select/3: using ETS match spec converted to Mnesia's match_object pattern
* using different pattern in erldns_zone_cache:zone_names_and_versions/0 depending on backend (ETS/Mnesia foldl/3 return values are different) * debug artefacts cleanup
Thanks for the fix, I was just testing it: Config:
All of the calls seem to work properly from the shell, however I have issues when trying to query using dig:
I haven't edited the example.zone.json at all Also if I comment out the mnesia storage from the config then dig is working properly:
|
The issue is 1> erldns_zone_cache:get_records_by_name(<<"example.com">>).
[] JSON: 1> erldns_zone_cache:get_records_by_name(<<"example.com">>).
[{dns_rr,<<"example.com">>,1,1,3600,
{dns_rrdata_a,{1,2,3,4}}},
{dns_rr,<<"example.com">>,1,2,3600,
{dns_rrdata_ns,<<"ns1.example.com">>}},
{dns_rr,<<"example.com">>,1,2,3600,
{dns_rrdata_ns,<<"ns2.example.com">>}},
{dns_rr,<<"example.com">>,1,6,3600,
{dns_rrdata_soa,<<"ns1.example.com">>,
<<"admin.example.com">>,2013022001,86400,7200,604800,300}},
{dns_rr,<<"example.com">>,1,15,3600,
{dns_rrdata_mx,10,<<"mail.example.com">>}},
{dns_rr,<<"example.com">>,1,16,3600,
{dns_rrdata_txt,[<<"Hi, this is some text">>]}},
{dns_rr,<<"example.com">>,1,28,3600,
{dns_rrdata_aaaa,{8193,1704,0,1,528,19455,65099,19553}}},
{dns_rr,<<"example.com">>,1,257,3600,
{dns_rrdata_caa,0,<<"issue">>,<<"example.net">>}}] |
Here is a fix that works at least: -spec get_records_by_name(dns:dname()) -> [dns:rr()].
get_records_by_name(Name) ->
case find_zone_in_cache(Name) of
{ok, Zone} ->
case erldns_config:storage_type() of
erldns_storage_json ->
case erldns_storage:select(zone_records, {erldns:normalize_name(Zone#zone.name), erldns:normalize_name(Name)}) of
[] -> [];
[{_, Records}] -> Records
end;
erldns_storage_mnesia ->
lists:filter(fun(#dns_rr{name = RecordName}) ->
RecordName =:= erldns:normalize_name(Name)
end, get_zone_records(erldns:normalize_name(Zone#zone.name)))
end;
_ ->
[]
end. |
erldns_storage:select/3 vs select/2 * added flattening returned from the select/3
Hello @nisbus, thank you for flagging this up. You're correct - get_records_by_name/1 with Mnesia backend is failing due to hitting select/2 in erldns_storage_mnesia which in turn just does mnesia:read/2 and will fail on calls with FQDN lookups. Check: 3ccdcff - it does address this scenario and allows for proper execution of erldns_zone_cache:zone_records_by_name/1 against Mnesia and ETS' backends. |
looks good to me, everything seems to be working now |
@nisbus: Great to hear - all changes merged to master now. |
Mnesia related changes addressing #102.
Addressing Mnesia backend failing on erldns_zone_cache functions: