mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 16:46:28 +00:00
fix: flushing and fsync()ing the log file
When not flushing and fsync()ing it the output may be garbled due to concurrent writes to the file (system() spawns a child process with stdin/stdout/stderr inherited from it's parent)
This commit is contained in:
13
repmgrd.c
13
repmgrd.c
@@ -1031,6 +1031,13 @@ do_failover(void)
|
|||||||
log_info(_("%s: This node is the best candidate to be the new primary, promoting...\n"),
|
log_info(_("%s: This node is the best candidate to be the new primary, promoting...\n"),
|
||||||
progname);
|
progname);
|
||||||
log_debug(_("promote command is: \"%s\"\n"), local_options.promote_command);
|
log_debug(_("promote command is: \"%s\"\n"), local_options.promote_command);
|
||||||
|
|
||||||
|
if (log_type == REPMGR_STDERR && *local_options.logfile)
|
||||||
|
{
|
||||||
|
fflush(stderr);
|
||||||
|
fsync(fileno(stderr));
|
||||||
|
}
|
||||||
|
|
||||||
r = system(local_options.promote_command);
|
r = system(local_options.promote_command);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
{
|
{
|
||||||
@@ -1051,6 +1058,12 @@ do_failover(void)
|
|||||||
* New Primary need some time to be promoted.
|
* New Primary need some time to be promoted.
|
||||||
* The follow command should take care of that.
|
* The follow command should take care of that.
|
||||||
*/
|
*/
|
||||||
|
if (log_type == REPMGR_STDERR && *local_options.logfile)
|
||||||
|
{
|
||||||
|
fflush(stderr);
|
||||||
|
fsync(fileno(stderr));
|
||||||
|
}
|
||||||
|
|
||||||
r = system(local_options.follow_command);
|
r = system(local_options.follow_command);
|
||||||
if (r != 0)
|
if (r != 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user