From 3fc0ba3a632bfdf276a93cb94cfbde216437d400 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Fri, 21 Jun 2019 08:22:51 -0500 Subject: [PATCH] Added DATBASE_TIMEOUT constant to allow customizing database wait time --- core/dbengine.php | 2 +- core/sys_config.php | 1 + ext/rule34/main.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/dbengine.php b/core/dbengine.php index 880ff013..79b407ec 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -74,7 +74,7 @@ class PostgreSQL extends DBEngine } else { $db->exec("SET application_name TO 'shimmie [local]';"); } - $db->exec("SET statement_timeout TO 10000;"); + $db->exec("SET statement_timeout TO ".DATABASE_TIMEOUT.";"); } public function scoreql_to_sql(string $data): string diff --git a/core/sys_config.php b/core/sys_config.php index a2fbefee..13b18d7e 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -27,6 +27,7 @@ function _d(string $name, $value): void } _d("DATABASE_DSN", null); // string PDO database connection details _d("DATABASE_KA", true); // string Keep database connection alive +_d("DATABASE_TIMEOUT", 10000); // string Keep database connection alive _d("CACHE_DSN", null); // string cache connection details _d("DEBUG", false); // boolean print various debugging details _d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log diff --git a/ext/rule34/main.php b/ext/rule34/main.php index 529e6201..e1e6f5a3 100644 --- a/ext/rule34/main.php +++ b/ext/rule34/main.php @@ -73,7 +73,7 @@ class Rule34 extends Extension global $database, $page, $user; if ($user->can("delete_user")) { // deleting users can take a while - $database->execute("SET statement_timeout TO 25000;"); + $database->execute("SET statement_timeout TO ".(DATABASE_TIMEOUT+15000).";"); } if (function_exists("sd_notify_watchdog")) {