Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: MultiThread possible issues - basic questions - Thanks

by rob_au (Abbot)
on Jan 28, 2004 at 08:50 UTC ( #324623=note: print w/ replies, xml ) Need Help??


in reply to MultiThread possible issues - basic questions - Thanks

With regards to your questions regarding DBI thread safety and code implementations, I would strongly recommend incorporating the creation and destruction of your database handle into your job code - This is because of the behaviour of the DBI in threaded environments. In the interpreter threads (iThreads) environment, the new thread is created through the cloning of the interpreter and assignment of a single interpreter per application thread. Subsequently, as described in the DBI documentation, if the database handle and drivers are loaded and handles created before the thread is created then the new interpreter thread will only receive a cloned copy of the DBI, the drivers and the handles rather than a denovo copy. When this occurs however, the internal pointer data within the handles will refer to the DBI and drivers in the original interpreter, which in turn causes the interpreter thread to croak upon the use of any method call using handles that don't belong to the current thread.

The error messages which you are seeing (Attempt to free unreferenced scalar ...) are in fact the result of the the interpreter thread croaking upon employ of methods within the database driver handle and subsequently attempting to free resources which have been cloned from the parent thread.

In short, DBI handles cannot be shared between interpreter threads and as such each thread should create it's own database handle upon creation.

 

perl -le "print unpack'N', pack'B32', '00000000000000000000001010110111'"


Comment on Re: MultiThread possible issues - basic questions - Thanks
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://324623]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-09-21 13:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (171 votes), past polls