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