Transaction and Database Connection Properties

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Transaction and Database Connection Properties

Amin Abbaspour
Hi All,

I'm back with another (semi-)fundamental question. I want to know if there is any way to define some database connection properties (such as readonly-ness and isolation level) in current transaction and ask
DataSource to apply these properties into the connection it returns? In fact not necessarily to transaction itself but maybe to the thread it's bind to.

I think this might need a proxy around DataSource which lookups current running transaction (binded to thread) and reads some connection-related properties and then sets them to the physical JDBC connection. Am I right? Does BTM support this? Is there any other way to define these properties?

Thanks again,
Amin Abbaspour
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transaction and Database Connection Properties

Ludovic Orban
Administrator
Hi Amin,

For read-only, there is a standard solution: http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html#setRollbackOnly()

For the rest, I think this practice would lead to abuses and bad designs. It is not the job of a transaction manager to interfere with connections settings nor isolation levels, at least this is my opinion.

You can (and should) implement this at an upper layer. Here is for instance an article from IBM explaining how to do it with Spring:
  http://www.ibm.com/developerworks/java/library/j-isolation/index.html


In summary: I won't implement such feature unless you can persuade me that my view of transactional systems is wrong. If you're willing to discus this, you're welcome. I'd be more than happy to get fresh opinions on this subject.

Ludovic



2007/11/3, Amin Abbaspour <[hidden email]>:

Hi All,

I'm back with another (semi-)fundamental question. I want to know if there
is any way to define some database connection properties (such as
readonly-ness and isolation level) in current transaction and ask
DataSource to apply these properties into the connection it returns? In fact
not necessarily to transaction itself but maybe to the thread it's bind to.

I think this might need a proxy around DataSource which lookups current
running transaction (binded to thread) and reads some connection-related
properties and then sets them to the physical JDBC connection. Am I right?
Does BTM support this? Is there any other way to define these properties?

Thanks again,
Amin Abbaspour
--
View this message in context: http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13564155
Sent from the BTM Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transaction and Database Connection Properties

Amin Abbaspour
Dear Ludovic,

AFAIK 'rollbackOnly transaction' and 'readOnly connection' are two seprate concepts. A rollbackOnly transaction can still update the database but it will be rolled-backed in future. A readOnly connection is controlled by DB and prevents update queries. Please correct me if I'm wrong.

You are somehow correct that connection properties and transaction-managment are different concerns but you also accept that there is a close relation between them. This is a feature that nearly no transaction manager provides but BTM can be the first! :)  I also think that a clear design is possible and this mixure will no necessarily lead to a bad design.

Also thanks for the link about j-isolation. That was an approach but I'm looking for a solution to provide more controll. Maybe I develop one for myself and post the code to the list.

Regards,
Amin


Ludovic Orban wrote
Hi Amin,

For read-only, there is a standard solution:
http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html#setRollbackOnly()

For the rest, I think this practice would lead to abuses and bad designs. It
is not the job of a transaction manager to interfere with connections
settings nor isolation levels, at least this is my opinion.

You can (and should) implement this at an upper layer. Here is for instance
an article from IBM explaining how to do it with Spring:
 http://www.ibm.com/developerworks/java/library/j-isolation/index.html


In summary: I won't implement such feature unless you can persuade me that
my view of transactional systems is wrong. If you're willing to discus this,
you're welcome. I'd be more than happy to get fresh opinions on this
subject.

Ludovic



2007/11/3, Amin Abbaspour <abbaspour_amin@yahoo.com>:
>
>
> Hi All,
>
> I'm back with another (semi-)fundamental question. I want to know if there
> is any way to define some database connection properties (such as
> readonly-ness and isolation level) in current transaction and ask
> DataSource to apply these properties into the connection it returns? In
> fact
> not necessarily to transaction itself but maybe to the thread it's bind
> to.
>
> I think this might need a proxy around DataSource which lookups current
> running transaction (binded to thread) and reads some connection-related
> properties and then sets them to the physical JDBC connection. Am I right?
> Does BTM support this? Is there any other way to define these properties?
>
> Thanks again,
> Amin Abbaspour
> --
> View this message in context:
> http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13564155
> Sent from the BTM Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transaction and Database Connection Properties

Ludovic Orban
Administrator
Amin,

You're right about read only connections and rollback only transactions. The outcome is the same in theory but it's not the same concept at all. I don't know if any database takes advantage of readonly connections nor if it is properly implemented. You made me curious, is there any to your knowledge ?

Connection pooling and transaction management are totally separate concerns in theory. But only in theory because it is NOT possible to get a usable XA transaction manager without a pool fully aware of the XA internals.

The JTA spec is terrible in this respect. It only describes in very vague and incomplete way the interactions between an XA resource and the transaction manager. You can't imagine how complex it is to get a simple connection pool working in a decently with XA-awareness. The BTM pool has been implemented in such a way that it gives consistent results in all common situations. It required a hell load of complex tricks to get it working the way it does now.

Not taking into account the fact that such feature could easily be abused,its implementation could lead in an extra load of complexity in the already complex connection pool code.

I'm terribly sorry but I stand my point: if you want that you either have to implement it on top of the pool or hack BTM yourself knowing there is very little chance the code will ever be integrated.

I'm sure this sounds terribly inflexible but you have to understand this: a transaction manager has to build up a reputation of stability. If it isn't or isn't viewed as such then it will quickly be disregarded by its users. BTM is new and still has to prove itself even if I'm certain it's up to the task.

Ludovic

2007/11/5, Amin Abbaspour <[hidden email]>:

Dear Ludovic,

AFAIK 'rollbackOnly transaction' and 'readOnly connection' are two seprate
concepts. A rollbackOnly transaction can still update the database but it
will be rolled-backed in future. A readOnly connection is controlled by DB
and prevents update queries. Please correct me if I'm wrong.

You are somehow correct that connection properties and transaction-managment
are different concerns but you also accept that there is a close relation
between them. This is a feature that nearly no transaction manager provides
but BTM can be the first! :)  I also think that a clear design is possible
and this mixure will no necessarily lead to a bad design.

Also thanks for the link about j-isolation. That was an approach but I'm
looking for a solution to provide more controll. Maybe I develop one for
myself and post the code to the list.

Regards,
Amin



Ludovic Orban wrote:

>
> Hi Amin,
>
> For read-only, there is a standard solution:
> http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html#setRollbackOnly()
>
> For the rest, I think this practice would lead to abuses and bad designs.
> It
> is not the job of a transaction manager to interfere with connections
> settings nor isolation levels, at least this is my opinion.
>
> You can (and should) implement this at an upper layer. Here is for
> instance
> an article from IBM explaining how to do it with Spring:
>  http://www.ibm.com/developerworks/java/library/j-isolation/index.html
>
>
> In summary: I won't implement such feature unless you can persuade me that
> my view of transactional systems is wrong. If you're willing to discus
> this,
> you're welcome. I'd be more than happy to get fresh opinions on this
> subject.
>
> Ludovic
>
>
>
> 2007/11/3, Amin Abbaspour <[hidden email]>:
>>
>>
>> Hi All,
>>
>> I'm back with another (semi-)fundamental question. I want to know if
>> there
>> is any way to define some database connection properties (such as
>> readonly-ness and isolation level) in current transaction and ask
>> DataSource to apply these properties into the connection it returns? In
>> fact
>> not necessarily to transaction itself but maybe to the thread it's bind
>> to.
>>
>> I think this might need a proxy around DataSource which lookups current
>> running transaction (binded to thread) and reads some connection-related

>> properties and then sets them to the physical JDBC connection. Am I
>> right?
>> Does BTM support this? Is there any other way to define these properties?
>>
>> Thanks again,
>> Amin Abbaspour
>> --
>> View this message in context:
>> http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13564155
>> Sent from the BTM Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13581779
Sent from the BTM Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Transaction and Database Connection Properties

Amin Abbaspour
Dear Ludovic,

Thanks for taking the time and writing a detailed answer. I completely understand what you mean and would like to say that according to me BTM has be very successful in achieving its goal: stability.

And about the connection property aware DataSource implementation,  I will try to write it as a wrapper on top of BTM and see the what happens.

Regards,
Amin

Ludovic Orban wrote
Amin,

You're right about read only connections and rollback only transactions. The
outcome is the same in theory but it's not the same concept at all. I don't
know if any database takes advantage of readonly connections nor if it is
properly implemented. You made me curious, is there any to your knowledge ?

Connection pooling and transaction management are totally separate concerns
in theory. But only in theory because it is NOT possible to get a usable XA
transaction manager without a pool fully aware of the XA internals.

The JTA spec is terrible in this respect. It only describes in very vague
and incomplete way the interactions between an XA resource and the
transaction manager. You can't imagine how complex it is to get a simple
connection pool working in a decently with XA-awareness. The BTM pool has
been implemented in such a way that it gives consistent results in all
common situations. It required a hell load of complex tricks to get it
working the way it does now.

Not taking into account the fact that such feature could easily be
abused,its implementation could lead in an extra load of complexity in the
already complex connection pool code.

I'm terribly sorry but I stand my point: if you want that you either have to
implement it on top of the pool or hack BTM yourself knowing there is very
little chance the code will ever be integrated.

I'm sure this sounds terribly inflexible but you have to understand this: a
transaction manager has to build up a reputation of stability. If it isn't
or isn't viewed as such then it will quickly be disregarded by its users.
BTM is new and still has to prove itself even if I'm certain it's up to the
task.

Ludovic

2007/11/5, Amin Abbaspour <a.abbaspour@gmail.com>:
>
>
> Dear Ludovic,
>
> AFAIK 'rollbackOnly transaction' and 'readOnly connection' are two seprate
> concepts. A rollbackOnly transaction can still update the database but it
> will be rolled-backed in future. A readOnly connection is controlled by DB
> and prevents update queries. Please correct me if I'm wrong.
>
> You are somehow correct that connection properties and
> transaction-managment
> are different concerns but you also accept that there is a close relation
> between them. This is a feature that nearly no transaction manager
> provides
> but BTM can be the first! :)  I also think that a clear design is possible
> and this mixure will no necessarily lead to a bad design.
>
> Also thanks for the link about j-isolation. That was an approach but I'm
> looking for a solution to provide more controll. Maybe I develop one for
> myself and post the code to the list.
>
> Regards,
> Amin
>
>
>
> Ludovic Orban wrote:
> >
> > Hi Amin,
> >
> > For read-only, there is a standard solution:
> >
> http://java.sun.com/products/jta/javadocs-1.0.1/javax/transaction/UserTransaction.html#setRollbackOnly()
> >
> > For the rest, I think this practice would lead to abuses and bad
> designs.
> > It
> > is not the job of a transaction manager to interfere with connections
> > settings nor isolation levels, at least this is my opinion.
> >
> > You can (and should) implement this at an upper layer. Here is for
> > instance
> > an article from IBM explaining how to do it with Spring:
> >  http://www.ibm.com/developerworks/java/library/j-isolation/index.html
> >
> >
> > In summary: I won't implement such feature unless you can persuade me
> that
> > my view of transactional systems is wrong. If you're willing to discus
> > this,
> > you're welcome. I'd be more than happy to get fresh opinions on this
> > subject.
> >
> > Ludovic
> >
> >
> >
> > 2007/11/3, Amin Abbaspour <abbaspour_amin@yahoo.com>:
> >>
> >>
> >> Hi All,
> >>
> >> I'm back with another (semi-)fundamental question. I want to know if
> >> there
> >> is any way to define some database connection properties (such as
> >> readonly-ness and isolation level) in current transaction and ask
> >> DataSource to apply these properties into the connection it returns? In
> >> fact
> >> not necessarily to transaction itself but maybe to the thread it's bind
> >> to.
> >>
> >> I think this might need a proxy around DataSource which lookups current
> >> running transaction (binded to thread) and reads some
> connection-related
> >> properties and then sets them to the physical JDBC connection. Am I
> >> right?
> >> Does BTM support this? Is there any other way to define these
> properties?
> >>
> >> Thanks again,
> >> Amin Abbaspour
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13564155
> >> Sent from the BTM Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe from this list, please visit:
> >>
> >>     http://xircles.codehaus.org/manage_email
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Transaction-and-Database-Connection-Properties-tf4743407.html#a13581779
> Sent from the BTM Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>
>
Loading...