<div dir="ltr">Hi Ishii-San<div><br></div><div>Thanks for your valuable input on this, I have pushed the patch to the master branch.</div><div>Do we also need to back port to all branches?<br><div class="gmail_extra"><br></div><div class="gmail_extra">Regards</div><div class="gmail_extra">Muhammad Usama</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 7:02 AM, Tatsuo Ishii <span dir="ltr">&lt;<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">&gt; On Fri, Jul 1, 2016 at 10:22 AM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; &gt; On Thu, Jun 30, 2016 at 1:51 PM, Tatsuo Ishii &lt;<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>&gt;<br>
&gt;&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Usama,<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; &gt; Totally agreed on both the points. I think you have a valid point and<br>
&gt;&gt; &gt;&gt; &gt; unconditionally forwarding all the kind = N messages to frontend is<br>
&gt;&gt; the<br>
&gt;&gt; &gt;&gt; &gt; best choice. The attached version 2 of the patch does the same as<br>
&gt;&gt; &gt;&gt; suggested.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;&gt; Thanks for the patch. BTW, I had hard time to test the patch. The<br>
&gt;&gt; &gt;&gt; original problem report was talking about VACUUM case, but in<br>
&gt;&gt; &gt;&gt; streaming replication mode, VACUUM is sent to primary node only and<br>
&gt;&gt; &gt;&gt; kind mismatch error can&#39;t happend with VACUUM command.<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The original bug report listed a case where one of the PostgreSQL server<br>
&gt;&gt; &gt; was throwing a warning message because of transaction wrap around and was<br>
&gt;&gt; &gt; suggesting to perform vacuum. The original query was not a VACUUM<br>
&gt;&gt; command.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;&gt; Any suggestion to trigger kind mismatch errors in streaming<br>
&gt;&gt; &gt;&gt; replication mode?<br>
&gt;&gt; &gt;&gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Yes I ran into similar issue and mimicking the exact reported scenario<br>
&gt;&gt; and<br>
&gt;&gt; &gt; getting the transaction wrap around warning is a very hard to generate.<br>
&gt;&gt; &gt; So I tested the patch by setting the lower value of client_min_messages<br>
&gt;&gt; &gt; variable on one of the backend servers and also set log_statement = &#39;all&#39;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; i.e.<br>
&gt;&gt; &gt; *Backend 1*<br>
&gt;&gt; &gt; log_statement = &#39;all&#39;<br>
&gt;&gt; &gt; client_min_messages = debug2<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; *Backend 2*<br>
&gt;&gt; &gt; log_statement = &#39;all&#39;<br>
&gt;&gt; &gt; client_min_messages = notice<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Doing this ensures that one server will always send a original query as a<br>
&gt;&gt; &gt; log message back to client application. And after that I tested the patch<br>
&gt;&gt; &gt; using SET commands, since they are sent to all attached backends and<br>
&gt;&gt; &gt; because of different client_min_messages backend settings I was getting<br>
&gt;&gt; an<br>
&gt;&gt; &gt; extra log message form backend 1<br>
&gt;&gt;<br>
&gt;&gt; Looks like now NOTICE messages are duplicated according to the number<br>
&gt;&gt; of backends if the SQL command is sent to each backend.<br>
&gt;&gt;<br>
&gt;&gt; Before:<br>
&gt;&gt;<br>
&gt;&gt; test=# begin;<br>
&gt;&gt; LOG:  statement: begin;<br>
&gt;&gt; BEGIN<br>
&gt;&gt;<br>
&gt;&gt; After your patch:<br>
&gt;&gt;<br>
&gt;&gt; test=# begin;<br>
&gt;&gt; LOG:  statement: begin;<br>
&gt;&gt; LOG:  statement: begin;<br>
&gt;&gt; BEGIN<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m not sure if this is a desirable change.<br>
&gt;&gt;<br>
&gt;<br>
&gt; Thanks for pointing this out, This is definitely not intended and happening<br>
&gt; because of the side effect.<br>
&gt; But I have been thinking about this, and couldn&#39;t think of any cleaner<br>
&gt; solution to solve this duplicate notice message. Although I think this is a<br>
&gt; very rare scenario, especially in a production environment to have some<br>
&gt; configurations where PG backend is forwarding the normal log messages to<br>
&gt; front-end client.<br>
&gt; Also, if we have to decide between the current state (producing a kind<br>
&gt; mismatch error) vs this rare occurrence of duplicate LOG on the client<br>
&gt; side, I think we should choose this duplicate log as it is less harmful.<br>
&gt; But Offcource the best thing would be to solve this in a clean and<br>
&gt; efficient way.<br>
<br>
</div></div>Yeah, I couldn&#39;t think of any better solution neither. It&#39;s apparent<br>
that solving the existing kind mismatch error problem is very<br>
important. I agree that we should choose living with duplicate log<br>
messages in rare cases. Let&#39;s leave your patch as it is and<br>
commit/push it.<br>
<br>
Best regards,<br>
<div class="HOEnZb"><div class="h5">--<br>
Tatsuo Ishii<br>
SRA OSS, Inc. Japan<br>
English: <a href="http://www.sraoss.co.jp/index_en.php" rel="noreferrer" target="_blank">http://www.sraoss.co.jp/index_en.php</a><br>
Japanese:<a href="http://www.sraoss.co.jp" rel="noreferrer" target="_blank">http://www.sraoss.co.jp</a><br>
</div></div></blockquote></div><br></div></div></div>