zope.rdb catches Retry and ConflictError exceptions

Bug #111185 reported by Maciej Wisniowski
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Low
Unassigned
zope.rdb
Confirmed
Low
Unassigned

Bug Description

zope/rdb/__init__.py has function queryForResults which calls cursor.execute this way:

    try:
        cursor.execute(query)
    except Exception, error:
        # Just catch the exception, so that we can convert it to a database
        # exception.
        raise DatabaseException(str(error))

This causes all errors from underlying adapters to be catched and converted to
DatabaseException.
It is wrong as sometimes database adapters have to raise Retry or
ConflictError. For example psycopgda (from zope repository) raises Retry(...) in
cursor.execute when database reports error like deadlock detected or conflict,
also it is necessary to add some code to cxoracleda to handle specific oracle
error codes and do 'reconnect' for them but this is not possible to do while
Retry exceptions are not propagated.

Quick fix may be to change above code to:

from zope.publisher.interfaces import Retry
from ZODB.POSException import ConflictError

(...)

    try:
        cursor.execute(query)
    except Retry:
        raise
    except ConflictError:
        raise
    except Exception, error:
        # Just catch the exception, so that we can convert it to a database
        # exception.
        raise DatabaseException(str(error))

Topic about this problem on zope3-dev: http://www.nabble.com/zope.rdb-error-and-zope.publisher-error-tf3651458.html#a10205344

Changed in zope3:
importance: Undecided → Low
status: New → Confirmed
Tres Seaver (tseaver)
Changed in zope.rdb:
status: New → Confirmed
importance: Undecided → Low
Changed in zope3:
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.