pgpool2.git / summary / log / commit / refs
commit b377b1d3ea04046f38f836bd4eebfce1cb782c82
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Mon Sep 18 04:15:56 2023 +0000
Fix race condition with pgpool main and pcp child process.
When pcp child process is forked off, pgpool main process unblock all
signals. This could lead to a race condition if a signal is sent to
the pcp process before it sets up signal handlers. Fix is, do not
unblock signals until the signal handlers are set up.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-September/004398.html
src/main/pgpool_main.c | 1 -
src/pcp_con/pcp_child.c | 7 ++++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index 5200daa98..598a9e539 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -812,7 +812,6 @@ pcp_fork_a_child(int *fds, char *pcp_conf_file)
close(pipe_fds[1]);
/* call PCP child main */
- POOL_SETMASK(&UnBlockSig);
health_check_timer_expired = 0;
reload_config_request = 0;
pcp_main(fds);
diff --git a/src/pcp_con/pcp_child.c b/src/pcp_con/pcp_child.c
index b1d921141..f06c9ed1e 100644
--- a/src/pcp_con/pcp_child.c
+++ b/src/pcp_con/pcp_child.c
@@ -5,7 +5,7 @@
* pgpool: a language independent connection pool server for PostgreSQL
* written by Tatsuo Ishii
*
- * Copyright (c) 2003-2022 PgPool Global Development Group
+ * Copyright (c) 2003-2023 PgPool Global Development Group
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby
@@ -154,6 +154,11 @@ pcp_main(int *fds)
/* We can now handle ereport(ERROR) */
PG_exception_stack = &local_sigjmp_buf;
+ /*
+ * Unblock signals
+ */
+ POOL_SETMASK(&UnBlockSig);
+
ereport(DEBUG1,
(errmsg("I am PCP child with pid:%d", getpid())));
[parent: 2ee501190928]