1
0
Fork 0
mirror of synced 2024-06-26 10:10:57 +12:00

Merge pull request #1385 from TorstenDittmann/fix-broken-pdo-connection

fix(http): reset pdo connection if broken
This commit is contained in:
Torsten Dittmann 2021-07-12 18:39:57 +02:00 committed by GitHub
commit e9a37e9a53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 5 deletions

View file

@ -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;

View file

@ -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());
}

View file

@ -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;
});

View file

@ -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

View file

@ -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: