Alex Zhang
Alex Zhang
@fankeke 是的。 目前 `resty-sync` 的做法能够完全避免掉这些问题。
@fankeke 你可以仔细看下 `_M.start` 这个函数,我通过在共享内存里设置一个特殊的标记,即用 `LOCK_TIMER_KEY` 作为 key,存放成功启动 sync timer 的 worker 的 id,过期时间为这个 `sync` 实例所设置的 `interval ` + 10,且每次定时器在处理回调的时候,都会更新下这个 key ,以避免过期。 如果某个 worker 进入到这个函数,先第一次抢锁,抢到锁的,首先会判断这个 `LOCK_TIMER_KEY` 对应的值是不是存在,如果不存在,则由这个 worker 抢占到 timer,同时共享内存里的 `LOCK_TIMER_KEY`...
@fankeke 恩,这个 `new` 操作你要放到 init 阶段,可以放在 init 阶段再试试
See the relevant issue: https://github.com/openresty/stream-lua-nginx-module/issues/167 for details.
> So ngx_http_lua_module also needs a patch. OK, I will push a patch to that repo.
> Look like the original `ngx_http_lua_check_broken_connection` is modified from `ngx_http_upstream_check_broken_connection` in 2012. In 2013, Nginx added the `NGX_USE_EPOLL_EVENT` check to fix https://trac.nginx.org/nginx/ticket/320. > However, this code doesn't synchronize the fix....
> @tokers > `ngx_http_lua_check_broken_connection` doesn't have this patch because it is written in 2012, > while this patch is added to `ngx_http_lua_check_broken_connection` in 2013. OK 👌
I have written a patch to solve this problem, I will push it to the meta-lua-nginx-module repo.
> I have written a patch to solve this problem, I will push it to the meta-lua-nginx-module repo. Nonetheless, I don't know why the `ngx_stram_lua_check_broken_connection ` would be triggerd duplicately...
@dndx Any idea about this?