Koha/t/db_dependent
Jonathan Druart 4ae3665ad8 Bug 10611: Use mysql_auto_reconnect instead of ping
DBD::Mysql provides a mysql_auto_reconnect flag. Using it avoids
the time required to do a $dbh->ping().

Benchmarks:

use Modern::Perl;
use C4::Context;
for ( 1 .. 1000 ) {
    $dbh = C4::Context->dbh;
}

* without this patch on a local DB:
perl t.pl  0,49s user 0,02s system 98% cpu 0,525 total
* without this patch on a remote DB:
perl t.pl  0,52s user 0,05s system 1% cpu 37,358 total
* with this patch on a local DB:
perl t.pl  0,46s user 0,04s system 99% cpu 0,509 total
* with this patch on a remote DB:
perl t.pl  0,49s user 0,02s system 56% cpu 0,892 total

Testing the auto reconnect:
use Modern::Perl;
use C4::Context;
my $ping = $dbh->ping;
say $ping;
$dbh->disconnect;
$ping = $dbh->ping;
say $ping;

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Comment: Real improvement. No koha-qa errors

prove t/db_dependent/Circulation_issuingrules.t produces no error
prove t/db_dependent/Context.t produces no error

Test
1) dumped Koha DB, load it on a non-local server
2) run sample script whit and without patch, local and remote

use Modern::Perl;
use C4::Context;
for ( 1 .. 100000 ) {
    my $dbh = C4::Context->dbh;
}

Main difference I note is with remote server
a) without patch
real    0m16.357s
user    0m2.592s
sys     0m2.132s

b) with patch
real    0m0.259s
user    0m0.240s
sys     0m0.012s

I think this could be good for DBs placed on
remote servers

Bug 10611: add a "new" parameter to C4::Context->dbh

When dbh->disconnect is called and the mysql_auto_reconnect flag is set,
the dbh is not recreated: the old one is used.

Adding a new flag, we can now force the C4::Context->dbh method to
return a new dbh.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Bug 10611: Followup: remove useless calls to dbh->disconnect

These 3 calls to disconnect are done at the end of the script, they are
useless.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2014-03-10 23:15:35 +00:00
..
Acquisition Bug 11549: Add regression test 2014-01-23 16:17:24 +00:00
Circulation Bug 11338: add unit tests for DelItemCheck 2013-12-25 17:07:53 +00:00
data Bug 11096: add regression tests for indexing/retrieving large MARC records 2014-02-28 19:48:37 +00:00
Koha Bug 11279: (follow-up) remove unnecessary check on number of quotes 2013-12-19 15:06:39 +00:00
Labels
LDAP
Members
Record
Reports
Serials
www
00-strict.t
Accounts.t
Acquisition.t Bug 11224: (follow-up) clean up unit test for bug 10723 2014-03-10 16:44:00 +00:00
Amazon.t
Auth.t Bug 10952: (follow-up) remove mention of KohaOpacRecentSearches cookie 2014-01-10 16:55:37 +00:00
Auth_SearchHistorySession.t Bug 10952: (follow-up) comments fixes and unit tests 2014-01-10 16:21:18 +00:00
Auth_with_cas.t
AuthoritiesMarc.t
BackgroundJob.t
Barcodes.t
Biblio.t
Bookseller.t Bug 11457: avoid spurious test failure in t/db_dependent/Bookseller.t 2014-01-09 19:09:56 +00:00
Borrower_Debarments.t
Branch.t
Budgets.t
Category.t Bug 11543: (followup) add one more test 2014-01-15 19:58:30 +00:00
check_sysprefs.t
Circulation.t Bug 11336: (follow-up) fix typo in previous follow-up 2014-01-06 16:16:22 +00:00
Circulation_Branch.t
Circulation_issue.t
Circulation_Issuingrule.t
Circulation_issuingrules.t
Circulation_OfflineOperation.t
Circulation_transfers.t Bug 11470: fix occassional spurious test failure in Circulation_transfers.t 2014-01-06 05:31:21 +00:00
ClassSource.t
Context.t Bug 10611: Use mysql_auto_reconnect instead of ping 2014-03-10 23:15:35 +00:00
CourseReserves.t
Csv.t
External_BakerTaylor.t
Heading_MARC21.t
Holds.t Bug 10452: [QA Followup] - Unit tests 2014-03-10 18:15:33 +00:00
HoldsQueue.t
Holidays.t Bug 11112: (follow-up) repair Koha::Calendar->add_holiday() 2013-12-10 18:19:15 +00:00
ILSDI_Services.t
Installer.t Bug 11541: (follow-up) move Installer.t to t/db_dependent 2014-01-14 21:43:56 +00:00
Items.t
KitchenSinkPlugin.kpz
Koha.t
Koha_Authority.t
Koha_borrower_modifications.t
Koha_Database.t
Koha_template_plugin_Branches.t Bug 11779: (follow-up) improve GetLoggedInBranchcode() and add test cases 2014-02-19 16:40:06 +00:00
Koha_template_plugin_KohaDates.t
Languages.t Bug 11545: (follow-up) move Languages.t to t/db_dependent 2014-01-14 20:48:33 +00:00
Letters.t Bug 11208: regression test for failing SMS messages 2013-12-30 16:45:45 +00:00
Linker_FirstMatch.t
Log.t
MarcModificationTemplates.t
Members.t Bug 11221: (follow-up) test for NULL rather than empty string 2013-11-19 15:35:25 +00:00
Members_columns.t
PatronLists.t
Plugins.t
Ratings.t
Record.t Bug 11066: (follow-up) add regression test 2014-01-03 15:54:45 +00:00
RecordProcessor_EmbedSeeFromHeadings.t
Reports.t
Reports_Guided.t
ReportsGuided.t
Reserves.t Bug 8918: (follow-up) support creating brief UNIAMRC bibs in Reserves.t 2014-03-10 17:35:38 +00:00
rollingloans.t
RotatingCollections.t
Search.t Bug 11096: support the retrieval of large MARCXML records 2014-02-28 19:50:09 +00:00
Search_SearchHistory.t
Serials.t
Serials_2.t
Service.t
ShelfBrowser.t
SIP_ILS.t
SQLHelper.t
SuggestionEngine_ExplodedTerms.t
Suggestions.t
sysprefs.t
Tags.t
UploadedFile.t
VirtualShelves.t
VirtualShelves_Page.t
XISBN.t Bug 11439: (follow-up) adjust for change in list returned by OCLC XISBN 2014-01-30 15:48:48 +00:00
zebra_config.pl Bug 11078: Add locking to rebuild_zebra 2014-02-28 22:21:41 +00:00