<div dir="ltr">Hello all,<div><br></div><div>I have a system using RelStorage with postgresql (9.2) and plone.app.async (which is installed only on a dedicated "worker" instance).</div><div>While debugging a nasty network problem where idle connections where being forcefully terminated, I stumbled upon this:</div>

<div><br></div><div><div>postgres=# select datname, usename, query_start, state_change, state, query from pg_stat_activity;</div><div>      datname       | usename  |          query_start          |         state_change          |        state        |                                </div>

<div>          query                                          </div><div>--------------------+----------+-------------------------------+-------------------------------+---------------------+--------------------------------</div>

<div>---------------------------------------------------------</div><div> replication_repmgr | repmgr   | 2014-03-13 15:34:40.536227+01 | 2014-03-13 15:34:40.536327+01 | idle                | SELECT 1</div><div> prod_zope          | zope     | 2014-03-13 15:34:41.079448+01 | 2014-03-13 15:34:41.079497+01 | idle in transaction | EXECUTE get_latest_tid<br>

</div><div> stage_zope         | zope     | 2014-03-13 15:34:40.631671+01 | 2014-03-13 15:34:40.631705+01 | idle in transaction | EXECUTE get_latest_tid</div><div> stage_zope         | zope     | 2014-03-13 15:34:06.37716+01  | 2014-03-13 15:34:06.38005+01  | idle                | COMMIT</div>

<div> prod_zope          | zope     | 2014-03-13 13:36:24.287554+01 | 2014-03-13 13:36:24.287568+01 | idle                | ROLLBACK</div><div> prod_zope          | zope     | 2014-03-13 13:36:23.887335+01 | 2014-03-13 13:36:23.891213+01 | idle                | COMMIT</div>

</div><div><br></div><div>Note: the connection are one each for the production and preproduction database, and is consistent with the fact that we have a worker for preproduction and one for production.</div><div><br></div>

<div><div>Which roughly means that I have two connections where the following happened:</div><div>BEGIN TRANSACTION;</div><div>EXECUTE get_latest_tid;<br></div><div><br></div><div>And then the connection went idle, without any further command sent to postgres (a COMMIT or ROLLBACK). This has a number of side effects, namely:</div>

<div><ol><li>Certain tables remain locked and automatic cleanup functions (e.g. AUTOVACUUM) can't properly run<br></li><li>In my case, when this connection gets terminated postgres gets reasonably upset<br></li></ol>
</div>
<div>If i turn off the worker instance(s), these connections that are left as "idle in transaction" disappear. My wild guess is that the worker, relying as it is on a reactor (Twisted, if I'm not mistaken), doesn't quite follow the pattern that RelStorage expects (and probably the difference between an RDBMS and ZEO here comes into play).</div>

<div><br></div><div>What I want to know is:</div><div><ol><li>Someone else experienced this same problem?<br></li><li>My diagnosis makes sense, or am I assuming too much[1]?</li><li>Are there any other solutions or workarounds besides "use ZEO" or "use some other queue system"?<br>

</li></ol></div><div>Thanks everyone,</div><div><br></div><div>[1] This has been known to happen frequently :)</div><div><br></div>-- <br><div dir="ltr"><div><b><font>Simone Deponti</font></b></div><div><font size="1">Project manager</font></div>

<div><br></div><div><b><font size="6" color="#000000">>_</font></b></div><div><font size="1"><a href="http://abstract.it" target="_blank"><font color="#000000">abstract.it</font></a> - +39 06 92 94 69 38</font></div><div>

...............................................................................</div><div><font size="1" color="#666666">Registro Imprese di Napoli 788429 / Cap. Soc. 10.000 Euro I.V.</font></div><div><font size="1" color="#666666">Avvertenze Legali - D. Lgs. 196/03 Tutela dei dati personali. Le informazioni</font></div>

<div><font size="1" color="#666666">contenute in questo messaggio e in ogni eventuale allegato sono riservate e</font></div><div><font size="1" color="#666666">ne è vietata ogni forma di diffusione. Se avete ricevuto questa comunicazione</font></div>

<div><font size="1" color="#666666">per errore, Vi preghiamo di informare immediatamente il mittente del messaggio</font></div><div><font size="1" color="#666666">e di eliminare l'e-mail.</font></div></div>
</div></div>