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

bug: config_util.lua:99: attempt to index local 'item' (a boolean value) #9822

Closed
Sn0rt opened this issue Jul 12, 2023 · 2 comments
Closed
Assignees
Labels
bug Something isn't working wait for update wait for the author's response in this issue/PR

Comments

@Sn0rt
Copy link
Contributor

Sn0rt commented Jul 12, 2023

Current Behavior

2023/07/11 10:25:26 [error] 10644#10644: *95142022 [lua] config_etcd.lua:659: failed to fetch data from etcd: /usr/local/apisix/apisix/core/config_util.lua:99: attempt to index local 'item' (a boolean value)
stack traceback:
        /usr/local/apisix/apisix/core/config_util.lua:99: in function 'fire_all_clean_handlers'
        /usr/local/apisix/apisix/core/config_etcd.lua:376: in function 'sync_data'
        /usr/local/apisix/apisix/core/config_etcd.lua:606: in function </usr/local/apisix/apisix/core/config_etcd.lua:596>
        [C]: in function 'xpcall'
        /usr/local/apisix/apisix/core/config_etcd.lua:596: in function </usr/local/apisix/apisix/core/config_etcd.lua:574>,  etcd key: /apisix/routes, context: ngx.timer

Expected Behavior

no error log

Error Logs

No response

Steps to Reproduce

APISIX: 3.2.0
ETCD: 3.5

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@moonming moonming added the bug Something isn't working label Jul 12, 2023
@kingluo
Copy link
Contributor

kingluo commented Jul 12, 2023

This bug is due to the iteration of boolean items.

To avoid moving table (self.values) items frequently, we append the new items only to the table.

self.values[pre_index] = false

When the size of the table exceeds 100, the obsoleted items will be cleared. Before the clear, if the compacted event happens, it will iterate the self.values to invoke all clean handlers, which involves the false item and break the type assertion.

config_util.fire_all_clean_handlers(val)

So the bugfix is to skip the false items.

BTW, in the new watch mechanism, no compacted event happens anymore, because we watch the whole apisix keyspace, not individual watching for each admin resource. So this bug will be not triggered anymore.

@leslie-tsang leslie-tsang added the wait for update wait for the author's response in this issue/PR label Jul 13, 2023
@leslie-tsang leslie-tsang assigned Sn0rt and unassigned lingsamuel Jul 13, 2023
@moonming moonming assigned lingsamuel and unassigned Sn0rt Jul 14, 2023
@lingsamuel
Copy link
Member

should be fixed by #8493 (already in 3.2.1) and #9811

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wait for update wait for the author's response in this issue/PR
Projects
Archived in project
Development

No branches or pull requests

5 participants