Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread dbisam 4 and transactions.
Fri, Oct 21 2011 12:08 PMPermanent Link

Enrico Lago

I have a problem with dbisam 4 and transactions.
Is there a way for detect if there is a transaction in action and wich are the involved tables?
Fri, Oct 21 2011 2:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Enrico,

<< I have a problem with dbisam 4 and transactions. Is there a way for
detect if there is a transaction in action and wich are the involved tables?
>>

You can use the TDBISAMDatabase.InTransaction flag to find out if a
particular database has a transaction in progress:

http://www.elevatesoft.com/manual?action=viewprop&id=dbisam4&product=delphi&version=7&comp=TDBISAMDatabase&prop=InTransaction

However, the transaction must have been started by the current process in
order for InTransaction to be True.

Unfortunately, there is no easy way to find out which tables are involved in
a restricted transaction.  You can do so with some internal calls, however.
If you're interested, I'll post some sample code.

--
Tim Young
Elevate Software
www.elevatesoft.com
Mon, Oct 24 2011 3:30 AMPermanent Link

Enrico Lago

>
> You can use the TDBISAMDatabase.InTransaction flag to find out if a
> particular database has a transaction in progress:
>

I have a thread contest. Each thread has your own TDBISAMDatabase object. The TDBISAMDatabase object does not know if the others TDBISAMDatabase objects have a transaction in action. The InTransaction property is only locally. Do you think that the TDBISAMDatabase object mast be common?
I have tried LockWaitTime and LockRetryCount but does not work. If a thread starts a transaction when another transaction is in action the thread is stopped till the end of the transaction.
Mon, Oct 24 2011 7:10 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Enrico


>I have a thread contest. Each thread has your own TDBISAMDatabase object. The TDBISAMDatabase object does not know if the others TDBISAMDatabase objects have a transaction in action. The InTransaction property is only locally. Do you think that the TDBISAMDatabase object mast be common?

Each thread need to be fully isolated. In practice this means that each thread MUST have its own TDBISAMSession, TDBISAMDatabase, TDBISAMTable and TDBISAMQuery components. If this rule is broken then it can cause problems eg corruption of the data.

>I have tried LockWaitTime and LockRetryCount but does not work. If a thread starts a transaction when another transaction is in action the thread is stopped till the end of the transaction.
>

This is the behaviour I would expect. What do you want it to do?

Roy Lambert [Team Elevate]
Mon, Oct 24 2011 8:00 AMPermanent Link

Enrico Lago

>
> This is the behaviour I would expect. What do you want it to do?
>

I  want to verify if there is a transaction in action. If it is, the thread can decide what to do.
Mon, Oct 24 2011 9:02 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Enrico

>> This is the behaviour I would expect. What do you want it to do?
>>
>
>I want to verify if there is a transaction in action. If it is, the thread can decide what to do.

Reading the link Tim posted, and accepting that the flag isn't being set in your case then unless Tim says something different the only solution I can see is to write your own code to indicate that a transaction is in progress.

One approach would be to use a simple text file in the same directory as the database. Before starting the transaction check if it exists, if not write it, delete after the transaction has finished.

A second approach would be to use semaphore locks (there's a chunk in the pdf manual about them) which have the advantage that in the event of a crash they clear themselves.

It has to be possible to detect whatever lock it is that Tim's setting otherwise transactions just wouldn't work. So it maybe that you just need the internal calls he refers to.

Roy Lambert [Team Elevate]
Mon, Oct 31 2011 8:39 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Enrico,

<< I have a thread contest. Each thread has your own TDBISAMDatabase object.
The TDBISAMDatabase object does not know if the others TDBISAMDatabase
objects have a transaction in action. The InTransaction property is only
locally. Do you think that the TDBISAMDatabase object mast be common? >>

No, don't make the TDBISAMDatabase common, for the reasons that Roy cites.

<< I have tried LockWaitTime and LockRetryCount but does not work. If a
thread starts a transaction when another transaction is in action the thread
is stopped till the end of the transaction. >>

Check out these two properties:

http://www.elevatesoft.com/manual?action=viewprop&id=dbisam4&product=delphi&version=7&comp=TDBISAMEngine&prop=TableTransLockRetryCount
http://www.elevatesoft.com/manual?action=viewprop&id=dbisam4&product=delphi&version=7&comp=TDBISAMEngine&prop=TableTransLockWaitTime

They will allow you to reduce the wait time/count for transaction locks so
that they fail almost immediately if you try to start a transaction and
cannot do so.  You will get an exception when the transaction lock fails
during the StartTransaction call, though, so be sure to wrap the call in a
try..except so that it doesn't bubble out of your thread.

--
Tim Young
Elevate Software
www.elevatesoft.com
Image