<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
  <meta name="Generator" content="Zarafa WebAccess v7.1.10-44973">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Re: [pgpool-general: 2973] pcp_promote_node usecase?</title>
  <style type="text/css">
      body
      {
        font-family: Arial, Verdana, Sans-Serif ! important;
        font-size: 12px;
        padding: 5px 5px 5px 5px;
        margin: 0px;
        border-style: none;
        background-color: #ffffff;
      }

      p, ul, li
      {
        margin-top: 0px;
        margin-bottom: 0px;
      }
  </style>
</head>
<body>
<p><style type="text/css">body { font-family: monospace; }</style>               <style type="text/css">       .bodyclass       {         font-family: Arial, Verdana, Sans-Serif ! important;         font-size: 12px;         padding: 5px 5px 5px 5px;         margin: 0px;         border-style: none;         background-color: #ffffff;       }        p, ul, li       {         margin-top: 0px;         margin-bottom: 0px;       }   </style></p><div><p>Hi Yugo,</p> <p>&nbsp;</p> <p>In my case I use pcp_promote_node to also manage/failover my Postgres master-slave streaming-replication cluster backend nodes.</p> <p>I wrote a small patch to accomplish this:</p> <p>&nbsp;</p> <p>--- main.c.orig 2014-08-06 11:23:28.407919835 +0200</p> <p>+++ main.c&nbsp; 2014-08-06 11:25:34.034290079 +0200</p> <p>@@ -1820,6 +1820,9 @@</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pool_log(&quot;starting promotion. promote host %s(%d)&quot;,</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BACKEND_INFO(node_id).backend_hostname,</p> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BACKEND_INFO(node_id).backend_port);</p> <p>+</p> <p>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trigger_failover_command(PRIMARY_NODE_ID, pool_config-&gt;failover_command,&nbsp;</p> <p>+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MASTER_NODE_ID, node_id, PRIMARY_NODE_ID);</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; }</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; else</p> <p>&nbsp; &nbsp; &nbsp; &nbsp; {</p> <p>&nbsp;</p> <p>This patch is build against pgpool-II-pg93 version 3.3.2 (I&#39;m using the rpm&#39;s from the postgres.org yum repos and patched the source rpm).</p> <p>&nbsp;</p> <p>As you can see it only creates the trigger file on the new master node. My slave is configured as a hot-standby so it&#39;s read-only and needs to be set in the master (read/write) state.</p> <p>&nbsp;</p> <p>So I think it&#39;s nice to include this in a future version of pgpool and make it configurable in pgpool.conf?</p> <p>&nbsp;</p> <p>Kind regards,</p> <p>&nbsp;</p> <p>Joey Loman</p> <p>&nbsp;</p> <p>&gt;&nbsp;</p> <p>&gt; On Thu, Jun 26, 2014 at 4:54 PM, Yugo Nagata &lt;nagata at sraoss.co.jp&gt; wrote:</p> <p>&gt;&nbsp;</p> <p>&gt; Hi all,</p> <p>&gt;&nbsp;</p> <p>&gt; Are you using pcp_promote_node? If so, please tell me your usecase!</p> <p>&gt;&nbsp;</p> <p>&gt; pgpool-II has pcp_promote_node command, which change specified backend</p> <p>&gt; nodes status to &#39;primary&#39;, but this has some problems.</p> <p>&gt; So, if there is no users of pcp_promote_node, we consider to remove</p> <p>&gt; this from pgpool-II. Or not, I want to know usecases and fix</p> <p>&gt; pcp_promote_node to be more usefull and suitable for the usecase.</p> <p>&gt;&nbsp;</p> <p>&gt; The current pcp_promote_node works as below;</p> <p>&gt;&nbsp;</p> <p>&gt; (0) This is enabled only in master-slave / streaming-replication mode.</p> <p>&gt;&nbsp;</p> <p>&gt; (1) This changes pgpool-II&#39;s internal status and set the specified</p> <p>&gt; &nbsp; &nbsp; node to primary. The internal status is used in online-recovery</p> <p>&gt; &nbsp; &nbsp; and loadbalancing etc.. &nbsp;</p> <p>&gt; ** Note that this doesn&#39;t control the backend nodes themselves.**</p> <p>&gt;&nbsp;</p> <p>&gt; (2) All nodes other than the new primary are detached from pgpool-II.</p> <p>&gt;&nbsp;</p> <p>&gt; (3) pgpool-II execute follow_master command for all the detached nodes.</p> <p>&gt; &nbsp; &nbsp; follow_master command is mainly used for auto-recovery of standbys</p> <p>&gt; &nbsp; &nbsp; from the new primary.</p> <p>&gt;&nbsp;</p> <p>&gt; Here, I found the some problems:</p> <p>&gt;&nbsp;</p> <p>&gt; (a) Even when DISALLOW_TO_FAILOVER is used, backends node are detached</p> <p>&gt; &nbsp; &nbsp; at step (2).</p> <p>&gt; (b) If pcp_recovery_node is executed in follow_master command at step (3),&nbsp;</p> <p>&gt; &nbsp; &nbsp; recovery can fail because pgpool-II&#39;s internal status can be different</p> <p>&gt; &nbsp; &nbsp; from the acutual backend status of primary/standby.</p> <p>&gt;&nbsp;</p> <p>&gt; I want to fix about (a), if there is any user of pcp_promote_node.</p> <p>&gt; I think the design would be:</p> <p>&gt;&nbsp; - When DISALLOW_TO_FAILOVER is used, pcp_promote_node is disabled</p> <p>&gt;&nbsp; &nbsp; because this command can detach some backend nodes.</p> <p>&gt;&nbsp; - or, pcp_promote_node change primary node status, but doesn&#39;t detach</p> <p>&gt;&nbsp; &nbsp; any nodes. (In this case, some trick would be required so that&nbsp;</p> <p>&gt;&nbsp; &nbsp; primary node should be unique.)</p> <p>&gt;&nbsp;</p> <p>&gt; About (b), I think this is a restriction of pgpool-II. User have</p> <p>&gt; to note that internal status can be different from the acutual backend</p> <p>&gt; status of primary/standby, after using pcp_promote_node. If you know</p> <p>&gt; other idea, please tell me.</p> <p>&gt;&nbsp;</p> <p>&gt; Any comment and suggestion?</p> <p>&gt;&nbsp;</p> <p>&gt;&nbsp;</p> <p>&gt; Best regards,</p> <p>&gt; --&nbsp;</p> <p>&gt; Yugo Nagata &lt;nagata at sraoss.co.jp&gt;</p></div>
</body>
</html>