Re: idle in transaction

From: João Paulo Ribeiro <jp(at)mobicomp(dot)com>
To: Sriram Dandapani <sdandapani(at)counterpane(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: idle in transaction
Date: 2006-09-18 16:50:54
Message-ID: 450ECE6E.2090401@mobicomp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi.<br>
In a more generic way, you need to garantee 2 things:<br>
1) You always release your connections back to the pool.<br>
2) Any connection released must not have a valid transaction with
resources allocated.<br>
<br>
Its ok to have a connection in the pool with setautocommit(false), that
leads to "idle in connection", if the transaction is a new one and no
resources or lock have been made at the db.<br>
<br>
If you want now what is blocking your vaccum try this:<br>
<br>
SELECT pg_class.relname AS table, pg_database.datname AS database,
transaction, pid, mode, granted FROM pg_locks, pg_class, pg_database
WHERE pg_locks.relation = pg_class.oid AND pg_locks.database =
pg_database.oid order by pg_class.relname, pid;<br>
<br>
You will see in wich table the vaccum is waiting to acquire the lock
and wich process is holding it at the moment.<br>
<br>
Best regards.<br>
Jo&atilde;o Paulo Ribeiro<br>
<br>
Sriram Dandapani wrote:
<blockquote
cite="mid6992E470F12A444BB787B5C937B9D4DF05DF1A7F(at)ca-mail1(dot)cis(dot)local"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags"
name="PersonName">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";
color:black;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
pre
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
span.EmailStyle17
{mso-style-type:personal;
font-family:Arial;
color:windowtext;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</o:SmartTagType>
<div class="Section1">
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;">Hi<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;">I use JBOSS
4.0.3 to manage my connection
pooling. Is there a way to configure / modify code to take care of this<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;">Thanks for
your input<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;">Sriram<o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
<div>
<div class="MsoNormal" style="text-align: center;" align="center"><font
color="black" face="Times New Roman" size="3"><span
style="font-size: 12pt; color: windowtext;">
<hr tabindex="-1" align="center" size="3" width="100%"></span></font></div>
<p class="MsoNormal"><b><font color="black" face="Tahoma" size="2"><span
style="font-size: 10pt; font-family: Tahoma; color: windowtext; font-weight: bold;">From:</span></font></b><font
color="black" face="Tahoma" size="2"><span
style="font-size: 10pt; font-family: Tahoma; color: windowtext;"> Jo&atilde;o
Paulo Ribeiro [<a class="moz-txt-link-freetext" href="mailto:jp(at)mobicomp(dot)com">mailto:jp(at)mobicomp(dot)com</a>] <br>
<b><span style="font-weight: bold;">Sent:</span></b> Monday,
September 18, 2006
2:15 AM<br>
<b><span style="font-weight: bold;">To:</span></b> Sriram Dandapani<br>
<b><span style="font-weight: bold;">Cc:</span></b> <st1:PersonName
w:st="on"><a class="moz-txt-link-abbreviated" href="mailto:pgsql-jdbc(at)postgresql(dot)org">pgsql-jdbc(at)postgresql(dot)org</a></st1:PersonName><br>
<b><span style="font-weight: bold;">Subject:</span></b> Re: [JDBC]
idle in
transaction</span></font><font color="black"><span
style="color: windowtext;"><o:p></o:p></span></font></p>
</div>
<p class="MsoNormal"><font color="black" face="Times New Roman"
size="3"><span style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
<p class="MsoNormal"><font color="black" face="Times New Roman"
size="3"><span style="font-size: 12pt;">Hi.<br>
<br>
Are you using DODS/Enhydra to manage your database connection pool?<br>
If yes, see my email in the Enhydra mailing list:<br>
<a href="http://mail-archive.objectweb.org/dods/2006-05/msg00000.html">http://mail-archive.objectweb.org/dods/2006-05/msg00000.html</a><br>
<a href="http://mail-archive.objectweb.org/dods/2006-06/msg00000.html">http://mail-archive.objectweb.org/dods/2006-06/msg00000.html</a><br>
<br>
The latest DODS dont have this issue anymore. You just use
"RollbackOnReset" option.<br>
<br>
Bests regards.<br>
Jo&atilde;o Paulo Ribeiro<br>
<br>
Sriram Dandapani wrote: <o:p></o:p></span></font></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">I use postgres 8.1.2
database and postgres 8.1.404
jdbc driver .<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">I keep seeing &#8220;idle in
transaction&#8221;
connections on the postgres box all the time. The application logic
closes all
connections , so it makes me wonder if the driver is issuing a begin
statement
after every commit to leave a floating transaction open.<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">This is causing
autovacuum to not finish (and hence I
have to frequently issue database-wide vacuums to prevent the
transaction id
wraparound problem)<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Any help here is
appreciated<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Thanks<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;"><u1:p>&nbsp;</u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Arial" size="2"><span
style="font-size: 10pt; font-family: Arial;">Sriram<u1:p></u1:p></span></font><o:p></o:p></p>
<p class="MsoNormal"><font color="black" face="Times New Roman"
size="3"><span style="font-size: 12pt;"><br>
<br>
<br>
<o:p></o:p></span></font></p>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">-- <o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">Jo&atilde;o Paulo Ribeiro | Senior Software Engineer<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><a href="mailto:jp(at)mobicomp(dot)com">jp(at)mobicomp(dot)com</a><o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">PHONE: + 351 253 305 250<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">FAX&nbsp; : + 351 253 305 250<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><a href="http://www.mobicomp.com">www.mobicomp.com</a><o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">________________________________________________________________<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">About Solutions | Wireless World<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;"><o:p>&nbsp;</o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.<o:p></o:p></span></font></pre>
<pre><font color="black" face="Courier New" size="2"><span
style="font-size: 10pt;">DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.<o:p></o:p></span></font></pre>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Jo&atilde;o Paulo Ribeiro | Senior Software Engineer
<a class="moz-txt-link-abbreviated" href="mailto:jp(at)mobicomp(dot)com">jp(at)mobicomp(dot)com</a>

PHONE: + 351 253 305 250
FAX : + 351 253 305 250
<a class="moz-txt-link-abbreviated" href="http://www.mobicomp.com">www.mobicomp.com</a>

________________________________________________________________

About Solutions | Wireless World

CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.
DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.</pre>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 12.2 KB

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albert Cardona 2006-09-18 17:04:34 Re: about monitoring the input stream
Previous Message Sriram Dandapani 2006-09-18 16:02:59 Re: idle in transaction