steve0511 / resty-redis-cluster

Openresty lua client for redis cluster.
Apache License 2.0
376 stars 134 forks source link

redis cluster connection failure #98

Open fatihbm opened 2 years ago

fatihbm commented 2 years ago

Hi, I have an interesting issue I wanna use the Redis cluster for the high available proxy cache but something is wrong and I couldn't find the reason. I printed an extra error.log for a better understanding of this. You can see this on lines 107 and 111. After doing this, when I open the error.log, I noticed the strange situation that you can see below. The IP and port information are correct in the first six lines, but these are incorrect in the following lines. So the port numbers are right, but the IP addresses somehow change to 127.0.0.1.

Has anyone encountered this before? What is your suggestion for a solution? Ps. The log was generated to only one HTTP request.

rediscluster.lua

image

http error logs;


2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 192.168.55.51:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 192.168.55.52:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 192.168.55.53:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 192.168.55.54:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 192.168.55.55:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 192.168.55.50:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:107: try_hosts_slots(): debug --ccc-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7000, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7003, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7001, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7004, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7002, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
2022/03/03 14:18:32 [] 10106#10106: *276 [lua] rediscluster.lua:111: try_hosts_slots(): debug --iii-- 127.0.0.1:7005, client: 192.168.44.1, server: _, request: "GET / HTTP/1.1", host: "abc.cc"
toredash commented 2 years ago

Could you give us your config?

fatihbm commented 2 years ago

Sorry, I couldn't know how can I do it because I use this with apisix. I don't use any special configuration. Maybe following links give you any ideas.

https://apisix.apache.org/docs/apisix/2.7/plugins/limit-count https://github.com/apache/apisix/blob/d4154bc0a02511f77785a965a4f6285b700997dd/apisix/plugins/limit-count/limit-count-redis-cluster.lua#L41