<div dir="ltr"><div>Hi,</div><div><br></div><div><b><font size="4" color="#000000" style="background-color:rgb(255,255,0)">using postgresql 9.3.1 and pgpool 3.42</font></b></div><div><br></div><div>I try to write failover &amp; failback mechanism using pgpool attach/detach pcp command.</div><div>but sometimes I had noticed that the argument send to the failback script are wrong (new primary hostname is not right):</div><div><br></div><div><br></div><div># <b>psql -U postgres -h 192.168.15.59 -p 9999 template1 -c &quot;show pool_nodes;&quot;</b></div><div>Password for user postgres:</div><div> node_id |   hostname    | port | status | lb_weight |  role</div><div>---------+---------------+------+--------+-----------+---------</div><div> 0       | 192.168.15.55 | 5432 | 2      | 0.500000  | standby</div><div> 1       | 192.168.15.56 | 5432 | 2      | 0.500000  | primary</div><div>(2 rows)</div><div><br></div><div><br></div><div><div>#<b> pcp_detach_node -d 10 192.168.15.59 9898 user password 0</b></div><div>DEBUG: send: tos=&quot;R&quot;, len=44</div><div>DEBUG: recv: tos=&quot;r&quot;, len=21, data=AuthenticationOK</div><div>DEBUG: send: tos=&quot;D&quot;, len=6</div><div>DEBUG: recv: tos=&quot;d&quot;, len=20, data=CommandComplete</div><div>DEBUG: send: tos=&quot;X&quot;, len=4</div></div><div><br></div><div><br></div><div>[root@mgrdb-56 etc]# <b>psql -U postgres -h 192.168.15.59 -p 9999 template1 -c &quot;show pool_nodes;&quot;</b></div><div>Password for user postgres:</div><div> node_id |   hostname    | port | status | lb_weight |  role</div><div>---------+---------------+------+--------+-----------+---------</div><div> 0       | 192.168.15.55 | 5432 | 3      | 0.500000  | standby</div><div> 1       | 192.168.15.56 | 5432 | 2      | 0.500000  | primary</div><div>(2 rows)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div># <b>pcp_attach_node -d 10 192.168.15.59 9898 user password 0</b></div><div>DEBUG: send: tos=&quot;R&quot;, len=44</div><div>DEBUG: recv: tos=&quot;r&quot;, len=21, data=AuthenticationOK</div><div>DEBUG: send: tos=&quot;D&quot;, len=6</div><div>DEBUG: recv: tos=&quot;c&quot;, len=20, data=CommandComplete</div><div>DEBUG: send: tos=&quot;X&quot;, len=4</div></div><div><br></div><div><br></div><div><br></div><div><u>failback.sh script is being executed:</u></div><div><b>from pgpool.conf:</b></div><div><i>failback_command=&#39;/etc/pgpool-II/recovery/failback.sh %d %h %H %m %M %D %R %r&#39;</i><br></div><div><br></div><div><b>from failback.sh:</b></div><div><div><font color="#000000"><i>NODE_ID=$1</i></font></div><div><i><font color="#6aa84f"><b>HOST_NAME</b>=$2</font></i></div><div><i><font color="#6aa84f"><b>NEW_MASTER_HOSTNAME</b>=$3</font></i></div><div><font color="#000000"><i>NEW_MASTER_NODE_ID=$4</i></font></div><div><font color="#000000"><i>OLD_MASTER_NODE_ID=$5</i></font></div><div><font color="#000000"><i>DATABASE_CLUSTER_PATH=$6</i></font></div><div><font color="#000000"><i>MASTER_CLUSTER_PATH=$7</i></font></div><div><font color="#000000"><i>NEW_MASTER_PORT=$8</i></font></div></div><div><font color="#000000"><i><br></i></font></div><div><div><font color="#000000" size="1"><i>function log()</i></font></div><div><font color="#000000" size="1"><i>{</i></font></div><div><font color="#000000" size="1"><i>###log error messages###</i></font></div><div><font color="#000000" size="1"><i>[ ! &quot;$1&quot; ] &amp;&amp; return 0</i></font></div><div><font color="#000000" size="1"><i>/bin/echo &quot;[$(/bin/date +%m/%d/%y\ %H:%M:%S.%2N)] - $1&quot; &gt;&gt; $PGHOME/failback.log</i></font></div><div><font color="#000000" size="1"><i>}</i></font></div><div><font color="#000000"><i><br></i></font></div><div><font color="#000000"><i>log &quot;&quot;</i></font></div><div><font color="#000000"><i>log &quot;--- failback of $HOST_NAME ---&quot;</i></font></div><div><font color="#000000"><i>log &quot;&quot;</i></font></div><div><font color="#000000"><i>log &quot;node_id: $NODE_ID&quot;</i></font></div><div><font color="#000000"><i><b>log &quot;hostname: $HOST_NAME&quot;</b></i></font></div><div><font color="#000000"><i><b>log &quot;hostname of new master: $NEW_MASTER_HOSTNAME&quot;</b></i></font></div><div><font color="#000000"><i>log &quot;new master node id: $NEW_MASTER_NODE_ID&quot;</i></font></div><div><font color="#000000"><i>log &quot;old master node id: $OLD_MASTER_NODE_ID&quot;</i></font></div><div><font color="#000000"><i>log &quot;database cluster path: $DATABASE_CLUSTER_PATH&quot;</i></font></div><div><font color="#000000"><i>log &quot;master database cluster path: $MASTER_CLUSTER_PATH&quot;</i></font></div><div><font color="#000000"><i>log &quot;master port: $NEW_MASTER_PORT&quot;</i></font></div><div><font color="#000000"><i>for i in $*; do</i></font></div><div><font color="#000000"><i>  log &quot;$i&quot;</i></font></div><div><font color="#000000"><i>done</i></font></div><div><font color="#000000"><i>exit 0</i></font></div></div><div><br></div><div><br></div><div><br></div><div><b>and the log outputs:</b></div><div><i><br></i></div><div><div><i>[11/09/15 19:02:00.66] - --- failback of 192.168.15.55 ---</i></div><div><i>[11/09/15 19:02:00.66] - node_id: 0</i></div><div><i>[11/09/15 19:02:00.67] - <b>hostname: 192.168.15.55</b></i></div><div><i>[11/09/15 19:02:00.67] -<b> <font color="#cc0000">hostname of new master: 192.168.15.55</font></b></i></div><div><i>[11/09/15 19:02:00.67] - new master node id: 0</i></div><div><i>[11/09/15 19:02:00.67] - old master node id: 1</i></div><div><i>[11/09/15 19:02:00.67] - database cluster path: /home/postgres/databases/fabrix</i></div><div><i>[11/09/15 19:02:00.68] - master database cluster path: /home/postgres/databases/fabrix</i></div><div><i>[11/09/15 19:02:00.68] - master port: 5432</i></div><div><i>[11/09/15 19:02:00.68] - 0</i></div><div><i>[11/09/15 19:02:00.68] - 192.168.15.55</i></div><div><i>[11/09/15 19:02:00.68] - 192.168.15.55</i></div><div><i>[11/09/15 19:02:00.69] - 0</i></div><div><i>[11/09/15 19:02:00.69] - 1</i></div><div><i>[11/09/15 19:02:00.69] - /home/postgres/databases/fabrix</i></div><div><i>[11/09/15 19:02:00.69] - /home/postgres/databases/fabrix</i></div><div><i>[11/09/15 19:02:00.69] - 5432</i></div></div><div><br></div><div><br></div><div><br></div><div>as you can tell the new master us not 192.168.15.55 , should be 192.168.15.56.</div><div><br></div><div><br></div><div>Please advice,</div><div><br></div><div>cohavisi</div></div>