Subject Re: Issue for process
Author Adam
--- In, "heroes3lover"
<heroes3lover@...> wrote:
> Hello everyone,
> I got a problem.
> Because some SQL is huge and make program no response for a while, we
> have to use thread to retrieve data, below is my
> code,TSQLCompleteDataSetPlus is a component we inherited from
> TSQLCompleteDataSet(this is component of dbexpressplus),
> but when the process running to, sometimes the whole
> program jammed, and looks like die, and cpu usage is 0%, I think
> should be something wrong with thread safe issue, but I can not find
> out, cauz all stuff I created them in thread.
> Is there anybody can figure out the possible issue?
> Thanks very much.

Firstly, if it is an insert / update / delete, there is the
possibility of a 'lock conflict'. That means you have two or more
transactions attempting to modify the same record at the same time, or
a snapshot transaction trying to modify a record that a newer
transaction has modified. If you are using a WAIT transaction, your
transaction will suspend until that other transaction commits or rolls
back. Try using NOWAIT in however that is represented by your
connection components.

Secondly, establishing a connection is not threadsafe, so you may want
to put a mutex around

conInThread := TSQLConnection.Create(nil);

Use OutputDebugString in the windows unit to send messages from within
your thread. Download DebugView from Microsoft (formerly sysinternals)
and you can watch what is happenning. You are doing synchronise to
write your logs at the moment, which is going to put a bottle neck in

Without knowing what state it is in when it freezes and not having the
time to analyse everything about your threading code, it makes sense
to narrow down your problem to whether you are waiting for Firebird or
Delphi first.