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

red:smembers("key"), sometime not include the new member? #277

Open
yuchao-java opened this issue Jul 2, 2024 · 6 comments
Open

red:smembers("key"), sometime not include the new member? #277

yuchao-java opened this issue Jul 2, 2024 · 6 comments

Comments

@yuchao-java
Copy link

in my kong lua scripts, I write some code in access function like this:
local redis = require "resty.redis"
local red = redis:new()
red:set_timeouts(5000, 5000, 5000)
local ok, err = red:connect(redisHost, redisPort)
local result, err = red:smembers("all_allow_urls")
local ok, keep_err = red:set_keepalive(10000, 100)
at first, the key "all_allow_urls" in redis is a set, which include 10 members, then I execute SADD all_allow_urls 'aaa' in redis-cli cmd;
but when I visit my kong to check the result from red:smembers("all_allow_urls"), it sometimes include "aaa" but sometimes not。
Can you help me?

@yuchao-java
Copy link
Author

the same question, after I execute set key1 value1 in redis-cli cmd,
local result2, err =red:get("key1"), the result2 is userdata: NULL when the red.get_reused_times() > 1, and the result2 is aaa when the red.get_reused_times() == 0.
How to get new data in redis when the data is changed?

@zhuizhuhaomeng
Copy link
Contributor

Use tcpdump to capture the packets.
And then use wireshark to look into this issue.

@yuchao-java
Copy link
Author

yuchao-java commented Jul 3, 2024

Even if rebooting redis and kong doesn't work, the problem remains, do you have some quick solutions? thx

@yuchao-java
Copy link
Author

Use tcpdump to capture the packets. And then use wireshark to look into this issue.

The tcp stream that I captured by using kong to operate redis through lua-resty-redis. For the first time, 44 data are normally obtained in the set whose key is api:all_allow_urls, scard it also displays 44 data, and the content of string whose key is bbb is 0000. When the connection is put back into the connection pool and reused to read again, the set contains only 37 data and the contents of the bbb are empty.
Uploading redis_tcp_stream.log…

See attachment for details, Please!

@zhuizhuhaomeng
Copy link
Contributor

can't find the attachment @yuchao-java

@yuchao-java
Copy link
Author

redis_tcp_stream.log
sorry, maybe something wrong, here

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

2 participants