lemonldap-ng issueshttps://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/-/issues2022-01-14T16:27:46Zhttps://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/-/issues/2633Add graceful reload to llng-fastcgi-server2022-01-14T16:27:46ZMaxime BessonAdd graceful reload to llng-fastcgi-server### Summary
We should add a hot-reload feature to llng-fastcgi-server for users who don't want to install uwsgi
### Design proposition
Not easy to do: plackup -s FCGI does not gracefully stop, so Server::Starter can't help us### Summary
We should add a hot-reload feature to llng-fastcgi-server for users who don't want to install uwsgi
### Design proposition
Not easy to do: plackup -s FCGI does not gracefully stop, so Server::Starter can't help us3.0.0Maxime BessonMaxime Bessonhttps://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/-/issues/3122Random DB errors when using llng-fastcgi-server in foreground mode2024-03-27T09:37:24ZMaxime BessonRandom DB errors when using llng-fastcgi-server in foreground mode### Affected version
Version: 2.18.2
Platform: FastCGI server with the coudot/lemonldap-ng docker image
### Summary
* I have customized the coudot/lemonldap-ng image to use CDBI with a mariadb server
* I encounter difficult to predic...### Affected version
Version: 2.18.2
Platform: FastCGI server with the coudot/lemonldap-ng docker image
### Summary
* I have customized the coudot/lemonldap-ng image to use CDBI with a mariadb server
* I encounter difficult to predict DB errors
* Errors can be easily triggered with high load and a disabled configuration cache
### Logs
Some of the errors that pop up:
```
DBD::mysql::db selectrow_array failed: Unknown or undefined error code
...
DBD::mysql::db selectrow_arrayref failed: fetch() without execute()
```
### Root cause
llng-fastcgi-server instanciates a handler[](https://gitlab.ow2.org/lemonldap-ng/lemonldap-ng/-/blob/v2.18.2/fastcgi-server/sbin/llng-fastcgi-server?ref_type=tags#L121) during startup.
This is needed to have shared status (apparently). But this action causes DBI to cache a connection to the database.
This connection cache is preserved after the process are forked by
* Plack startup (only when --foreground is not set)
* The FastCGI process manager (NPROC worker processes)
During the plack startup fork, the parent process exists, which runs DBI cleanup and closes the file descriptor, therefore invalidating the cache in other processes.
When --foreground is set, the file descriptor remains open and is reused until:
* That shared connection is closed by the SQL server
* One of the process terminates
### Possible fixes
Either:
* Revert 019f1e75e829ec9fdfc34d23e2874398a5cba8f0 and find another way to share the status server
* Find another way to have working docker logs without --foreground, and remove this option
* Fork llng-fastcgi-server one more time before handing control to Plack2.20.0Maxime BessonMaxime Besson