openresty / openresty/lua-resty-lrucache

Runtime error: table index is nil

Open
#44 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
461
Forks
114
PR merge metrics
No merged PRs in 30d

Description

The following error is visible in nginx logs when trying to set value in lrucache:

*10 lua entry thread aborted: runtime error: /usr/share/lua/5.1/resty/lrucache.lua:223: table index is nil

Code leading to the error:

  access_by_lua_block {

    local lrucache = require "resty.lrucache"
    local cache, cache_init_err = lrucache.new(10)

    if not cache or cache_init_err then
        log(ERROR, "Failed to create cache. Reason: " .. (cache_init_err or "unknown"))
    else
        cache:set("dog", 32)
    end
  }

lua-resty-lrucache ver.: 0.08

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with resty/lrucache.lua at line 223 and trace the cache:set("dog", 32) call from the reported access_by_lua_block. Reproduce the failure with lua-resty-lrucache 0.08 and determine what causes the nil table index; done means the example no longer raises the reported runtime error and the relevant behavior is covered by the project’s tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.