1

I am trying one cron job after running of 5 minutes it is giving me below error.

Here by i am attaching screen shot for that.I am using yii framework.

I am trying one cron job after running of 5 minutes it is giving me below error.

  CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: 
  General error: 2006 MySQL server has gone away. 
  The SQL statement executed was: INSERT INTO `phpcrawler_links` 
  (`site_id`, `depth`, `crawl_now`, `url`, `last_crawled`, 
  `http_status_code`, `content_type`, `page_size`, `parent_url_id`) 
  VALUES (:yp0, :yp1, :yp2, :yp3, :yp4, :yp5, :yp6, :yp7, :yp8)
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Bhaskar Bhatt
  • 1,399
  • 13
  • 19
  • possible duplicate of [ERROR 2006 (HY000): MySQL server has gone away](http://stackoverflow.com/questions/10474922/error-2006-hy000-mysql-server-has-gone-away) – IROEGBU Feb 09 '15 at 12:39
  • @iroegbu Its error is duplicate but sitation is different and same solution is not working here – Bhaskar Bhatt Feb 09 '15 at 12:43

2 Answers2

2

It often happens due to several inserts in a big loop, and one of the INSERT fails. Normally, the MySQL server resumes after a while without having to do anything.

But be sure to tweak your max_packet_size to some large amount in my.ini and restart your server:

[mysqld]
max_allowed_packet = 16M

Verify by:

SHOW VARIABLES LIKE '%packet%';
Bimal Poudel
  • 1,214
  • 2
  • 18
  • 41
2

If you use columns text that maybe take serialized data and many rows you must consider to increase these parameters:

max_allowed_packet=512M

If you have a lot of request set this and don't set it to bigger because its related with your environment

max_connections=1000

Note If you are in last case and if you are using persistent connection take a look to disable it, in many application that have close interaction with database if you create many connections persistent you consume that number so fast.

onalbi
  • 2,609
  • 1
  • 24
  • 36