Does anybody are conscious of any gotachs or problems when writing multithreaded Perl programs while using Oracle DBI? Each thread might have it's own link with Oracle.
For that longest time I had been told multithreading wasn't supported in Perl with Oracle.
The Perl DBI makes sure single-threads through its interior, therefore the motorists are only participating in one session (
$dbh) at any given time. No matter the number of Processor chips you've. So, multi-threads isn't supported (because everything inside DBI is single-threaded), but it's dependable DBI (and therefore DBD::Oracle) inside a multi-threaded application.
Well, the DBI documentation states not to utilize a threaded Perl, and indicates a Perlmonks post that explains that. The documentation suggesting to avoid it's a very good reason.
However, I have seen it work all right on some platforms but fail totally on others. It's definitely not portable even when you need to do get results.
Yes, using threads in Perl is definitely an very bad idea, no matter whether you utilize Oracle or otherwise.
While theoretically, provided each uses its very own connection, it will work, perl 5.8 threads are fundamentally flawed.
Should you realize that article but still desire to use Perl threads, best of luck.
I have used multi threads in Perl for benchmarking an Oracle db and that i needed to produce a database handler for each thread.
Some time back I mannaged to obtain an advertisement-hock implementation working... I treated the bond w/ dbi like a limited resource and shared it one of the various threads in Perl utilizing a file securing mechanism. My multi-threaded application only ever attached to the dbi via a seperate perl-script running like a daemon.
On Linux, the multithreaded finish ended via fork, on home windows I made use of whatever included the default activeperl implementation ( I forget )
I attempted getting them communicate via shared memory, but wound up simply using a shared file rather. Linux has reliable append mode, therefore it was simple. On home windows it had been a lot more nearly impossible to find them synchronized.
Lately I have investigated database transactions, with every demonstration of the thread getting it's own link with the database, and letting the database handle the bond particulars.
This really is with mysql, but i am sure oracle supports transactions.
apache::dbi works/plays well with mod_perl to keep these connections alive in between each run-through from the script (before I made use of this, each connection made was quite time intensive).
Your results will be different.
You can test using spend "multithreading" rather. Referred to in http://alexhanin.blogspot.com/2010/07/multithreading-with-nothing-but-korn.html Place the your perl inside spend wrapper, then use each spend "thread" like a separate demonstration of a course.