Skip to content
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

:nxdomain when using redis cluster endpoint with large number of shards #126

Open
aniaptebsft opened this issue Jan 22, 2021 · 0 comments
Open

Comments

@aniaptebsft
Copy link

This is with eredis_cluster ~> 0.5.12

When using eredis pointing to a redis cluster endpoint with large number of shards, I get error :nxdomain. The only workaround is to use a list of ip addresses.

It is because, :inet.getaddr/2 unable to handle dns lookups that result in a large answers. Note however that :inet_res.gethostbyname/1 works fine likely because it reissues the dns lookup over TCP when it finds that the first query had the truncate bit set.

Offending code here: https://github.com/wooga/eredis/blob/master/src/eredis_client.erl#L335 (line 335, and line 307)

Below is a sample iex output that shows the error
Note the :nxdomain error in the second command, same hostname works fine in the fourth command.


iex(tango@2e76e9718be1)69> :inet.getaddr('small-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com', :inet)   
{:ok, {10, 99, 17, 14}}

iex(tango@2e76e9718be1)70> :inet.getaddr('large-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com', :inet)         
{:error, :nxdomain}

iex(tango@2e76e9718be1)71> :inet_res.gethostbyname('small-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com')
{:ok,
 {:hostent,
  'small-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com', [],
  :inet, 4,
  [
    {10, 99, 23, 178},
    {10, 99, 31, 149},
    {10, 99, 22, 232},
    {10, 99, 6, 27},
    {10, 99, 17, 14},
    {10, 99, 1, 221},
    {10, 99, 2, 67},
    {10, 99, 1, 59}
  ]}}
  
iex(tango@2e76e9718be1)72> :inet_res.gethostbyname('large-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com')      
{:ok,
 {:hostent, 'large-redis-cluster.kk5zzw.clustercfg.use1.cache.amazonaws.com', [],
  :inet, 4,
  [
    {10, 99, 59, 135},
    {10, 99, 57, 16},
    {10, 99, 59, 160},
    {10, 99, 56, 194},
    {10, 99, 56, 232},
    {10, 99, 57, 166},
    {10, 99, 57, 110},
    {10, 99, 60, 8},
    {10, 99, 57, 71},
    {10, 99, 59, 89},
    {10, 99, 57, 36},
    {10, 99, 59, 202},
    {10, 99, 56, 205},
    {10, 99, 57, 149},
    {10, 99, 59, 14},
    {10, 99, 59, 230},
    {10, 99, 61, 124},
    {10, 99, 61, 224},
    {10, 99, 60, 182},
    {10, 99, 60, 109}
  ]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant