You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/10/29 07:03:55 UTC

[GitHub] [apisix] Marco-Zheng opened a new issue #5365: bug: Lru Cache Problem in traffic-split

Marco-Zheng opened a new issue #5365:
URL: https://github.com/apache/apisix/issues/5365


   ### Issue description
   
   When i set cache in _M.init() by using timer , it was successfuly, but get nil in _M.access() function, see details as below Steps
   
   ### Environment
   
   - apisix version (cmd: `apisix version`): 2.6
   
   ### Steps to reproduce
   
   Here is my extension code to timely fetch some data from etcd in  traffic-split plugin
   ```
   OIDC_CACHE_TTL
   local version_control_lrucache = lru_new(1024 * 4)
   
   
   local function traffic_info_fetch_per_env(profile_active)
       local key = "/version_control/"..profile_active
       local res, err = core.etcd.get(key)
       if not res or res.status ~= 200 then
           --core.log.error("failed to get global rule[", key, "]: ", err)
           return
       end
       local version_control = res.body.node.value
       version_control_lrucache:set("version_control:"..profile_active, version_control, OIDC_CACHE_TTL)
       core.log.error("push complte")
   end
   
   local function traffic_info_fetch()
       core.log.error("start traffic info pull")
       local profile_actives = {"dev", "uat", "pre", "prod"}
       for _, profile_active in ipairs(profile_actives) do
           traffic_info_fetch_per_env(profile_active)
       end
   end
   
   function _M.init()
       timers.register_timer("plugin#traffic-split", traffic_info_fetch, true)
   end
   
   function _M.destroy()
       timers.unregister_timer("plugin#traffic-split", true)
   end
   ```
   Then i add below code in _M.acccess() function in order to get the data from cache
   ```
   local version_control = version_control_lrucache:get("version_control:uat")
   ```
   But the weird thing is that my cache settings are successful , when I fetch data from cache, it was nil
   My `lua_code_cache` is `open`
   
   ![image](https://user-images.githubusercontent.com/52538259/139390553-7027ed92-3a7e-4af8-80fd-fa124a79dc71.png)
   
   
   ### Actual result
   
   cache get is nil
   
   ### Error log
   
   No error log
   
   ### Expected result
   
   get the cache what i set in


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Marco-Zheng commented on issue #5365: bug: Lru Cache Problem in traffic-split

Posted by GitBox <gi...@apache.org>.
Marco-Zheng commented on issue #5365:
URL: https://github.com/apache/apisix/issues/5365#issuecomment-954512912


   It seems that the memory is not shared between different processes caused, if apisix has something memory shared cache utils(like lua_shared_dict)


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] Marco-Zheng commented on issue #5365: bug: Lru Cache Problem in traffic-split

Posted by GitBox <gi...@apache.org>.
Marco-Zheng commented on issue #5365:
URL: https://github.com/apache/apisix/issues/5365#issuecomment-954560770


   seems using lua_shared_dict can resolve this problem


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass closed issue #5365: bug: Lru Cache Problem in traffic-split

Posted by GitBox <gi...@apache.org>.
tzssangglass closed issue #5365:
URL: https://github.com/apache/apisix/issues/5365


   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tzssangglass commented on issue #5365: bug: Lru Cache Problem in traffic-split

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #5365:
URL: https://github.com/apache/apisix/issues/5365#issuecomment-954611680


   I'm turning this issue into a discussion because it's not the code for the project.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org