Merge pull request #1385 from TorstenDittmann/fix-broken-pdo-connection
fix(http): reset pdo connection if broken
This commit is contained in:
commit
e9a37e9a53
5 changed files with 15 additions and 5 deletions
|
@ -304,6 +304,10 @@ App::error(function ($error, $utopia, $request, $response, $layout, $project) {
|
||||||
/** @var Utopia\View $layout */
|
/** @var Utopia\View $layout */
|
||||||
/** @var Appwrite\Database\Document $project */
|
/** @var Appwrite\Database\Document $project */
|
||||||
|
|
||||||
|
if ($error instanceof PDOException) {
|
||||||
|
throw $error;
|
||||||
|
}
|
||||||
|
|
||||||
$route = $utopia->match($request);
|
$route = $utopia->match($request);
|
||||||
$template = ($route) ? $route->getLabel('error', null) : null;
|
$template = ($route) ? $route->getLabel('error', null) : null;
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,13 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo
|
||||||
Console::error('[Error] File: '.$th->getFile());
|
Console::error('[Error] File: '.$th->getFile());
|
||||||
Console::error('[Error] Line: '.$th->getLine());
|
Console::error('[Error] Line: '.$th->getLine());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset Database connection if PDOException was thrown.
|
||||||
|
*/
|
||||||
|
if ($th instanceof PDOException) {
|
||||||
|
$db = null;
|
||||||
|
}
|
||||||
|
|
||||||
if(App::isDevelopment()) {
|
if(App::isDevelopment()) {
|
||||||
$swooleResponse->end('error: '.$th->getMessage());
|
$swooleResponse->end('error: '.$th->getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,12 +164,11 @@ $register->set('dbPool', function () { // Register DB connection
|
||||||
$pool = new PDOPool((new PDOConfig())
|
$pool = new PDOPool((new PDOConfig())
|
||||||
->withHost($dbHost)
|
->withHost($dbHost)
|
||||||
->withPort($dbPort)
|
->withPort($dbPort)
|
||||||
// ->withUnixSocket('/tmp/mysql.sock')
|
|
||||||
->withDbName($dbScheme)
|
->withDbName($dbScheme)
|
||||||
->withCharset('utf8mb4')
|
->withCharset('utf8mb4')
|
||||||
->withUsername($dbUser)
|
->withUsername($dbUser)
|
||||||
->withPassword($dbPass)
|
->withPassword($dbPass)
|
||||||
);
|
, 16);
|
||||||
|
|
||||||
return $pool;
|
return $pool;
|
||||||
});
|
});
|
||||||
|
@ -189,7 +188,7 @@ $register->set('redisPool', function () {
|
||||||
->withPort($redisPort)
|
->withPort($redisPort)
|
||||||
->withAuth($redisAuth)
|
->withAuth($redisAuth)
|
||||||
->withDbIndex(0)
|
->withDbIndex(0)
|
||||||
);
|
, 16);
|
||||||
|
|
||||||
return $pool;
|
return $pool;
|
||||||
});
|
});
|
||||||
|
|
|
@ -342,7 +342,7 @@ services:
|
||||||
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
||||||
- MYSQL_USER=${_APP_DB_USER}
|
- MYSQL_USER=${_APP_DB_USER}
|
||||||
- MYSQL_PASSWORD=${_APP_DB_PASS}
|
- MYSQL_PASSWORD=${_APP_DB_PASS}
|
||||||
command: 'mysqld --innodb-flush-method=fsync'
|
command: 'mysqld --innodb-flush-method=fsync --wait_timeout=86400'
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:6.0-alpine3.12
|
image: redis:6.0-alpine3.12
|
||||||
|
|
|
@ -390,7 +390,7 @@ services:
|
||||||
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
- MYSQL_DATABASE=${_APP_DB_SCHEMA}
|
||||||
- MYSQL_USER=${_APP_DB_USER}
|
- MYSQL_USER=${_APP_DB_USER}
|
||||||
- MYSQL_PASSWORD=${_APP_DB_PASS}
|
- 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
|
# 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:
|
# smtp:
|
||||||
|
|
Loading…
Reference in a new issue