Subject Re: Multithreading problem - error reading data from the connection
Author Adam
--- In, Miroslav Penchev
<miroslavp@...> wrote:
> На Mon, 16 Oct 2006 22:42:36 +0300
> Miroslav Penchev <miroslavp@...> написа:
> > Hi,
> >
> > I have application with heavy forms and try to make some late loading
> > of data with threads. I made a simple thread class in Delphi which
> > takes a MDOQuery (similar to IBX components) and linked to it
> > ClientDataSet. In the thread I create a separate MDODatabase and
> > MDOTransaction and attach Query component to them. Then I open
> > ClientDataSet to fetch all records.
> > In about 10% of tests I get "error reading data from the connection"
> > when try to open some of MDODataset components in main thread just
> > after the thread was fetched its records.
> >
> > I am almost sure that two threads use different MDODatabase components
> > - I look at the Handle property trough OutputDebugString before open
> > of DataSet.
> > Is there any other prerequisites for multithreading work with
> > Firebird, except connection-per-thread?

Transaction and query objects per thread too. And "almost sure" isn't
good enough. It only takes one non threadsafe section of code to bring
problems, and thread problems are by definition exceedingly hard to
duplicate. Given that your tests are returning as high as 10% it
should be relatively easy to find.

If you are using UDFs in any queries (or in any triggers fired by
queries you run), you will need to check that they are threadsafe.

I am running embedded firebird multi threaded tiers in a multi-site
environment for about 8 customers in our beta program with no thread
related issues. Embedded firebird on windows is the same as Superserver.