Lock/deadlock and threads

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Gaby23
Posts: 13
Joined: Thu 04 Oct 2007 12:46

Lock/deadlock and threads

Post by Gaby23 » Thu 04 Oct 2007 13:18

Hello,

I'm using Borland Delphi 2006 and ODAC 6.20 (I tried ODAC 5.80).

I created Threads to run SQL commands, because the application needs to dialog with the second database even if the first wait the answer from the database.

I use ExecSQL procedure from TCustomOraQuery to execute the queries.

It's works, but when the database is in Lock/deadlock mode, the ExecSQL wait.
If there are a unlock, the command is executed and the thread normaly terminated.
If there are a network problem, the thread still run infinitly.

If I kill the Thread like "TerminateThread(ThreadOracle.Handle, 0);", The thread is terminated but when I recreate the Thread (after the unlock of the database) the ExecSQL still waiting...
Perhaps there are a link not terminated with the ODAC.

What's the solution to terminate the Thread properly or detect and stop ExecSQL ?

Thank you in advance,
Gaby

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 04 Oct 2007 14:51

Try to call the BreakExec method of TOraQuery to stop the query execution.

Gaby23
Posts: 13
Joined: Thu 04 Oct 2007 12:46

Post by Gaby23 » Thu 04 Oct 2007 15:34

Thank you for the answer.

I tried a BreakExec but it seems did nothing.
I tried a BreakExec and kill the thread but it's the same, the ExecSQL still waiting (database is unlocked)...

Gaby.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 05 Oct 2007 07:38

There is no other way to stop execution except the BreakExec method.

Gaby23
Posts: 13
Joined: Thu 04 Oct 2007 12:46

Post by Gaby23 » Fri 05 Oct 2007 08:41

Hello,

There are NonBlocking mode, but if NonBlocking := true ExecSQL don't block.
Is it possible to read ExecSQL state, and perhaps kill ExecSQL using BreakExec if ExecSQL still executing? (.Executing return allways True)

Thank you in advance,
Gaby

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 08 Oct 2007 09:03

In NonBlocking mode a query execution can be stopped by calling the BreakExec method. But if the BreakExec method cannot stop the execution when you have started it from a separate thread, this method also will not help in NonBlocking mode.

Post Reply