Assigning a timeout to database persistence

Hi,
OJS 3.1.1-4, LAMP

I’m getting Database connection lost pages every now and then, when logged in.
This has started when my university moved the database to another server one month ago.
Apparently it only occurs when users are logged in.

The sys admin department says that I should set database persistent connections to OFF (currently ON) as they have set a timeout of 180 secs to server’s databases. Alternatively, they say if I could set timeout to persistance below that time.

I will set persistance to OFF, although I’m not 100% sure that is the problem.

Is there a way to specify a persistence timeout valur, apart from on/off?
Regards
Juan
PS.: FYI this is a piece of errors in /var/log/php-fpm

27-Apr-2020 13:14:11 Atlantic/Canary] PHP Fatal error: Uncaught exception
‘PDOException’ with message ‘SQLSTATE[HY000] [2002] Permiso denegado’ in
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/Connector.php:47
Stack trace:
#0
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/Connector.php(47):
PDO->__construct(‘mysql:host=mysq…’, ‘’, ‘’, Array)
#1
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/MySqlConnector.php(20):
Illuminate\Database\Connectors\Connector->createConnection(‘mysql:host=mysq…’,
Array, Array)
#2
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/ConnectionFactory.php(59):
Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/ConnectionFactory.php(47):
Illuminate\Database\Connectors\ConnectionFactory->createSingleConnection(Array)
#4 /var/www in
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/Connector.php
on line 47

[15-May-2020 11:44:38 Atlantic/Canary] PHP Fatal error: Uncaught exception
‘PDOException’ with message ‘SQLSTATE[HY000] [2002] Permiso denegado’ in
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/Connector.php:47
Stack trace:
#0
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/Connector.php(47):
PDO->__construct(‘mysql:host=mysq…’, ‘’, ‘’, Array)
#1
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/MySqlConnector.php(20):
Illuminate\Database\Connectors\Connector->createConnection(‘mysql:host=mysq…’,
Array, Array)
#2
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/ConnectionFactory.php(59):
Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#3
/var/www/html/revistas/lib/pkp/lib/vendor/illuminate/database/Illuminate/Database/Connectors/ConnectionFactory.php(47):
Illuminate\Database\Connectors\ConnectionFactory->createSingleConnection(Array)

[11-May-2020 16:41:14 Atlantic/Canary] ojs2: DB Error: MySQL server has gone
away

Hi @jascanio,

Note that your stack trace included partial database credentials – I’ve removed them, but I’d recommend changing your credentials ASAP.

OJS currently uses two mechanisms to connect to the database – one through ADODB and the mysqli_connect toolset, the other using PDO. The front end only uses the ADODB toolset, and the back end uses a combination of the two. The error message you posted relates to the PDO toolset only, which would explain why users see the problem only when logged in.

In OJS 3.1.x, you can see the parameters that are being passed to the PDO connection in lib/pkp/classes/services/queryBuilders/BaseQueryBuilder.inc.php in the bootstrap function. I believe persistent database connections are disabled by default with Laravel’s PDO implementation – but see https://stackoverflow.com/questions/47679892/laravel-and-remote-database-dropping for a similar issue to what you’re describing, with some suggested solutions.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Thanks for your reply and extra info.

Before your replied I had set in config.inc.php persistency to “off”, just to check whether this would resolve the problem.

I’m waiting for users’ feedback.

In case this will not resolve the issue I will apply your recommendation.

Just one more question. Do you think that having persistancy set to “off” will have a negative effect in user experience?

Thanks!

Regards,
Juan

Hi @jascanio,

No, turning off persistence is fine – MySQL has very low connection overhead.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Ok. Thanks for your reply.
Regards,
Juan