Skip to content

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

Open

Description

@yuchao-java

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?

Activity

  1. yuchao-java commented on Jul 2, 2024

    @yuchao-java
    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?

  2. zhuizhuhaomeng commented on Jul 2, 2024

    @zhuizhuhaomeng
    Contributor

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

  3. yuchao-java commented on Jul 3, 2024

    @yuchao-java
    Author

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

  4. yuchao-java commented on Jul 5, 2024

    @yuchao-java
    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!

  5. zhuizhuhaomeng commented on Jul 12, 2024

    @zhuizhuhaomeng
    Contributor

    can't find the attachment @yuchao-java

  6. yuchao-java commented on Jul 15, 2024

    @yuchao-java
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions