<div dir="ltr">Does your application use the JDBC drivers for connection?<div>The JDBC driver has an autocommit option and If the autocommit is set to false, The driver executes the query in an explicit transaction and sends &quot;BEGIN&quot; and &quot;COMMIT&quot; by itself.</div><div><br><div class="gmail_extra">Regards</div><div class="gmail_extra">Muhammad Usama</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 23, 2016 at 5:00 AM, Dan Foster <span dir="ltr">&lt;<a href="mailto:Dan.Foster@bristol.ac.uk" target="_blank">Dan.Foster@bristol.ac.uk</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
I have a 2 node PgPool 3.4.3 set-up with streaming replication (i.e.<br>
replication_mode = off) &amp; load balancing enabled. Some clients get<br>
disconnected and I see the following sort of behaviour in the logs (as<br>
an example):<br>
<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
DB node id: 0 backend pid: 68027 statement: BEGIN<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
DB node id: 1 backend pid: 27748 statement: BEGIN<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
DB node id: 0 backend pid: 68027 statement: CREATE OR REPLACE FUNCTION<br>
create_label() RETURNS TRIGGER AS &#39; BEGIN UPDATE survey_question SET<br>
label = &#39;&#39;b&#39;&#39; || NEW.id WHERE (NEW.label = &#39;&#39;&#39;&#39; OR NEW.label IS NULL)<br>
AND id = NEW.id; RETURN NEW; END &#39; LANGUAGE plpgsql;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: DROP TRIGGER IF EXISTS create_label<br>
ON survey_question;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: CREATE TRIGGER create_label AFTER<br>
INSERT ON survey_question FOR EACH ROW EXECUTE PROCEDURE<br>
create_label();<br>
Mar 22 23:10:17 db-pg-p3 pgpool: CREATE OR REPLACE FUNCTION<br>
update_label() RETURNS TRIGGER AS &#39; BEGIN UPDATE survey_question SET<br>
label = &#39;&#39;b&#39;&#39; || NEW.id WHERE (OLD.label = &#39;&#39;&#39;&#39; OR OLD.label IS NULL)<br>
AND id = OLD.id; RETURN NEW; END &#39; LANGUAGE plpgsql;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: DROP TRIGGER IF EXISTS update_label<br>
ON survey_question;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: CREATE TRIGGER update_label AFTER<br>
UPDATE ON survey_question FOR EACH ROW  EXECUTE PROCEDURE<br>
update_label();<br>
Mar 22 23:10:17 db-pg-p3 pgpool: -- THIS IS A HACK TO REMOVE<br>
content_id constraint for positive integers only<br>
Mar 22 23:10:17 db-pg-p3 pgpool: -- since we need negative numbers for<br>
FGS -1 for core -2 for default (removable)<br>
Mar 22 23:10:17 db-pg-p3 pgpool: ALTER TABLE<br>
permissions_objectpermission DROP constraint IF EXISTS<br>
Mar 22 23:10:17 db-pg-p3 pgpool: permissions_objectpermission_content_id_check;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: COMMIT;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
DB node id: 1 backend pid: 27748 statement: COMMIT<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
DB node id: 0 backend pid: 68027 statement: COMMIT<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: LOG:<br>
pool_send_and_wait: Error or notice message from<br>
backend: : DB node id: 0 backend pid: 68027 statement: &quot;COMMIT&quot;<br>
message: &quot;there is no transaction in progress&quot;<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008:<br>
WARNING:  packet kind of backend 1 [&#39;C&#39;] does not match<br>
 with master/majority nodes packet kind [&#39;N&#39;]<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008:<br>
FATAL:  failed to read kind from backend<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008:<br>
DETAIL:  kind mismatch among backends. Possible last qu<br>
ery was: &quot;COMMIT&quot; kind details are: 0[N: there is no transaction in<br>
progress] 1[C]<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 68008: HINT:<br>
 check data consistency among db nodes<br>
Mar 22 23:10:17 db-pg-p3 pgpool: 2016-03-22 23:10:17: pid 67974: LOG:<br>
child process with pid: 68008 exits with status 5<br>
<br>
I can see that it&#39;s the return of the COMMITs returning different<br>
values that&#39;s causing problems. I can also see why this would be,<br>
because the query from the application contains a COMMIT of it&#39;s own<br>
on the end and this only gets run on one backend.<br>
<br>
What I do not understand is where the BEGIN and COMMIT statements are<br>
coming from and why they are sent to both backend nodes. Or how to<br>
approach fixing this.<br>
<br>
Could anyone offer some guidance?<br>
<br>
Thanks,<br>
Dan.<br>
<span class=""><font color="#888888">--<br>
Dan Foster | Senior Storage Systems Administrator<br>
Advanced Computing Research Centre, University of Bristol<br>
_______________________________________________<br>
pgpool-general mailing list<br>
<a href="mailto:pgpool-general@pgpool.net">pgpool-general@pgpool.net</a><br>
<a href="http://www.pgpool.net/mailman/listinfo/pgpool-general" rel="noreferrer" target="_blank">http://www.pgpool.net/mailman/listinfo/pgpool-general</a><br>
</font></span></blockquote></div><br></div></div></div>