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 mysql - Laravel and Remote Database Dropping - Stack Overflow 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

Hi @asmecher,
We are getting this entry www-error.log:
[04-Jun-2020 05:10:02 Atlantic/Canary] ojs2: DB Error: MySQL server has gone away.

since a couple of months.

Can you think of any reason to this problem?

FYI: Architecture is PHP-FPM

Thanks in advance for your reply.

Regards,
Juan

Hi @jascanio,

Hmm, it’s hard to know what’s happening without more information… Is this a message that happens repeatably? Does it only occur e.g. when the website is busy? Is it disrupting users, or only appearing in the log?

Thanks,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher,
Thanks for your reply.

It is a message that appears with some frequency in the log. It is not repeating constantly, but with some frequency everyday. I could not really tell you if it happens when the website is too busy.

The fact is that since data base was moved to a new server we are experiencing some problems. That is why we are digging into the error log.

Just to update you, setting database persistent connections to OFF resolved the issue “Database connection lost” white pages being displayed to users.

However, we are still dealing with the following set of issues:

  • Some authors and reviewers cannot upload their documents within the review stage
  • Other users are being logged out during their session (we have now set session_check_ip = Off, just in case this has anything to do with it), although we were not having this issue before
  • A couple or reviewers assured they had uploaded their review documents, despite we could not see them. The only way to reach the documents was going to the Editorial History, find the action, drop down blue arrow and find the document there.

I’m thinking of a combination of a firewall/proxy (remote or local) issue together with database issues. But I’m not sure.

Any idea or suggestion? Something in particular to search for in the log?

Thanks very much in advance for your reply.

Regards,
Juan

Hi @jascanio,

I think those will all be unrelated to the database persistence issue you experienced. The session logout issue should be solved by changing session_check_ip, and you may be able to resolve the author and reviewer upload problem by double-checking your file permissions in your files_dir. I’d recommend posting the last issue as a new topic, with as much information as you can include on what’s happening.

Regards,
Alec Smecher
Public Knowledge Project Team