Re: Transaction Isolation level

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Oct 04 2007 - 06:21:34 EDT

  • Next message: Martin Thelian: "Re: Transaction Isolation level"

    On Oct 4, 2007, at 1:07 PM, Martin Thelian wrote:

    > Andrus Adamchik schrieb:
    >>> and is there a way to change it to use serializable transactions?
    >> There's no direct API (maybe we should add it to Cayenne Transaction
    >> in 3.0?), but you can enable serializable transactions by wrapping
    >> your code in a Cayenne transaction manually [1] (see "User-Defined
    >> Transaction Scope" down the bottom), and setting Connection
    >> properties
    >> by hand.
    > Thank you for this tip.
    > It seems to work fine, except that the connection with the changed
    > isolation level is returned to pool once transaction.commit() is
    > called
    > by thread1, and therefore the next thread (thread2) gets this
    > connection
    > from pool, but with the changed transation-isolation-level. A
    > race-condition between thead1 and thread2 could arise if the
    > isolation-level would be set back by thread1 after the
    > transaction-commit. So each thread in the system would need to
    > check the
    > transaction-isolation-level of a connection to ensure that the proper
    > isolation-level is used.
    >
    > Martin

    Or you can reset the state in the "finally" block of the manual
    transaction.

    Andrus



    This archive was generated by hypermail 2.0.0 : Thu Oct 04 2007 - 06:22:02 EDT