[Zope-DB] [Weakness] excessive demand on database connections

Dieter Maurer dieter@handshake.de
Mon, 10 Mar 2003 22:49:21 +0100


<http://collector.zope.org/Zope/844>

DA instances derived from "Shared.DC.ZRDB.Connection" are very
eager to open a database connection:

  They do so immediately when they are loaded from ZODB.

  If someone looks at a folder containing a DA instance,
  a connection is opened.

  When someone uses the left frame in the ZMI, then
  DA instances too levels deeper than the unfolded tree
  open database connections.

This wastes precious resources.

Moreover, and more importantly, it can lead to very peculiar
behaviour.

   Twice, I had to analyse a behaviour that some
   requests (apparently) non-deterministically took more
   than 4 minutes. In both cases, it turned out
   (after long analysis) that an invisible DA instance
   trying to connect to an offline database was the culprit.
   The 4 minutes are the connection timeout.


Do not open a connection in "__setstate__"!
Do it, when the database is accessed for the first time.
If something goes wrong then, you get a traceback describing
the problem. Now, some requests unrelated to the database
simply take excessive time without any indication with respect
to the problem.


Dieter