Multithreading woes

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
Marian Aldenhövel
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 29.06.2024, 13:50

Multithreading woes

Post by Marian Aldenhövel »

Hi,

I am using Zeos 8.0 from Delphi 10.3 in an ETL-Type application where I fetch data from a REST-API and pump it into an Oracle DB. I have set things up so that various REST endpoints can be serviced from separate threads.

Unfortunately this fails by throwing an EExternalException. The oracle client also barfs the string KPEDBG_HDL_POP_FCPTR to stdout. So I believe the error is triggered in 3dparty code by Oracle.

My TZConnection all Zeos-Components are on DataModules. These are instantiated in the context of the main thread during setup but I am positive that I am creating a separate instance of the datamodule for each thread spawned later. When instantiating the datamodules I specify an Owner of NIL.

I have also tried creating the datamodules from within the worker threads themselves. But that results in the same error.

I do not have a simple testcase and am aware that this may be caused by a lot of dumb things I did wrong.

But maybe there is a something specific I need to tell the Oracle client that I want to use it in a multithreaded application?

Regards, Marian
MJFShark
Expert Boarder
Expert Boarder
Posts: 214
Joined: 04.06.2020, 13:59

Re: Multithreading woes

Post by MJFShark »

Hi Marian.

Try adding the following connection property to see if it helps your case:

MyConn.Properties.Values[ConnProps_OCIMultiThreaded] := 'True';

This puts the Oracle Client into multithreading mode.

-Mark
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 777
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Multithreading woes

Post by aehimself »

MJFShark wrote: 10.07.2024, 11:33MyConn.Properties.Values[ConnProps_OCIMultiThreaded] := 'True';
You beat me to it :) Me too, about 95% sure this will solve OP's issue.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Marian Aldenhövel
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 29.06.2024, 13:50

Re: Multithreading woes

Post by Marian Aldenhövel »

Yes, that did the trick.

To be precise I set the connection property at design time using the visual editor, but the result obviously is the same.

I would like to apologize for my weak googling, especially as I had a hunch it might be something like this.

Thank you very much!

Regards, Marian
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 777
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Multithreading woes

Post by aehimself »

However the patch is almost 2 years old it doesn't get much visibility because of two reasons:
- It does not affect single-threaded applications
- Even multithreaded ones can run stable-ish without it with specific driver versions

Plus, for months I simply considered these errors as normal operation for the crap Oracle calls driver :)
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply