Too Many Connections error (Laravel5) #4031

rmblstrp opened this Issue Feb 23, 2017 · 1 comment


None yet
2 participants

rmblstrp commented Feb 23, 2017

Similar Issues: #2958, #1591, #2060

Running a large suite of tests with models that have different connection settings throws the "Too Many Connections" error when running tests locally or in a CI pipeline.

The irony of the issue is that the source code makes specific mention of the "Too Many Connections" issue and tries to close open connections. However, it only closes the the default connection and ignores other open connections.

// disconnect from DB to prevent "Too many connections" issue
if (isset($this->app['db'])) {


  • Codeception version: 2.2.8
  • PHP Version: 5.6.22
  • Operating System: Amazon Linux AMI release 2014.03
  • Installation type: Composer
  • List of installed packages
aws/aws-sdk-php                       3.19.32 AWS SDK for PHP - Use Amazon Web Services in your PHP project
barryvdh/laravel-debugbar             v2.2.2  PHP Debugbar integration for Laravel
barryvdh/laravel-ide-helper           v2.1.4  Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
behat/gherkin                         v4.4.1  Gherkin DSL parser for PHP 5.3
chobie/jira-api-restclient            v1.0.0  JIRA REST API.
classpreloader/classpreloader         3.0.0   Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specifi...
codeception/c3                        2.0.9   CodeCoverage collector for Codeception
codeception/codeception               2.2.8   BDD-style testing framework
codeception/mockery-module            0.2.2   Mockery Module for Codeception
dnoegel/php-xdg-base-dir              0.1     implementation of xdg base directory specification for php
doctrine/annotations                  v1.2.7  Docblock Annotations Parser
doctrine/cache                        v1.6.0  Caching library offering an object-oriented API for many cache backends
doctrine/collections                  v1.3.0  Collections Abstraction library
doctrine/common                       v2.6.1  Common Library for Doctrine projects
doctrine/dbal                         v2.5.4  Database Abstraction Layer
doctrine/inflector                    v1.1.0  Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                 1.0.5   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                        v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
facebook/webdriver                    1.1.1   A PHP client for WebDriver
fzaninotto/faker                      v1.6.0  Faker is a PHP library that generates fake data for you.
guzzlehttp/guzzle                     6.2.2   Guzzle is a PHP HTTP client library
guzzlehttp/promises                   1.2.0   Guzzle promises library
guzzlehttp/psr7                       1.3.1   PSR-7 message implementation
hamcrest/hamcrest-php                 v1.2.2  This is the PHP port of Hamcrest Matchers
igaster/laravel-theme                 v1.1.3  Laravel 5 Themes: Asset & Views folder per theme. Theme inheritance. Blade integration and more...
influxdb/influxdb-php                 1.14.3  InfluxDB client library for PHP
jakoch/phantomjs-installer            2.1.1   A Composer package which installs the PhantomJS binary (Linux, Windows, Mac) into `/bin` of your project.
jakub-onderka/php-console-color       0.1
jakub-onderka/php-console-highlighter v0.3.2
jeremeamia/SuperClosure               2.2.0   Serialize Closure objects, including their context and binding
laracasts/utilities                   2.1     Transform your PHP to JavaScript
laravel/framework                     v5.2.37 The Laravel Framework.
laravelcollective/html                v5.2.4  HTML and Form Builders for the Laravel Framework
league/csv                            7.2.0   Csv data manipulation made easy in PHP
league/flysystem                      1.0.24  Filesystem abstraction: Many filesystems, one API.
league/flysystem-aws-s3-v3            1.0.12  Flysystem adapter for the AWS S3 SDK v3.x
league/url                            3.3.5   League/url is a lightweight PHP Url manipulating library
marc-mabe/php-enum                    v2.2.1  Simple and fast implementation of enumerations with native PHP 5.3 and upper
maximebf/debugbar                     v1.11.1 Debug bar in the browser for php application
mockery/mockery                       0.9.5   Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any othe...
monolog/monolog                       1.22.0  Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/cron-expression             v1.1.0  CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
mtdowling/jmespath.php                2.3.0   Declaratively specify how to extract elements from a JSON document
nesbot/carbon                         1.21.0  A simple API extension for DateTime.
nikic/php-parser                      v2.1.0  A PHP parser written in PHP
onelogin/php-saml                     2.10.2  OneLogin PHP SAML Toolkit
paragonie/random_compat               v1.4.1  PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpdocumentor/reflection-docblock     2.0.4
phpoffice/phpexcel                    1.8.1   PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
phpseclib/phpseclib                   2.0.2   PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
phpspec/php-diff                      v1.0.2  A comprehensive library for generating differences between two hashable objects (strings or arrays).
phpspec/phpspec                       2.5.0   Specification-oriented BDD framework for PHP 5.3+
phpspec/prophecy                      v1.6.1  Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage             2.2.4   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator             1.4.1   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template             1.2.1   Simple template engine.
phpunit/php-timer                     1.0.8   Utility class for timing
phpunit/php-token-stream              1.4.8   Wrapper around PHP's tokenizer extension.
phpunit/phpunit                       4.8.26  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects          2.3.8   Mock Object library for PHPUnit
predis/predis                         v1.1.0  Flexible and feature-complete Redis client for PHP and HHVM
psr/http-message                      1.0     Common interface for HTTP messages
psr/log                               1.0.2   Common interface for logging libraries
psy/psysh                             v0.7.2  An interactive shell for modern PHP.
sebastian/comparator                  1.2.0   Provides the functionality to compare PHP values for equality
sebastian/diff                        1.4.1   Diff implementation
sebastian/environment                 1.3.7   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                    1.2.1   Provides the functionality to export PHP variables for visualization
sebastian/global-state                1.1.1   Snapshotting of global state
sebastian/recursion-context           1.0.2   Provides functionality to recursively process PHP variables
sebastian/version                     1.0.6   Library that helps with managing the version number of Git-hosted PHP projects
sendgrid/php-http-client              3.5.0   HTTP REST client, simplified for PHP
sendgrid/sendgrid                     5.1.1   This library allows you to quickly and easily send emails through SendGrid using PHP.
sentry/sentry                         1.6.1   A PHP client for Sentry (
sentry/sentry-laravel                 0.5.0   Laravel integration for Sentry (
spatie/laravel-url-signer             1.1.2   Laravel implementation of spatie/signed-url
spatie/url-signer                     1.0.1   Generate a url with an expiration date and signature to prevent unauthorized access
swiftmailer/swiftmailer               v5.4.2  Swiftmailer, free feature-rich PHP mailer
symfony/browser-kit                   v3.1.0  Symfony BrowserKit Component
symfony/class-loader                  v3.1.0  Symfony ClassLoader Component
symfony/console                       v3.0.7  Symfony Console Component
symfony/css-selector                  v3.1.0  Symfony CssSelector Component
symfony/debug                         v3.0.7  Symfony Debug Component
symfony/dom-crawler                   v3.1.0  Symfony DomCrawler Component
symfony/event-dispatcher              v3.1.0  Symfony EventDispatcher Component
symfony/finder                        v3.0.7  Symfony Finder Component
symfony/http-foundation               v3.0.7  Symfony HttpFoundation Component
symfony/http-kernel                   v3.0.7  Symfony HttpKernel Component
symfony/polyfill-mbstring             v1.2.0  Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                v1.2.0  Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-util                 v1.2.0  Symfony utilities for portability of PHP codes
symfony/process                       v3.0.7  Symfony Process Component
symfony/routing                       v3.0.7  Symfony Routing Component
symfony/translation                   v3.0.7  Symfony Translation Component
symfony/var-dumper                    v3.0.7  Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                          v3.1.0  Symfony Yaml Component
true/punycode                         v2.0.3  A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
vlucas/phpdotenv                      v2.2.1  Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
  • Suite configuration:
actor: Tester
    enabled: true
    remote: false
          - app/*
          - app/Console/ArtisanConsole.php
          - app/Console/Kernel.php
          - app/Http/routes.php
          - app/Http/Kernel.php
    tests: tests
    log: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
    bootstrap: _bootstrap.php
    colors: true
    memory_limit: 1024M
    strict_xml: true
        - Codeception\Extension\RunFailed
            dsn: ''
            user: ''
            password: ''
            dump: tests/_data/dump.sql

This comment has been minimized.

Show comment
Hide comment

janhenkgerritsen Feb 23, 2017


Fixed with #4032. Thanks!


janhenkgerritsen commented Feb 23, 2017

Fixed with #4032. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment