PDOException (1040)
SQLSTATE[HY000] [1040] Too many connections PDOException thrown with message "SQLSTATE[HY000] [1040] Too many connections" Stacktrace: #9 PDOException in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connectors/Connector.php:68 #8 PDO:__construct in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connectors/Connector.php:68 #7 Illuminate\Database\Connectors\Connector:createPdoConnection in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connectors/Connector.php:44 #6 Illuminate\Database\Connectors\Connector:createConnection in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connectors/MySqlConnector.php:24 #5 Illuminate\Database\Connectors\MySqlConnector:connect in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connectors/ConnectionFactory.php:183 #4 Illuminate\Database\Connectors\ConnectionFactory:Illuminate\Database\Connectors\{closure} in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connection.php:883 #3 call_user_func in /home/deploy/EHungry-4-simon/PHP/vendor/illuminate/database/Connection.php:883 #2 Illuminate\Database\Connection:getPdo in /home/deploy/EHungry-4-simon/Web/classes/DB.php:106 #1 DB:configure in /home/deploy/EHungry-4-simon/PHP/Global.php:162 #0 require in /home/deploy/EHungry-4-simon/Web/index.php:17
Stack frames (10)
9
PDOException
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
68
8
PDO
__construct
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
68
7
Illuminate
\
Database
\
Connectors
\
Connector
createPdoConnection
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
44
6
Illuminate
\
Database
\
Connectors
\
Connector
createConnection
/
vendor
/
illuminate
/
database
/
Connectors
/
MySqlConnector.php
24
5
Illuminate
\
Database
\
Connectors
\
MySqlConnector
connect
/
vendor
/
illuminate
/
database
/
Connectors
/
ConnectionFactory.php
183
4
Illuminate
\
Database
\
Connectors
\
ConnectionFactory
Illuminate
\
Database
\
Connectors
\
{closure}
/
vendor
/
illuminate
/
database
/
Connection.php
883
3
call_user_func
/
vendor
/
illuminate
/
database
/
Connection.php
883
2
Illuminate
\
Database
\
Connection
getPdo
/
home
/
deploy
/
EHungry-4-simon
/
Web
/
classes
/
DB.php
106
1
DB
configure
/
Global.php
162
0
require
/
home
/
deploy
/
EHungry-4-simon
/
Web
/
index.php
17
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
            );
        }
    }
 
    /**
     * Create a new PDO connection instance.
     *
     * @param  string  $dsn
     * @param  string  $username
     * @param  string  $password
     * @param  array  $options
     * @return \PDO
     */
    protected function createPdoConnection($dsn, $username, $password, $options)
    {
        if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
            return new PDOConnection($dsn, $username, $password, $options);
        }
 
        return new PDO($dsn, $username, $password, $options);
    }
 
    /**
     * Determine if the connection is persistent.
     *
     * @param  array  $options
     * @return bool
     */
    protected function isPersistentConnection($options)
    {
        return isset($options[PDO::ATTR_PERSISTENT]) &&
               $options[PDO::ATTR_PERSISTENT];
    }
 
    /**
     * Handle an exception that occurred during connect execution.
     *
     * @param  \Exception  $e
     * @param  string  $dsn
     * @param  string  $username
Arguments
  1. "SQLSTATE[HY000] [1040] Too many connections"
    
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
            );
        }
    }
 
    /**
     * Create a new PDO connection instance.
     *
     * @param  string  $dsn
     * @param  string  $username
     * @param  string  $password
     * @param  array  $options
     * @return \PDO
     */
    protected function createPdoConnection($dsn, $username, $password, $options)
    {
        if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
            return new PDOConnection($dsn, $username, $password, $options);
        }
 
        return new PDO($dsn, $username, $password, $options);
    }
 
    /**
     * Determine if the connection is persistent.
     *
     * @param  array  $options
     * @return bool
     */
    protected function isPersistentConnection($options)
    {
        return isset($options[PDO::ATTR_PERSISTENT]) &&
               $options[PDO::ATTR_PERSISTENT];
    }
 
    /**
     * Handle an exception that occurred during connect execution.
     *
     * @param  \Exception  $e
     * @param  string  $dsn
     * @param  string  $username
Arguments
  1. "mysql:host=10.21.3.62;dbname=EHungry-2-joel"
    
  2. "EHungry-2-joel"
    
  3. "32749238742938472"
    
  4. array:6 [
      8 => 0
      3 => 2
      11 => 0
      17 => false
      20 => false
      1002 => "SET time_zone = "-08:00""
    ]
    
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connectors
/
Connector.php
        PDO::ATTR_EMULATE_PREPARES => false,
    ];
 
    /**
     * Create a new PDO connection.
     *
     * @param  string  $dsn
     * @param  array   $config
     * @param  array   $options
     * @return \PDO
     */
    public function createConnection($dsn, array $config, array $options)
    {
        list($username, $password) = [
            Arr::get($config, 'username'), Arr::get($config, 'password'),
        ];
 
        try {
            return $this->createPdoConnection(
                $dsn, $username, $password, $options
            );
        } catch (Exception $e) {
            return $this->tryAgainIfCausedByLostConnection(
                $e, $dsn, $username, $password, $options
            );
        }
    }
 
    /**
     * Create a new PDO connection instance.
     *
     * @param  string  $dsn
     * @param  string  $username
     * @param  string  $password
     * @param  array  $options
     * @return \PDO
     */
    protected function createPdoConnection($dsn, $username, $password, $options)
    {
        if (class_exists(PDOConnection::class) && ! $this->isPersistentConnection($options)) {
Arguments
  1. "mysql:host=10.21.3.62;dbname=EHungry-2-joel"
    
  2. "EHungry-2-joel"
    
  3. "32749238742938472"
    
  4. array:6 [
      8 => 0
      3 => 2
      11 => 0
      17 => false
      20 => false
      1002 => "SET time_zone = "-08:00""
    ]
    
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connectors
/
MySqlConnector.php
use PDO;
 
class MySqlConnector extends Connector implements ConnectorInterface
{
    /**
     * Establish a database connection.
     *
     * @param  array  $config
     * @return \PDO
     */
    public function connect(array $config)
    {
        $dsn = $this->getDsn($config);
 
        $options = $this->getOptions($config);
 
        // We need to grab the PDO options that should be used while making the brand
        // new connection instance. The PDO options control various aspects of the
        // connection's behavior, and some might be specified by the developers.
        $connection = $this->createConnection($dsn, $config, $options);
 
        if (! empty($config['database'])) {
            $connection->exec("use `{$config['database']}`;");
        }
 
        $this->configureEncoding($connection, $config);
 
        // Next, we will check to see if a timezone has been specified in this config
        // and if it has we will issue a statement to modify the timezone with the
        // database. Setting this DB timezone is an optional configuration item.
        $this->configureTimezone($connection, $config);
 
        $this->setModes($connection, $config);
 
        return $connection;
    }
 
    /**
     * Set the connection character set and collation.
     *
Arguments
  1. "mysql:host=10.21.3.62;dbname=EHungry-2-joel"
    
  2. array:10 [
      "driver" => "mysql"
      "host" => "10.21.3.62"
      "database" => "EHungry-2-joel"
      "username" => "EHungry-2-joel"
      "password" => "32749238742938472"
      "charset" => "latin1"
      "collation" => "latin1_swedish_ci"
      "options" => array:1 [
        1002 => "SET time_zone = "-08:00""
      ]
      "prefix" => ""
      "name" => "default"
    ]
    
  3. array:6 [
      8 => 0
      3 => 2
      11 => 0
      17 => false
      20 => false
      1002 => "SET time_zone = "-08:00""
    ]
    
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connectors
/
ConnectionFactory.php
    {
        return array_key_exists('host', $config)
                            ? $this->createPdoResolverWithHosts($config)
                            : $this->createPdoResolverWithoutHosts($config);
    }
 
    /**
     * Create a new Closure that resolves to a PDO instance with a specific host or an array of hosts.
     *
     * @param  array  $config
     * @return \Closure
     */
    protected function createPdoResolverWithHosts(array $config)
    {
        return function () use ($config) {
            foreach (Arr::shuffle($hosts = $this->parseHosts($config)) as $key => $host) {
                $config['host'] = $host;
 
                try {
                    return $this->createConnector($config)->connect($config);
                } catch (PDOException $e) {
                    if (count($hosts) - 1 === $key && $this->container->bound(ExceptionHandler::class)) {
                        $this->container->make(ExceptionHandler::class)->report($e);
                    }
                }
            }
 
            throw $e;
        };
    }
 
    /**
     * Parse the hosts configuration item into an array.
     *
     * @param  array  $config
     * @return array
     */
    protected function parseHosts(array $config)
    {
        $hosts = array_wrap($config['host']);
Arguments
  1. array:10 [
      "driver" => "mysql"
      "host" => "10.21.3.62"
      "database" => "EHungry-2-joel"
      "username" => "EHungry-2-joel"
      "password" => "32749238742938472"
      "charset" => "latin1"
      "collation" => "latin1_swedish_ci"
      "options" => array:1 [
        1002 => "SET time_zone = "-08:00""
      ]
      "prefix" => ""
      "name" => "default"
    ]
    
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connection.php
        if (is_null($this->doctrineConnection)) {
            $data = ['pdo' => $this->getPdo(), 'dbname' => $this->getConfig('database')];
 
            $this->doctrineConnection = new DoctrineConnection(
                $data, $this->getDoctrineDriver()
            );
        }
 
        return $this->doctrineConnection;
    }
 
    /**
     * Get the current PDO connection.
     *
     * @return \PDO
     */
    public function getPdo()
    {
        if ($this->pdo instanceof Closure) {
            return $this->pdo = call_user_func($this->pdo);
        }
 
        return $this->pdo;
    }
 
    /**
     * Get the current PDO connection used for reading.
     *
     * @return \PDO
     */
    public function getReadPdo()
    {
        if ($this->transactions >= 1) {
            return $this->getPdo();
        }
 
        if ($this->readPdo instanceof Closure) {
            return $this->readPdo = call_user_func($this->readPdo);
        }
 
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
vendor
/
illuminate
/
database
/
Connection.php
        if (is_null($this->doctrineConnection)) {
            $data = ['pdo' => $this->getPdo(), 'dbname' => $this->getConfig('database')];
 
            $this->doctrineConnection = new DoctrineConnection(
                $data, $this->getDoctrineDriver()
            );
        }
 
        return $this->doctrineConnection;
    }
 
    /**
     * Get the current PDO connection.
     *
     * @return \PDO
     */
    public function getPdo()
    {
        if ($this->pdo instanceof Closure) {
            return $this->pdo = call_user_func($this->pdo);
        }
 
        return $this->pdo;
    }
 
    /**
     * Get the current PDO connection used for reading.
     *
     * @return \PDO
     */
    public function getReadPdo()
    {
        if ($this->transactions >= 1) {
            return $this->getPdo();
        }
 
        if ($this->readPdo instanceof Closure) {
            return $this->readPdo = call_user_func($this->readPdo);
        }
 
Arguments
  1. Closure {
      class: "Illuminate\Database\Connectors\ConnectionFactory"
      this: ConnectionFactory { …}
      use: {
        $config: array:10 [
          "driver" => "mysql"
          "host" => "10.21.3.62"
          "database" => "EHungry-2-joel"
          "username" => "EHungry-2-joel"
          "password" => "32749238742938472"
          "charset" => "latin1"
          "collation" => "latin1_swedish_ci"
          "options" => array:1 [
            1002 => "SET time_zone = "-08:00""
          ]
          "prefix" => ""
          "name" => "default"
        ]
      }
    }
    
/
home
/
deploy
/
EHungry-4-simon
/
Web
/
classes
/
DB.php
            'username' => $user,
            'password' => $pwd,
            'charset' => 'latin1',
            'collation' => 'latin1_swedish_ci',
            'options' => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET time_zone = "'.date('P').'"'] //if it gets a bit lost
        ]);
 
        static::$capsule->setAsGlobal();
        static::$capsule->setEventDispatcher(new EventDispatcher);
        static::$capsule->bootEloquent();
        //extras: add a CacheManager and, possibly for later, a Translator helper
 
        //TODO: migrate this to serializeDate() when Eloquent 7.x lands
        \Carbon\Carbon::serializeUsing(function (\Carbon\Carbon $c) {
            return $c->format('c');
        });
 
        try {
            //using customized PDO classes to be able to log them - to DebugBar and the test logger
            static::$pdo = new TraceablePDO(self::$capsule->getConnection()->getPdo());
            static::$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, [LoggablePDOStatement::class, [static::$pdo]]);
            static::$capsule->getConnection()->setPdo(static::$pdo);
        } catch (PDOException $e) {
            if (DevLevel >= 2) {
                throw $e;
            } else {
                static::dberror($e->getMessage());
                return false;
            }
        }
 
        if (App::debugbar()) {
            App::debugbar()['db']->addConnection(static::$pdo, '');
        }
 
        return true;
    }
 
    protected static function installMysqlSilent() {
        Connection::resolverFor('mysql', function ($pdo, $db, $prefix, $config) {
/
home
/
deploy
/
EHungry-4-simon
/
PHP
/
Global.php
// TODO: figure out a way to enable IS_DEBUG through domains in production (i.e. in the customer pages of custom domain restaurants)
define(
    'IS_DEBUG',
    (DevLevel > 0 || isset($_SESSION['admin_id'])) //is a developer or a SuperAdmin
    && (isset($_REQUEST['debug']) || isset($_COOKIE['debug'])) //enabled debug, now or previously
    && (!isset($_REQUEST['debug']) || $_REQUEST['debug'] != '0') //and is passively using it, and not trying to disable
);
 
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == '0') {
    deletecookie('debug', '/');
} elseif (IS_DEBUG) {
    setcookie('debug', '1', time() + (60 * 60), '/');
}
 
App::initializeDebugbar();
 
///////////////////////////////////////////////////////////////////////////////
// Database, randomized logs, and i18n (which "depends" on debugbar)
$db_conn = DB::conn();
if (!DB::configure(DB_HOST, DB_USER, DB_PASS, DB_NAME)) {
    Splunk::log(Splunk::LOG_DB_CONN, ['error' => DB::getError()]);
    http_response_code(503);
    include(App_Path.'/Web/closed.php');
    exit(0);
}
 
App::initializeRandomizedLogs();
 
\eHungry\i18n\Locale::setup();
 
///////////////////////////////////////////////////////////////////////////////
// Now that we have a database, we can check for necessary session overrides.
// In some cases, we still allow URL-based session tokens. It may come from a bunch of *internal* places:
// - mercury/vantiv redirects after the payment is completed/declined
// - stripe redirects after admin/processor (check?)
// - anywhere else using:
//   - formatCustomerLink()
//   - getSessionTokenForUrl()
//       - redirectToCustomerFromAdmin - ordering/editing in behalf of a customer account
//       - redirecting from an insecure URL that requested a secure operation (i.e. login, credit cards, password...) (Global.php:446)
Arguments
  1. "10.21.3.62"
    
  2. "EHungry-2-joel"
    
  3. "32749238742938472"
    
  4. "EHungry-2-joel"
    
/
home
/
deploy
/
EHungry-4-simon
/
Web
/
index.php
<? /** @noinspection PhpIncludeInspection - to avoid marking dynamic includes */
 
//TODO create a «root»/_bootstrap.php which can be used by .psysh.php, tests/bootstrap.php and Web/index.php
require(dirname(__DIR__).'/PHP/base_consts.php');
require(dirname(__DIR__).'/PHP/autoloader.php');
initializeAutoLoader();
 
//disabled for now since we already have our own Alerts infrastructure, and it's not worth it to append another cloud provider to the startup of every freaking request; it's also not possible to catch errors this early if we depend on database checks, but we'll leave it here in case we change our mind?
//ErrorHandlers::sentryInit(); //early catch of errors and failsafe for smaller controllers, not in Sentry
 
App::startTime();
 
ErrorHandlers::register();
 
// Global.php is the core setup file for the application
App::debugbarTime('Global.php');
require(dirname(__DIR__) . '/PHP/Global.php');
App::debugbarTime('Global.php');
/** @var string $controller The main controller - defined at /PHP/Global.php */
 
App::debugbarTime('Sentry - controller');
ErrorHandlers::sentryInit($controller); //doesn't always do much - not every controller has a Sentry project
App::debugbarTime('Sentry - controller');
 
App::debugbarTime("controller: $controller");
apache_note('AppController', $controller);
if (file_exists(CORE_PATH."lib/helpers/$controller.php")) {
    require CORE_PATH."lib/helpers/$controller.php";
}
require CORE_PATH."controllers/$controller.php";
App::debugbarTime("controller: $controller");
 
Arguments
  1. "/home/deploy/EHungry-4-simon/PHP/Global.php"
    

Environment & details:

Key Value
aid
"restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
empty
empty
Key Value
PHPSESSID
"shdlcncgau8j9ariqdgtosbr1p"
Key Value
loc
"en_US"
customer_account_id
20746
cart
Cart {}
restaurant_id
10644
app_banner_shown
true
menu_id
13382
status
array:2 [
  1 => []
  2 => array:1 [
    0 => "The system encountered an error! Check logs for details."
  ]
]
Key Value
UNIQUE_ID
"aTmvDD8LDpNxpsw3PpzXAQAAAIk"
SCRIPT_URL
"/restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
SCRIPT_URI
"http://www.springroll.com.4.simon.ehungry.net/restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
HTTP_HOST
"www.springroll.com.4.simon.ehungry.net"
HTTP_X_REAL_IP
"216.73.216.186"
HTTP_X_FORWARDED_FOR
"216.73.216.186"
HTTP_X_CONFKEY
"Main_Domain:6462"
HTTP_SCHEME
"https"
HTTP_EHENV
"TODO"
HTTP_CONNECTION
"close"
HTTP_ACCEPT
"*/*"
HTTP_USER_AGENT
"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"
HTTP_ACCEPT_ENCODING
"gzip, br, zstd, deflate"
HTTP_COOKIE
"PHPSESSID=shdlcncgau8j9ariqdgtosbr1p"
PATH
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
SERVER_SIGNATURE
""
SERVER_SOFTWARE
"Apache/2.4.62 () mod_wsgi/4.6.5 Python/3.7 PHP/7.2.34"
SERVER_NAME
"www.springroll.com.4.simon.ehungry.net"
SERVER_ADDR
"127.0.0.1"
SERVER_PORT
"80"
REMOTE_ADDR
"127.0.0.1"
DOCUMENT_ROOT
"/home/deploy/EHungry-4-simon/Web"
REQUEST_SCHEME
"http"
CONTEXT_PREFIX
""
CONTEXT_DOCUMENT_ROOT
"/home/deploy/EHungry-4-simon/Web"
SERVER_ADMIN
"root@localhost"
SCRIPT_FILENAME
"/home/deploy/EHungry-4-simon/Web/index.php"
REMOTE_PORT
"41668"
GATEWAY_INTERFACE
"CGI/1.1"
SERVER_PROTOCOL
"HTTP/1.0"
REQUEST_METHOD
"GET"
QUERY_STRING
"aid=restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
REQUEST_URI
"/restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
SCRIPT_NAME
"/restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
PHP_SELF
"/restaurant/chopstickshousesi/order/main/lunch-special/l52-jumbo-shrimp-veg-w-garlic-sauce"
REQUEST_TIME_FLOAT
1765388044.546
REQUEST_TIME
1765388044
empty
0. Whoops\Handler\PrettyPageHandler

Fatal error: Uncaught Error: Call to a member function getExecutedStatements() on null in /home/deploy/EHungry-4-simon/Web/classes/DB.php:182 Stack trace: #0 /home/deploy/EHungry-4-simon/Web/classes/ErrorHandlers.class.php(234): DB::logStatsToSplunk() #1 /home/deploy/EHungry-4-simon/Web/classes/ErrorHandlers.class.php(56): ErrorHandlers::shutdown() #2 [internal function]: ErrorHandlers::{closure}() #3 {main} thrown in /home/deploy/EHungry-4-simon/Web/classes/DB.php on line 182