@mattab opened this issue on October 30th 2014

The goal of this issue is to make sure that the error SQLSTATE[HY000]: General error: 2006 MySQL server has gone away will not show again (randomly) in Travis CI.

Example randomly failed build: https://travis-ci.org/piwik/piwik/jobs/39441245

Also discussed in https://github.com/travis-ci/travis-ci/issues/2250

Our FAQ explains to our users how to solve this: How do I fix the error “Mysql Server has gone away”?

@mattab commented on October 30th 2014

my tests didn't work so I asked Travis here https://github.com/travis-ci/travis-ci/issues/2250#issuecomment-61037684

@mnapoli commented on October 30th 2014

FYI I got the same error while running the system tests on AWS.

@sgiehl commented on October 30th 2014

There were some users having the same error in the forums. Not sure if and how it could be caused by piwik

@tsteur commented on October 30th 2014

Didn't know this is still a thing... I added https://github.com/piwik/piwik/commit/8e58b758fb03d8d38db6a6c78f824cb68ee68668 a while ago which seemed to solve it but probably not. Or Is maybe performSetup no longer executed when executing system tests?

Actually, the system tests perform API requests so we might have to execute this query as well in each API/index.php request for tests? Might be worth a try. Not sure if it fixes it though.

@mattab commented on November 4th 2014

Another occurrence https://travis-ci.org/piwik/piwik/jobs/39922102

I'm deleting the branch where i was running some tests:

    + # Prevent Mysql has gone away
    + - mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"
    + - echo -e "[server]\nmax_allowed_packet=64M" | sudo tee -a /etc/mysql/conf.d/drupal.cnf
    + - sudo service mysql reload
    + - mysql -e "SET GLOBAL wait_timeout=300;"
    + - mysql -e "SHOW VARIABLES LIKE 'max_allowed_packet';"

@mattab commented on December 18th 2014

Somehow this happens less often now. it seems this issue is tightly coupled to whatever VMs Travis gives us. some of the VMs are failing heaps while others always work fine.

@mattab commented on December 19th 2014

Just as I write it happens less often I'm seeing today some example where it occurs eg. https://travis-ci.org/piwik/piwik/jobs/44512857

@mattab commented on January 7th 2015

Another one in https://travis-ci.org/piwik/piwik/jobs/46159944

@mnapoli commented on January 8th 2015

From a latest build, the stack trace:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2006 MySQL server has gone away' in /home/travis/build/piwik/piwik/libs/Zend/Db/Adapter/Pdo/Abstract.php:263
Stack trace:
#5 /home/travis/build/piwik/piwik/tests/PHPUnit/Framework/Fixture.php(839): Piwik\DbHelper::dropDatabase('piwik_tests')
#6 /home/travis/build/piwik/piwik/tests/PHPUnit/Framework/Fixture.php(295): Piwik\Tests\Framework\Fixture->dropDatabase()
#7 /home/travis/build/piwik/piwik/tests/PHPUni [the stack trace is truncated here unfortunately]

We can see that the query that failed is DROP DATABASE, which is executed in test's tearDown(). So it might be that a test has a query that fails, which breaks the MySQL connection. Then in the tearDown, DROP DATABASE fails because of that, and the new exceptions "overrides" the original exception in PHPUnit's log.

I had that kind of things happen in a previous project, we had to test in the database/table still existed before dropping it.

What we could try is wrap the call to dropDatabase in a try/catch?

@RoySegall commented on January 8th 2015

Well i'm join in about this one. I think there is a problem with memory. Although i tried to increase the max packet size to 64M the size is still 16M. What i did so my test will is to split it.

You can look here that the tests failed and you can see here that the matrix passed.

splitting test is a good solution but it's a really good one because each matrix set up the environment. For small projects it's could be good but for large projects like OpenScholar is not a good solution because the set up takes 20 min and you have only two matrix at a time. If someone know how to solve that i'd like to here about it.

@mattab commented on April 7th 2015

Since we removed the PHP 5.3.3 build and only run on latest PHP I think this issue is now gone. Please re-open the issue if you still find cases of "mysql has gone away" in Piwik builds

This issue was closed on April 7th 2015
Powered by GitHub Issue Mirror