Home Projects Jobs Clientele Contact


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Database exceptions

OK. Sounds good. We need to document it somewhere on the wiki.
(I presume "single procedure per modification" is currently the case for UU)


Alexey Parshin wrote:
I'd not suggest such transactions. Any data modifications in UU are made through the stored procedures. The ideal case is the only one stored procedure performing all the required data modifications. The main idea is to keep the transaction as short as possible. This is needed since every db resource modified within the transaction is locked till the end of transaction. A single stored procedure called to do all the modifications does the job the fastest and safest way.

The explicit transactions are handled correctly by CTransaction object. If defined as auto variable and goes out of scope (upon the exception) it automatically rolls back ancommitted transaction. However, the only reason for using explicit transaction handling is using several queries executed within transaction. This is generally ineffective but may be needed in some perverted situations (like Slonic file operations, for instance).

2008/12/23 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com <mailto:ilya@total-knowledge.com>>


    What do you think about making explicit transactions, starting one
    when connection is retrieved from the pool, and ending it when it
    is released back? (Question here is: how do we decide if we need
    to commit the transaction or roll it back. Does explicit transaction
    get rolled back if an exception is thrown by a stored proc?)


    Alexey Parshin wrote:


        The database exceptions are thrown in several different
        situations. This includes both read-only data access and data
        modifications. Normally, exceptions thrown by the stored
        procedures (any data access is done through stored procs) are
        re-thrown by sptk::CQuery as sptk::CException.

        By the definition, any call of the stored procedure is a
        transaction. If the exception is thrown from within the stored
        procedure, the transaction is terminated and rolled back by PG
        server, to the state before the procedure call. If no
        exceptions are thrown, stored proc exits and transaction is
        committed by PG server.

        The exception from the above rule is the manual transaction
        start (using CTransaction) and performing several procedure
        calls followed by explicit commit (rollback happens on
        exceptions), but this isn't used in UU at this point.

        2008/12/23 Ilya A. Volynets-Evenbakh <ilya@total-knowledge.com


           I have a few questions regarding UU database.

           What happens if database exception is thrown in UU?
           Does anything rollback? To what point?
           Also, when does commit of a transaction happen?


-- Alexey Parshin,

Alexey Parshin,

Authoright © Total Knowledge: 2001-2008