<div dir="ltr"><div class="gmail_quote">On Fri, Oct 26, 2012 at 10:27 PM, Tatsuo Ishii <span dir="ltr"><<a href="mailto:ishii@postgresql.org" target="_blank">ishii@postgresql.org</a>></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">>> On Fri, Oct 26, 2012 at 6:00 AM, Tatsuo Ishii <<a href="mailto:ishii@postgresql.org">ishii@postgresql.org</a>> wrote:<br>
>><br>
>>> Sorry for late reply.<br>
>>><br>
>>> > Hi,<br>
>>> ><br>
>>> > The docs [1] say that one of the preconditions for load-balancing is<br>
>>> > that<br>
>>> ><br>
>>> > > The query must not be in an explicitly declared transaction (i.e.<br>
>>> not<br>
>>> > in a BEGIN ~ END block)<br>
>>><br>
>>> Yeah, the doc is outdated in this regard.<br>
>>><br>
>>> > But I see that this is not a strict statement. I extracted a specific<br>
>>> > backend process' log lines (generated using log_per_node_statement), and<br>
>>> I<br>
>>> > could see that on line 6, the SELECT query was load-balanced to a replica<br>
>>> > (node id 2) and the next INSERT statement was correctly sent to the<br>
>>> master.<br>
>>> > But any SELECT after that INSERT was not sent to the replica, and only to<br>
>>> > the master.<br>
>>> ><br>
>>> > So can we say that load balancing _does_ occur in an explicitly<br>
>>> > declared transaction, but as soon as a DML operation is perfored, any<br>
>>> > subsequent SELECT queries will be sent only to master.<br>
>>><br>
>>> Yes, that is expected behavior if you are using streaming replication<br>
>>> mode. The reason why SELECTs are sent to master after DML issued is,<br>
>>> standby cannot see the modified rows.<br>
>>><br>
>><br>
>> Can we expect doc changes, or I should probably file a bug-report against<br>
>> documentation so that it gets taken care of in due process.<br>
><br>
> I will propose doc changes.<br>
<br>
</div></div>Included is the patch I promised. There are more to fix than what<br>
discussed though. If you are comfortable with this, I will commit.<br></blockquote><div><br>Looks good to me.<br><br>Best regards,<br></div></div>-- <br><div dir="ltr">Gurjeet Singh<br><br><a href="http://gurjeet.singh.im/" target="_blank">http://gurjeet.singh.im/</a><br>
</div><br>
</div>