Subject Re: Issue for process
Author heroes3lover
--- In firebird-support@yahoogroups.com, "Adam" <s3057043@...> wrote:
>
> --- In firebird-support@yahoogroups.com, "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 qryInThread.open, 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
> there.
>
> 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.
>
> Adam
>

Thank you Adam,
Currently I only use Select in the thread, the reason is that
customers complaint about their white screen, said our program freeze
their laptop, so use one thread backgroud to do select stuff, and
main process wait for the thread terminated which can get rid of the
white screen.In fact, only one thread can running background, so I
can not imagine the connection can cause this problem, but I can try.

Regards,
Roc