Workflow for RDB:
1. Executing the bgsave command, the Redis parent process determines whether a child process is currently executing, such as a rdb/aof child process, if there is a bgsave command to return directly.
2. The parent process performs the fork operation to create the child process, and the parent process is blocked during the fork operation.
3. After the parent process fork is finished, the Bgsave command returns the "* Background saving started by PID XXX" message and no longer blocks the parent process and can continue to respond to other commands.
4. The parent process creates an RDB file, generates a temporary snapshot file based on the parent process memory, and then atomically replaces the original file after completion. Depending on the Lastsave command, you can obtain the last time the RDB was generated, corresponding to the rdb_last_save_time in info persistence.
5. The process sends a signal to the parent process for a victory, and the parent process updates the statistics.
The persistence of Redis