Page 1 of 1
FB3 Threading and Connections
Posted: Wed 06 Jul 2016 00:11
by FredS
Hi,
I ran into this, from:
http://www.mail-archive.com/firebird-su ... 14625.html
Both engine and remote layer doesn't allow to run more than one thread per connection at the same time.
So now I have to ask, what happens when we set the same connection string to threaded TUniConnections?
From:
viewtopic.php?f=28&t=32233#p111360
the correct solution will be to use a separate connection (the TUniConnection component) in each thread.
Is FB3 serialized or threaded? And if serialized how do I force a new connection from a thread with the same ConnectionString?
Re: FB3 Threading and Connections
Posted: Thu 07 Jul 2016 13:58
by ViktorV
Please clarify your question. If you are interested in specificities of Firebird 3 functioning, please forward your question to Firebird technical support. If you are interested in UniDAC usage when working with Firebird in multi-threaded applications, then you have got a right answer: to create a thread-safe application, you should create a separate TUniConnection component in each thread and set the same connection string for each TUniConnection instance.
Re: FB3 Threading and Connections
Posted: Thu 07 Jul 2016 19:30
by FredS
ViktorV wrote:Please clarify your question.
Resource Monitor shows no additional threads being run by a local FB3 server when my app starts four new threads are using the same ConnectionString.
The Q:
How do I force a new FB3 (threaded on the Server side) connection from a thread using the same ConnectionString in UniDAC?
Re: FB3 Threading and Connections
Posted: Fri 08 Jul 2016 11:08
by ViktorV
If you mean usage of server in a multi-threaded mode, then usage of this mode depends on Firebird 3 configuration. For concurrent DB usage with creating a thread for each incoming connection, you can use Superclassic Server Mode. See more detailed information about Firebird 3 Server Modes at:
http://firebirdsql.org/file/documentati ... kStart.pdf You can choose Server Mode during installation of Firebird 3. You can also change Server Mode at any time in the firebird.conf file (the ServerMode variable) and restart the process.
If you mean UniDAC usage for creating multi-threaded applications, then you can create such applications. The only limitation is that you can't use a single connection (the TUniConnection component) in several threads. Therefore you should use a separate connection in each thread, not depending on the Firebird version.
Re: FB3 Threading and Connections
Posted: Fri 08 Jul 2016 19:14
by FredS
ViktorV wrote:The only limitation is that you can't use a single connection (the TUniConnection component) in several threads. Therefore you should use a separate connection in each thread, not depending on the Firebird version.
I already did that but wasn't sure if that translated to multiple connections in FB3.
After setting up Tracing I can verify that it does. However while looking at the Attachments/Connections change in the trace data I wondered about using connection Pooling.
When I turn on Connection Pooling and run I get an exception in TGDS.LoadGDS: Cannot load client DLL
Re: FB3 Threading and Connections
Posted: Wed 13 Jul 2016 09:43
by ViktorV
To solve the issue, please try to explicitly specify the path to the Firebird 3 client library in the TUniConnection.SpecificOptions.Values['Clientlibrary'] property.
If this doesn't help solve the issue, please compose a small sample reproducing the described behavior and send it to viktorv*devart*com , including scripts for database objects creating.
Re: FB3 Threading and Connections
Posted: Wed 13 Jul 2016 17:01
by FredS
ViktorV wrote:To solve the issue, please try to explicitly specify the path to the Firebird 3 client library in the TUniConnection.SpecificOptions.Values['Clientlibrary'] property
This is already there, the app runs fine when Pooling is Off.
Tracing through your code it appears that the Clientlibrary value is never used. Adding the Clientlibrary dir to the path allowed me to test "Pooling" but it won't take the value from SpecificOptions when Pooling is ON.
Re: FB3 Threading and Connections
Posted: Thu 14 Jul 2016 10:23
by ViktorV
Thank you for the information. We have reproduced and fixed the issue. The fix will be included in the next build of UniDAC.