Skip to content

Commit

Permalink
Not allow modify dir while a child process is running
Browse files Browse the repository at this point in the history
If a forked child process is running, modifying dir is not allowed.

I can think of two problems at present:
1. If dir is modified during aof rewrite, we will leave the tmp files
on the disk. Because the rename operation of the main process in
backgroundRewriteDoneHandler will fail. Of course, we can stop aof
rewrite when modifying dir, and restart aof rewrite after the modiry.

2. Both the parent and child processes may call serverLog to write
logs, and modifying dir will cause the child process to write logs
in the old dir and the parent process to write logs in the new dir.
Because they fopen the file every time they call serverLog. (PS. we
may need to change it to open only once in the future).

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Aug 11, 2024
1 parent 7424620 commit e6c0621
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2709,6 +2709,10 @@ static int setConfigDirOption(standardConfig *config, sds *argv, int argc, const
*err = "dir can't be empty";
return 0;
}
if (hasActiveChildProcess()) {
*err = "it is unsafe to modify dir when a child process is running";
return 0;
}
if (chdir(argv[0]) == -1) {
*err = strerror(errno);
return 0;
Expand Down

0 comments on commit e6c0621

Please sign in to comment.