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

Re: "Another thread runs exclusively already." exception



Timothy, sorry for the delay.

On Tue, 30 May 2000, Timothy Reaves wrote:
> What would cause this exception to be thrown?
> 
>     I am running a test query that starts a thread, queries the db for a
> user. I start some number of these threads, based on a command line
> argument.  It seems that at a certian point, the exception is thrown.
> The number of queries started varies from execution to execution.
> 
>     This is thrown from the beginExclusion method.
> 
>     From a short overview of the code (about five minutes, so please
> forgive me if I'm overlooking something), it would apear that a
> Transaction object does not have it's own thread instace variable, and
> that upon starting a Transcation via
> TransactionManager.prepareTransaction() that two threads could collide
> on the single TransactionManager.exclusive attribute.  Shouldn't either
> the Transaction class have it's own thread attribute for syncing on, or
> make TransactionManager.prepareTransaction() a synchronized method to
> prevent two threads from changeing the TransactionManager.exclusive
> attribute?
> 
>     It would appear that the later would - in effect - make the db
> single threaded by means of only single access, so perhaps giving each
> Transaction an attribute would be better.

Actually each transaction has its own thread. But because we always want to
know which transaction is associated to which thread we map threads into
transactions. This is done via the ta member of CommandThread (in case of
RemoteDatabase) or via the threadTable map of TransactionsManager (in case of
LocalDatabase).

TransactionManager.beginExclusion() is needed to let one transaction/thread
exclusivly during prepare/commit. The Java synchronization mechanism is suited
here. Currently is is done by simple raising the priority of the thread. This
should run on single processor but probably failes on multi processor machines.
Are you working on a multi processor?

A better implementation would actually suspend all other threads. But this is
not as simple as it sounds.

Also, your log shows that exactly after calling beginExclusion() another thread
is executed, which is strange even on a multi processor. Which ozone version do
you run. Check the code of beginExclusion. Is there a line like:

       Thread.currentThread().setPriority (Env.TRANSACTION_MUTEX_PRIORITY);


Falko
-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de