The first few log message are logged with the role letter "C", meaning child process. After a few lines, this changes to "M" = primary. Example:
24881:C 21 Oct 2024 21:10:57.165 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo
24881:C 21 Oct 2024 21:10:57.165 * Valkey version=255.255.255, bits=64, commit=814e0f55, modified=1, pid=24881, just started
24881:C 21 Oct 2024 21:10:57.165 * Configuration loaded
24881:M 21 Oct 2024 21:10:57.167 * Increased maximum number of open files to 10032 (it was originally set to 1024).
Expected behaviour: The server starts up as primary and logs the first lines with "M".
The reason we see "C" now is because server.pid has not yet been initialized when these lines are logged. The logging function checks if server.pid == getpid().
Currently, server.pid = getpid() is done in initServer() but it would be better to do it before the first logging happens, in main() before we load config files. This is a simple fix.
The first few log message are logged with the role letter "C", meaning child process. After a few lines, this changes to "M" = primary. Example:
Expected behaviour: The server starts up as primary and logs the first lines with "M".
The reason we see "C" now is because
server.pid
has not yet been initialized when these lines are logged. The logging function checks ifserver.pid == getpid()
.Currently,
server.pid = getpid()
is done ininitServer()
but it would be better to do it before the first logging happens, inmain()
before we load config files. This is a simple fix.Discussion from https://github.com/valkey-io/valkey/issues/1022.