Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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'"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://324623]
and the radiator hisses contentedly...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-02-18 23:08 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (257 votes). Check out past polls.