Gateway 环境捕获不到 "MySQL server has gone away“异常

在 Gateway 里面,获取 SQL 连接的代码:
$ident = md5($dsn);

try {
if(!empty(self::$instances[$ident])){
$message = self::$instances[$ident]->getAttribute(PDO::ATTR_SERVER_INFO);
if(strpos($message, 'Lost connection to MySQL server during query') !== FALSE || strpos($message, 'MySQL server has gone away') !== FALSE){
throw new \PDOException("MySQL server has gone away!");
}
}else{
self::$instances[$ident] = new PDO($dsn, Config::DB_USERNAME, Config::DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET CHARACTER SET utf8;', PDO::ATTR_PERSISTENT => Config::DB_ATTR_PERSISTENT));
self::$instances[$ident]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (Config::DB_SET_TIMEZONE == TRUE) {
static::setDbTimezone(Config::DB_TIMEZONE, self::$instances[$ident]);
}
}

} catch (\Exception $e) {
Log::getLogger()->error($e->getMessage());
self::$instances[$ident] = NULL;
self::$instances[$ident] = new PDO($dsn, Config::DB_USERNAME, Config::DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET CHARACTER SET utf8;', PDO::ATTR_PERSISTENT => Config::DB_ATTR_PERSISTENT));
self::$instances[$ident]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (Config::DB_SET_TIMEZONE == TRUE) {
static::setDbTimezone(Config::DB_TIMEZONE, self::$instances[$ident]);
}
}

return self::$instances[$ident];
把 Mysql 的 wait_timeout 设置 6 秒,执行跑脚本,sleep(7) 之后,在获取pdo ,会直接抛出异常;
但是, 把这个代码放在 Gateway 环境里面,设置估计7秒之后,才去获取 pdo,没有抛出异常,而是 PDO::getAttribute 直接返回了 “Lost connection to MySQL server during query”, 这是什么梗?
已邀请:

要回复问题请先登录注册