juspay / services-flake

NixOS-like services for Nix flakes
https://community.flake.parts/services-flake
MIT License
390 stars 31 forks source link

process-compose gets stuck on quit if clickhouse init db fails #361

Closed conscious-puppet closed 1 week ago

conscious-puppet commented 1 month ago

process-compose gets stuck on quit if the the clickhouse init db service fails. we need to manually kill the clickhouse process.

the issue can be reproduced by using a malformed initial db dump with the clickhouse service.

asciicast

shivaraj-bh commented 1 month ago

Here’s the culprit: https://github.com/juspay/services-flake/blob/deaa2b81d07d2e7ec2ee74e91e17020d31bf3cb7/nix/services/clickhouse/default.nix#L120-L125

During init the server starts and because the schema files have errors, and exits with non-zero exit-code, the script stops before killing the server.

shivaraj-bh commented 1 month ago

The easiest fix is to run the shell script without breaking on errors in any intermediate command.

But, I would like to see if we can just avoid starting the clickhouse-server in the init script, by just waiting for the server process to start and then init the schemas.

pinging @roman-bodavskiy to see if you have any opinion on this as you worked on this in https://github.com/juspay/services-flake/pull/91