MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / sentinelFlushConfig

Function sentinelFlushConfig

src/sentinel.cpp:2319–2337  ·  view source on GitHub ↗

This function uses the config rewriting Redis engine in order to persist * 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. */

Source from the content-addressed store, hash-verified

2317 *
2318 * On failure the function logs a warning on the Redis log. */
2319void sentinelFlushConfig(void) {
2320 int fd = -1;
2321 int saved_hz = g_pserver->hz;
2322 int rewrite_status;
2323
2324 g_pserver->hz = CONFIG_DEFAULT_HZ;
2325 rewrite_status = rewriteConfig(cserver.configfile, 0);
2326 g_pserver->hz = saved_hz;
2327
2328 if (rewrite_status == -1) goto werr;
2329 if ((fd = open(cserver.configfile,O_RDONLY)) == -1) goto werr;
2330 if (fsync(fd) == -1) goto werr;
2331 if (close(fd) == EOF) goto werr;
2332 return;
2333
2334werr:
2335 serverLog(LL_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
2336 if (fd != -1) close(fd);
2337}
2338
2339/* ====================== hiredis connection handling ======================= */
2340

Callers 8

sentinelIsRunningFunction · 0.85
sentinelConfigSetCommandFunction · 0.85
sentinelCommandFunction · 0.85
sentinelSetCommandFunction · 0.85
sentinelVoteLeaderFunction · 0.85

Calls 2

rewriteConfigFunction · 0.85
serverLogFunction · 0.85

Tested by

no test coverage detected