[Koha-bugs] [Bug 11974] Enable non-default unix socket location for database connections.

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jun 2 16:44:14 CEST 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11974

--- Comment #23 from Olli-Antti Kivilahti <olli-antti.kivilahti at jns.fi> ---
Created attachment 63940
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=63940&action=edit
Bug 11974 - Enable non-default unix socket location for database connections.

-----------------
- BUSINESS CASE -
-----------------
Currently Koha doesn't support using a non-default unix socket for database
connections.
Using unix sockets is generally ~20-30% faster compared to using TCP packets.
Because
Koha abuses the database a lot, this will make a difference.

Using a non-default unix socket is useful if you want to run multiple databases
(eg. mysql and mariadb) in the same OS (eg. for testing purposes).
Also if one needs to move the unix socket, for example to share it between LXC
containers
using a shared partition, this feature might be handy.

Using unix sockets for connections are faster than TCP because there is no need
for TCP
and IP layer packet generation. Instead applications can communicate directly
without
extra overhead.
The benefit is marginal for a single query, around 0.5ms, but escalates
linearly when
hundreds of queries are performed.

------------
- SOLUTION -
------------
Mysql uses unix sockets for localhost connections only, but DBI::Mysql cannot
automatically
find the non-default socket path, thus it needs to be explicitly given.

This patch modifies the Koha::Database->_new_schema routine to check for the
presence of
mysql_socket in koha-conf.xml and prioritize the socket connection.

This patch works on MariaDB and Mysql and hopefully on PostgreSQL.

-------------
- TEST PLAN -
-------------
DEFAULT:
1.  edit koha-conf.xml
1.1.  put your socket path to the <socket>-attribute
      by default /var/run/mysqld/mysqld.sock
      or create the xml-entry <socket>/var/run/mysqld/mysqld.sock</socket>
2.  load any koha's web-page. Shouldn't get any errors.

BAD SOCKET:
1.  but a bad path as your mysql_socket, eg /var/run/mysqld/mysqld.sockBADBAD
2.  load any koha's web-page. It should fail due to DB connection error.

Thank you for testing!

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list