diff --git a/app/controllers/general.php b/app/controllers/general.php index cd95b74a0..708e24985 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -304,6 +304,10 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) { /** @var Utopia\View $layout */ /** @var Appwrite\Database\Document $project */ + if ($error instanceof PDOException) { + throw $error; + } + $route = $utopia->match($request); $template = ($route) ? $route->getLabel('error', null) : null; diff --git a/app/http.php b/app/http.php index baf069324..9a3a5459d 100644 --- a/app/http.php +++ b/app/http.php @@ -99,6 +99,13 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo Console::error('[Error] File: '.$th->getFile()); Console::error('[Error] Line: '.$th->getLine()); + /** + * Reset Database connection if PDOException was thrown. + */ + if ($th instanceof PDOException) { + $db = null; + } + if(App::isDevelopment()) { $swooleResponse->end('error: '.$th->getMessage()); } diff --git a/app/init.php b/app/init.php index 302ce0f65..617322f9d 100644 --- a/app/init.php +++ b/app/init.php @@ -164,12 +164,11 @@ $register->set('dbPool', function () { // Register DB connection $pool = new PDOPool((new PDOConfig()) ->withHost($dbHost) ->withPort($dbPort) - // ->withUnixSocket('/tmp/mysql.sock') ->withDbName($dbScheme) ->withCharset('utf8mb4') ->withUsername($dbUser) ->withPassword($dbPass) - ); + , 16); return $pool; }); @@ -189,7 +188,7 @@ $register->set('redisPool', function () { ->withPort($redisPort) ->withAuth($redisAuth) ->withDbIndex(0) - ); + , 16); return $pool; }); diff --git a/app/views/install/compose.phtml b/app/views/install/compose.phtml index 1acc35066..c110fcd4e 100644 --- a/app/views/install/compose.phtml +++ b/app/views/install/compose.phtml @@ -342,7 +342,7 @@ services: - MYSQL_DATABASE=${_APP_DB_SCHEMA} - MYSQL_USER=${_APP_DB_USER} - MYSQL_PASSWORD=${_APP_DB_PASS} - command: 'mysqld --innodb-flush-method=fsync' + command: 'mysqld --innodb-flush-method=fsync --wait_timeout=86400' redis: image: redis:6.0-alpine3.12 diff --git a/docker-compose.yml b/docker-compose.yml index fb8a8355f..621304f0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -390,7 +390,7 @@ services: - MYSQL_DATABASE=${_APP_DB_SCHEMA} - MYSQL_USER=${_APP_DB_USER} - MYSQL_PASSWORD=${_APP_DB_PASS} - command: 'mysqld --innodb-flush-method=fsync' # add ' --query_cache_size=0' for DB tests + command: 'mysqld --innodb-flush-method=fsync --wait_timeout=86400' # add ' --query_cache_size=0' for DB tests # command: mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bu && mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bu # smtp: