It would seem that the default timeout for MariaDB is much shorter than for MySQL, which leads to frequent connection failures under Starman. By wrapping the $dbh->ping call in an eval, Starman is able to reconnect without any problems.
Further research has led me to conclude that the problem is *not* the ping, but rather the way the database handle is handled in VirtualShelves. $dbh must be reinitialized in each subroutine. Upping severity because now that I understand the problem I realize that this same issue could happen with MySQL.
Created attachment 13422 [details] [review] Bug 9066: VirtualShelves db access not Plack+MariaDB compatible The $dbh database handle in C4::VirtualShelves was declared at the module level, which means under Plack it is initialized only once, when the server first starts. With the default MySQL configuration this is not a problem, since the MySQL connection does not time out, but the MariaDB default configuration does time out, resulting in every page that calls any sub in C4::VirtualShelves failing after a certain period. This patch eliminates the module-level $dbh variable and replaces it with $dbh handles in each subroutine that requires it. To test: Confirm that Virtual Shelves functionality still works as expected. The problem is not reproducible when using Apache or Plack+MySQL, but if everything works after the patch has been applied, the changes are safe.
Created attachment 13476 [details] [review] Bug 9066: VirtualShelves db access not Plack+MariaDB compatible The $dbh database handle in C4::VirtualShelves was declared at the module level, which means under Plack it is initialized only once, when the server first starts. With the default MySQL configuration this is not a problem, since the MySQL connection does not time out, but the MariaDB default configuration does time out, resulting in every page that calls any sub in C4::VirtualShelves failing after a certain period. This patch eliminates the module-level $dbh variable and replaces it with $dbh handles in each subroutine that requires it. To test: Confirm that Virtual Shelves functionality still works as expected. The problem is not reproducible when using Apache or Plack+MySQL, but if everything works after the patch has been applied, the changes are safe. Signed-off-by: Mason James <mtj@kohaaloha.com>
(In reply to comment #3) > Created attachment 13476 [details] [review] > Bug 9066: VirtualShelves db access not Plack+MariaDB compatible > > To test: > Confirm that Virtual Shelves functionality still works as expected. The > problem is not reproducible when using Apache or Plack+MySQL, but if > everything works after the patch has been applied, the changes are safe. > > Signed-off-by: Mason James <mtj@kohaaloha.com> tested this on my shiny new plack+mariadb koha Virtual Shelves functionality still works as expected :)
QA comment: * small patch that just move a variable for better accessibility * passes koha-qa.pl * no string change * no noticeable change passed QA
Created attachment 13545 [details] [review] Bug 9066: VirtualShelves db access not Plack+MariaDB compatible The $dbh database handle in C4::VirtualShelves was declared at the module level, which means under Plack it is initialized only once, when the server first starts. With the default MySQL configuration this is not a problem, since the MySQL connection does not time out, but the MariaDB default configuration does time out, resulting in every page that calls any sub in C4::VirtualShelves failing after a certain period. This patch eliminates the module-level $dbh variable and replaces it with $dbh handles in each subroutine that requires it. To test: Confirm that Virtual Shelves functionality still works as expected. The problem is not reproducible when using Apache or Plack+MySQL, but if everything works after the patch has been applied, the changes are safe. Signed-off-by: Mason James <mtj@kohaaloha.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This patch has been pushed to master.
Patch pushed to branch 3.10.x
This is now working on master.