Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^3: Issue with dbi connect_cached method

by Corion (Patriarch)
on Apr 22, 2022 at 16:59 UTC ( [id://11143212]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Issue with dbi connect_cached method
in thread Issue with dbi connect_cached method

Most likely, the database server has disconnected the database connection and now ->connect_cached tries to reuse the connection but times out. Consider speaking with your database administrator and network administrator after what time the database and the network will drop an existing connection.

Another problem can be if you use the fork system call. Ideally, DBD::Oracle (and the underlying database library) would detect that and reestablish the connection, but maybe they don't and try to reuse the connection of the parent.

Replies are listed 'Best First'.
Re^4: Issue with dbi connect_cached method
by Anonymous Monk on Apr 22, 2022 at 17:30 UTC

    Thank you Corion for the revert.
    Here lexical scoped variable $dbh has been used (not a global one), so here it should have been created a new connection, isn't it? but somehow it seems to act as a global variable.
    Is there any downside if I retain the "connect" itself instead of "connect_cached", at least for this problematic part of the code.

    Please suggest.
    Regards,

      The point of the ->connect_cached method is to keep a global cache of the connection.

      In an ideal world, ->connect_cached is a drop-in replacement for ->connect, but reusing an old connection.

      The downside of using ->connect is that maybe you are a bit slower because you rebuild the network connection. But that is better than having a long timeout, in your case.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-18 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found