Maybe this can help others in my situation.
After installing ModX 2.0.2 on OVH, I could log in manager but after few clics i lost the session. After some investigations, i saw in core/cache/logs some PDO exceptions :
(ERROR in xPDO::connect @ /xxx/www/core/xpdo/xpdo.class.php : 324) SQLSTATE[42000] [1203] User xxx already has more than 'max_user_connections' active connections
It was related to manager’s Ajax concurrent calls and my 60gp shared hosting which seems to offer only 3 concurrent mysql connections.
As I don’t wanna change my hosting, I patched xpdo to be able to retry the connection with some delay :
Original code (core/xpdo/xpdo.core.class @314)
try {
$this->pdo= new PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
$errorCode= $this->pdo->errorCode();
} catch (PDOException $xe) {
$this->log(xPDO::LOG_LEVEL_ERROR, $xe->getMessage(), '', __METHOD__, __FILE__, __LINE__);
return false;
} catch (Exception $e) {
$this->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage(), '', __METHOD__, __FILE__, __LINE__);
return false;
}
With 10 retries and a sleep between 100 and 150ms :
for ($i = 1; $i <= 10; $i++) {
try {
$this->pdo= new PDO($this->config['dsn'], $this->config['username'], $this->config['password'], $this->config['driverOptions']);
$errorCode= $this->pdo->errorCode();
break;
} catch (PDOException $xe) {
if (strstr($xe->getMessage(), 'SQLSTATE[42000] [1203]')) {
usleep(rand(100000, 150000));
} else {
$this->log(xPDO::LOG_LEVEL_ERROR, $xe->getMessage(), '', __METHOD__, __FILE__, __LINE__);
return false;
}
} catch (Exception $e) {
$this->log(xPDO::LOG_LEVEL_ERROR, $e->getMessage(), '', __METHOD__, __FILE__, __LINE__);
return false;
}
}
This code is simple but saved me for the moment