Fix main process exiting while performing finding primary node.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 4 Mar 2022 11:00:41 +0000 (20:00 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 4 Mar 2022 11:15:53 +0000 (20:15 +0900)
commit24a8ffd8db8917554eb78459aff7d3d8063b0c5e
tree6053844bab479ef5fc57cfa89471f36cc613b319
parenteaf648e8f22c42111175d56c658f580369901118
Fix main process exiting while performing finding primary node.

Pgpool-II main process tries to find primary node whenever the cluster
status is changed by failover/failback. While doing it, if a backend
is failing or shutting down, socket write to the backend could
fail. Unfortunately in the case do_query() throws FATAL error, which
makes the Pgpool-II main process die like this.

2022-03-04 18:13:12.711: main pid 795826: WARNING:  write on backend 1 failed with error :"Broken pipe"
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  while trying to write data from offset: 0 wlen: 32
2022-03-04 18:13:12.711: main pid 795826: LOG:  notice_backend_error: called from pgpool main. ignored.
2022-03-04 18:13:12.711: main pid 795826: LOG:  unable to flush data to backend
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  do not failover because I am the main process
2022-03-04 18:13:12.711: main pid 795826: FATAL:  Backend throw an error message
2022-03-04 18:13:12.711: main pid 795826: DETAIL:  Exiting current session because of an error from backend
2022-03-04 18:13:12.711: main pid 795826: HINT:  BACKEND Error: "terminating connection due to administrator command"
2022-03-04 18:13:12.715: main pid 795826: LOG:  shutting down

To prevent it, change ereport(FATAL) to ereport(ERROR) in do_query().
src/protocol/pool_process_query.c