Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#67 Too low max_allowed_packet on server causes crash

ZMySQLDA-2.0.9
closed
Andy Dustman
ZMySQLDA (19)
5
2012-09-19
2003-09-29
Johan Lübcke
No

If a MySQL query from Zope fails for the reason that the
max_allowed_packet variable has a to small value on the MySQL
server, the Zope process consumes all available memory and
crashes... (For example if you feed the query with a big chunk
for a BLOB)

My guess is that the 'query' method of the 'DB' object (db.py)
recurses forever if the db connection is hosed. If the second try
fails, I think it should give up.

Discussion

  • Johan Lübcke
    Johan Lübcke
    2003-09-29

    Logged In: YES
    user_id=194813

    This diff does the trick for me. (I get an OperationError instead of a
    crash.)

    --- lib/python/Products/ZMySQLDA/db.py 14 Mar 2002 20:24:54
    -0000 1.20
    +++ lib/python/Products/ZMySQLDA/db.py 29 Sep 2003 11:32:34
    -0000
    @@ -310,7 +310,7 @@
    r.append(info)
    return r

    • def query(self,query_string, max_rows=1000):
    • def query(self,query_string, max_rows=1000, retry_on_fail=1):
      self._use_TM and self._register()
      desc=None
      result=()
      @@ -339,10 +339,10 @@
      self._lock.release()

       except OperationalError, m:
      
      • if m[0] not in hosed_connection: raise
      • if m[0] not in hosed_connection or not retry_on_fail: raise
        # Hm. maybe the db is hosed. Let's restart it.
        db=self.db=apply(self.Database_Connection, (), self.kwargs)
      • return self.query(query_string, max_rows)
      • return self.query(query_string, max_rows, retry_on_fail=0)

        if desc is None: return (),()

     
  • Andy Dustman
    Andy Dustman
    2003-12-13

    Logged In: YES
    user_id=71372

    I've been thinking this whole business of trying to re-open
    the database and re-submit the query is just wrong,
    particularly if you are using transactions. Probably that
    whole except clause should go. ZMySQLDA was derived from
    ZOracleDA, and that is one of the carryover bits that
    probably was not right to begin with, even with Oracle.
    Probably it should _abort() instead.

     
  • Andy Dustman
    Andy Dustman
    2005-03-06

    Logged In: YES
    user_id=71372

    The fix is finally in 2.0.9b3.