<div dir="ltr"><div><div><div><div><div>Hello - I'm having an issue with Dancer::Plugin::Database that has been hard to reproduce and track down.<br><br></div>I have a new app that I just moved to its production environment. It connects to a database that is in a remote data center over a vpn tunnel. Everything functions normally as expected 98% of the time, however occasionally I will hit a worker thread (deployed via Starman) that just hangs trying to get a database handle. It hangs in the _check_connection subroutine until it reaches some timeout. Then will reconnect just fine with a new connection.<br>
<br>I'm using plugin version 1.82 and I have traced it down to this line in the plugin:<br>if ($dbh->{Active} && (my $result = $dbh->ping)) {<br><br>Right at this if statement is where it hangs, i assume while calling the ping function. It seems there is some confusion as to whether the dbh is still active, it then calls ping which hangs for a number of minutes (not sure how many exactly yet, b/t 3-5). This renders this worker thread unresponsive until it times out. It will eventuall fall into the else block and just return false, which then a new connection is established just fine. <br>
</div></div><div></div><div><br></div>I have successfully deployed a number of apps using this same plugin with no problems this only difference here is the physical location so there maybe something network related, just not sure where.<br>
<br></div><div>I have dug into DBI, etc and the ping functions works fine on all my test scripts. Again, this only happens once in a while so I cannot reproduce on command, which makes it difficult to debug.<br><br><br></div>
<div>Here is the output of my debug statements, showing the one thread that hangs:<br><br>[27037] debug @0.005053> [hit #4]Database connection_check_threshold [30] in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 69<br>
[27037] debug @0.005189> [hit #4]Database handle last check [1398093938] in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 70<br>[27037] debug @0.005345> [hit #4]Database calling check_connection in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 83<br>
[27037] debug @0.005481> [hit #4]Database.pm in check_connection before if active and ping in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 265<br>... other threads working ...<br>[27037] debug @962.134467> [hit #4]Database in check_connectiion false returnĀ  in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 285<br>
[27037] debug @962.134667> [hit #4]Database connection went away, reconnecting in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 90<br>[27037] debug @962.134894> [hit #4]Database calling get_connection in /usr/local/share/perl5/Dancer/Plugin/Database.pm l. 97<br>
[27037] debug @962.135059> [hit #4]Adding mysql_enable_utf8 to DBI connection params to enable UTF-8 support in /usr/local/share/perl5/Dance<br></div><div><br><br><br></div>Any help or suggestions on where to look next is appreciated.<br>
<br></div>Thank you.<br><div><div><div><div><div><br><br></div></div></div></div></div></div>