yowenter commented on issue #7715:
URL: https://github.com/apache/apisix/issues/7715#issuecomment-1347780375

   
   > Since you can reproduce consistently, it would be great if you could 
provide minimal reproduction use cases.
   It's not consistenly that we can reproduce.   we used apisix helm chart 
appVersion 2.15.1 , verison 0.11.3.
   we can only reproduce it  by accidently. 
   
   there are some facts we can ensure:
   1. once we change the etcd address to ip, there will be no probelm.
   2. if we add  `  log.error("select random answer: ", idx, " from answers: 
",json.delay_encode(answers)) ` in client.lua file, the probablity is 
decreasing significantly.
   ```
   
   function _M.resolve(self, domain, selector)
       local client = self.client
   
       -- this function will dereference the CNAME records
       local answers, err = client.resolve(domain)
       if not answers then
           return nil, "failed to query the DNS server: " .. err
       end
       -- log.error("resolve ", domain,  " answers: 
",json.delay_encode(answers),". ")
   
       if answers.errcode then
           return nil, "server returned error code: " .. answers.errcode
                       .. ": " .. answers.errstr
       end
   
       -- log.error("resolver use selector:", selector)
       if selector == _M.RETURN_ALL then
           log.error("dns resolve ", domain, ", result: ", 
json.delay_encode(answers))
           for _, answer in ipairs(answers) do
               if answer.type == client.TYPE_SRV then
                   return resolve_srv(client, answers)
               end
           end
           return table.deepcopy(answers)
       end
   
       local idx = math_random(1, #answers)
       local answer = answers[idx]
       log.error("select random answer: ", idx, " from answers: 
",json.delay_encode(answers))
       local dns_type = answer.type
       if dns_type == client.TYPE_A or dns_type == client.TYPE_AAAA then
           -- log.error("dns resolve ", domain, ", result: ", 
json.delay_encode(answer))
           return table.deepcopy(answer)
       end
   
       return nil, "unsupported DNS answer"
   end
   ```
   
   
   > Or you could track `local function resolve(qname, r_opts, dnsCacheOnly, 
try_list)` in `/usr/local/apisix/deps/share/lua/5.1/resty/dns/client.lua 
L1069~L1240`
   I may try this later.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to