Kong/kong

Using a Go plugin generates emergency logs at startup and adds a 10-second delay for a graceful stop

Closed this issue · 2 comments

Summary

When I configure Kong to use a Go plugin as an embedded server, Kong generates emergency logs at startup and there is a 10-second delay for a graceful stop.

Steps To Reproduce

The following GitHub repository provides a setup and steps to reproduce the problems:
https://github.com/xxcpas/kong-with-go-plugins

Additional Details & Logs

  • Kong version: 2.3.2
  • Operating system: MacOS 11.2.2

Issues

  1. Why do we see the emergency logs? How critical is it for the good behaviour of Kong?
  2. Why does a graceful stop take 10 seconds?

When Kong starts, it displays the following emergency-level logs at startup

  kong_1 | 2021/03/12 16:09:32 [notice] 26#0: 2 [lua] globalpatches.lua:55: sleep(): executing a blocking 'sleep' (0.002 seconds), context: init_worker_by_lua
  kong_1 | 2021/03/12 16:09:32 [notice] 28#0: 4 [kong] init.lua:370 declarative config loaded from /usr/local/kong/declarative/kong.yml, context: init_worker_by_lua
  kong_1 | 2021/03/12 16:09:32 [notice] 28#0: 4 [kong] init.lua:417 only worker #0 can manage, context: init_worker_by_lua
  kong_1 | 2021/03/12 16:09:32 [notice] 27#0: 3 [kong] init.lua:417 only worker #0 can manage, context: init_worker_by_lua
  kong_1 | 2021/03/12 16:09:32 [notice] 26#0: 2 [kong] init.lua:417 only worker #0 can manage, context: init_worker_by_lua
  kong_1 | 2021/03/12 16:09:32 [notice] 25#0: *9 [kong] process.lua:239 Starting my-plugin, context: ngx.timer
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8000 failed (9: Bad file descriptor)
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8000 failed (9: Bad file descriptor)
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8000 failed (9: Bad file descriptor)
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8443 failed (9: Bad file descriptor)
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8443 failed (9: Bad file descriptor)
  kong_1 | 2021/03/12 16:09:32 [emerg] 25#0: lua pipe child close() socket 0.0.0.0:8443 failed (9: Bad file descriptor)

See also #6904

@xxcpas the emerg logs are caused by openresty/lua-nginx-module#1806, it's fixed in openresty master and will be shipped with kong 2.4.

The long time during graceful stop has been fixed and will be released in kong 2.4 as well.