AlinsRan opened a new pull request, #14186: URL: https://github.com/apache/apisix/pull/14186
### Description When a worker exits abnormally after the master has been running for longer than `worker_startup_time_threshold` (default 60 s), the respawned worker reloads the full configuration from etcd in `init_worker` (`config_etcd.init_worker()` → `init_loaded_configuration()`). That works in the HTTP subsystem, but not in the stream one. The etcd read goes through `resty.http`, whose body reader calls `coroutine.create`, and stream-lua-nginx-module rejects `coroutine.create` in `init_worker_by_lua*`. The error is thrown, not returned. It aborts `stream_init_worker()` before the stream router, plugins and upstreams are initialised: ``` [error] init_worker_by_lua error: .../resty/http.lua:74: API disabled in the context of init_worker_by_lua* ``` From then on, that worker drops every stream connection it accepts, and the process keeps running. With N workers, about 1/N of stream connections fail until APISIX is restarted. HTTP traffic is not affected. The first start is not affected either, because the master reads etcd in `init` and the workers inherit that snapshot through fork. This change keeps the HTTP path as it is. In the stream subsystem, a stale snapshot is now discarded instead of reloaded: `loaded_configuration` and its revision are cleared, and each resource type reads its own directory at first sync. That is the same path already used when nothing was preloaded, so `init_worker` does no etcd I/O there. The new test makes every worker treat the snapshot as stale (`worker_startup_time_threshold: -1`) and sends a stream request. On the old code, the request is reset and the error above is logged. With this change, the request is proxied. No documentation change: this is a bug fix, and configuration and behaviour stay the same apart from the fix. #### Which issue(s) this PR fixes: Fixes # ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [ ] I have updated the documentation to reflect this change - [x] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
