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

Re: Error: ExternalTransaction in a LocalDatabase



On Fri, 26 Jan 2001, Michael Keuchen wrote:
> Hi!
> 
> I cannot begin an ExternalTransaction on a LocalDatabase with the newest
> CVS code
> because ExternalTransaction.begin
> uses ExternalDatabase.beginTX
> uses LocalDatabase.joinTX
> which always throws a RuntimeException.
> 
> The code in LocalDatabase is:
> 
> 
>     public void joinTX( AbstractTransaction tx ) throws TransactionExc {
>         // currently the client side threads are used for server
> internal work;
>         // that is, DbLocalClient just calls the appropriate server
> method; but
>         // the server can handle only one thread per transaction,
> therefore
>         // jointTX for local connections is not allowed -> one
> (Command)Thread per
>         // DbLocalClient
>    throw new RuntimeException( "joinTX()" );
>     }

In order to get ozone working with the JTA transaction manager of Prowler I
recently reworked the connection pooling code and found that
LocalTransaction.join() did never work correctly. I wasn't sure about the
best way to fix this. The exception is there to let you know at least.

I will try to describe the problem. Since I don't use LocalDatabase that much I
will not tackle this soon. Maybe someone else can look into it. ;)

Ok, here we go! ozone allows to open more than one connection to the server.
Each connection "runs" inside its own server thread and is connected by one
socket. One server thread (connection) is always associated to one
transaction or it is inactive. So, for ExternalDatabase it is easy to map
several client threads to one server connection (socket), which is needed when
several client threads join the same transaction - the client thread just need
to use the right socket to make sure to do work on behalf of the right
transaction. So far so good.

To keep it simple the LocalDatabase does _not_ have such a client to server
thread mapping. The client thread simply calls the appropriate methods inside
the server _directly_. That is, the server work is done _inside_ the client
thread. Since a server transaction is associated to exectly one thread, it is
not possible to join more than one thread to a transaction when using
LocalDatabase.

Ok, there are several ways to fix this and I would like to discuss them but
first someone has to confirm that he got me anyway ;)


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com