qwzhou89 opened a new issue, #9878:
URL: https://github.com/apache/apisix/issues/9878

   ### Current Behavior
   
   When I put the code to register a new variable inside my_hook.lua and 
execute apisix reload, an error is output inside the logs
   
   ### Expected Behavior
   
   There should be no mistakes.
   
   ### Error Logs
   
   2023/07/21 06:53:10 [error] 1#1: init_by_lua error: 
/usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed 
when some regexs have already been compiled and cached
   stack traceback:
        [C]: in function 'error'
        /usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
        /usr/local/apisix/apisix/init.lua:21: in main chunk
        [C]: in function 'require'
        init_by_lua:4: in main chunk
   
   ### Steps to Reproduce
   
   1.Run APISIX 2.15.3 in docker.
   2.Modify 3 of the lines in conf/config-default.yaml as follows:
   ```shell
     extra_lua_path: "/usr/local/apisix/conf/hook/?.lua"                # 
extend lua_package_path to load third party code
     extra_lua_cpath: ""               # extend lua_package_cpath to load third 
party code
     lua_module_hook: "my_hook"  # the hook module which will be used to inject 
third party code into APISIX
   ``` 
   3.Create a new /usr/local/apisix/conf/hook/my_hook.lua file and insert the 
following contents
   (this is copied from 
https://apisix.apache.org/docs/apisix/next/plugin-develop/#register-custom-variable)
   ```lua
   local core = require "apisix.core"
   
   core.ctx.register_var("a6_labels_zone", function(ctx)
       local route = ctx.matched_route and ctx.matched_route.value
       if route and route.labels then
           return route.labels.zone
       end
       return nil
   end)
   ``` 
   4.Execute the `apisix reload` command
   5.In the log there is the following output
   ```
   2023/07/21 07:11:38 [warn] 1#1: "ssl_stapling" ignored, issuer certificate 
not found for certificate "/usr/local/apisix/conf/cert/ssl_PLACE_HOLDER.crt"
   2023/07/21 07:11:38 [error] 1#1: init_by_lua error: 
/usr/local/apisix/apisix/init.lua:21: changing jit stack size is not allowed 
when some regexs have already been compiled and cached
   stack traceback:
        [C]: in function 'error'
        /usr/local/openresty/lualib/ngx/re.lua:297: in function 'opt'
        /usr/local/apisix/apisix/init.lua:21: in main chunk
        [C]: in function 'require'
        init_by_lua:4: in main chunk
   
   ``` 
   
   ### Environment
   
   - APISIX version (run `apisix version`):2.15.3
   - Operating system (run `uname -a`):Linux k8s-m-3 4.19.225-0419225-generic 
#202201110859 SMP Tue Jan 11 14:15:40 UTC 2022 x86_64 GNU/Linux
   - 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`):
   


-- 
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-unsubscr...@apisix.apache.org.apache.org

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

Reply via email to