Kong / kong-pongo

Tooling to run plugin tests with Kong and Kong Enterprise
Apache License 2.0
155 stars 57 forks source link

Null pointer issue with mlcache lru #629

Open DuzzlinAdmin opened 1 month ago

DuzzlinAdmin commented 1 month ago

Context : Changes added to Kong-Pongo for version 3.8.0.0 added a few lines in spec/helpers.lua line 323 which are highlighted below

_G.kong.cache.mlcache.lru = nil collectgarbage()

When mlcache.lru is set to nil we have this issue of cluster_events callback failing [error] 1342#0: *18 [lua] init.lua:270: process_event(): [cluster_events] callback threw an error: /usr/local/share/lua/5.1/kong/resty/mlcache/init.lua:1420: attempt to index field 'lru' (a nil value), context: ngx.timer

Can you please provide reasons on why the above lines were added to helpers.lua and what can be the resolution to this as callbacks are being executed after the function call clear_cache_on_file_end

Tieske commented 1 month ago

@DuzzlinAdmin when do you encounter this error? Always, or specific to your custom plugin, etc.

@chobits this was part of the dns refactor I think. Can you have a look at this issue?

KalshuCodes commented 1 month ago

@Tieske Replying via main account, encountered it during few plugin execution, Happens randomly and mostly after all the tests from 1 file completed execution or between 2 tests, doesn't happen if I remove _G.kong.cache.mlcache.lru = nil from kong-pongo Also tried finding logs no logs are found for this because happens before log is initialized, found out via timestamps

KalshuCodes commented 1 month ago

I checked the logs, Happens when worker calls the poll function which calls to cluster_events process event where callbacks are set and then when callbacks are executed in the below part it gives the error

else
      local ok, err = pcall(cbs[j], row.data)
      if not ok and not ngx_debug then
        log(ERR, "callback threw an error: ", err)
      end
    end
Tieske commented 1 month ago

The issue here is that those files are not owned by Pongo. They are part of the Kong repo's, and only copied into Pongo on a release-tag basis. So any fix should be in the Kong repos.