Unverified Commit c9466b24 authored by Wang Yuan's avatar Wang Yuan Committed by GitHub
Browse files

Remove unnecessary `fsync` when sentinel flushs config file (#11910)

`rewriteConfig` already calls `fsync` to make sure changes are committed to disk.
so it is no need to call `fsync` again here.
this was added here when rewriteConfigOverwriteFile used the ftruncate approach and didn't fsync
parent d6910983
...@@ -2272,12 +2272,8 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) { ...@@ -2272,12 +2272,8 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
/* This function uses the config rewriting Redis engine in order to persist /* This function uses the config rewriting Redis engine in order to persist
* the state of the Sentinel in the current configuration file. * the state of the Sentinel in the current configuration file.
* *
* Before returning the function calls fsync() against the generated
* configuration file to make sure changes are committed to disk.
*
* On failure the function logs a warning on the Redis log. */ * On failure the function logs a warning on the Redis log. */
int sentinelFlushConfig(void) { int sentinelFlushConfig(void) {
int fd = -1;
int saved_hz = server.hz; int saved_hz = server.hz;
int rewrite_status; int rewrite_status;
...@@ -2285,17 +2281,13 @@ int sentinelFlushConfig(void) { ...@@ -2285,17 +2281,13 @@ int sentinelFlushConfig(void) {
rewrite_status = rewriteConfig(server.configfile, 0); rewrite_status = rewriteConfig(server.configfile, 0);
server.hz = saved_hz; server.hz = saved_hz;
if (rewrite_status == -1) goto werr; if (rewrite_status == -1) {
if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr; serverLog(LL_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
if (fsync(fd) == -1) goto werr; return C_ERR;
if (close(fd) == EOF) goto werr; } else {
serverLog(LL_NOTICE,"Sentinel new configuration saved on disk"); serverLog(LL_NOTICE,"Sentinel new configuration saved on disk");
return C_OK; return C_OK;
}
werr:
serverLog(LL_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
if (fd != -1) close(fd);
return C_ERR;
} }
/* Call sentinelFlushConfig() produce a success/error reply to the /* Call sentinelFlushConfig() produce a success/error reply to the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment