• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI Session - Lost connection to MySQL server during query

#1
Sad 
My site is working fine but sometimes it suddenly starts giving CI_SESSION error...

Error is : 


Code:
ERROR -> Query error: Lost connection to MySQL server during query - Invalid query: SELECT `data`
FROM `ci_sessions`
WHERE `id` = '44278e7a05ed07842bgf15b1a5feaff0dcee76c3'

ERROR --> Query error: MySQL server has gone away - Invalid query: INSERT INTO `ci_sessions` (`id`, `ip_address`, `timestamp`, `data`) VALUES ('21440e7a66ed02342bbf15b1a3feaff0dcee76c3', 'xxx.xx.xx.xx', 1545006351, '')

ERROR - --> Query error: MySQL server has gone away - Invalid query: SELECT RELEASE_LOCK('5d966d065ca3606e9cdf23c761035e54') AS ci_session_lock

 Please let me know if anyone has any idea about this...
 
 My config setting is : 

Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_driver'] = 'database';
Reply

#2
@bharatmaher,

In your config database settings file, what do you have ['pconnect'] set to?
Reply

#3
Some time ago we noticed issues with sessions as well when using database storage. This has been discussed few times on this forum why it has to work the way it does, but we ended up changing to file based session storage while we were moving to Redis. Had no session issues since, but last 18 months we never managed to move to Redis due to reason completely unrelated to CodeIgniter :|
Reply

#4
This isn't a CodeIgniter issue. Same errors can be seen in your logs with any framework. This is a problem with the server. I know this because I usually modify the error handler so it emails me when there are errors, and I get these errors from multiple accounts/websites, at the same time, and they are not all using CodeIgniter. Unless you are in control of the server, or your host can provide more information, it's unlikely there's anything you can do about it.
Reply

#5
(12-19-2018, 10:18 AM)php_rocs Wrote: @bharatmaher,

In your config database settings file, what do you have ['pconnect'] set to?

@php_rocs,
 
 Thanks for your update!.

  My ['pconnect'] is set to FALSE.
 
  Thank you.
Reply

#6
(12-20-2018, 09:08 AM)skunkbad Wrote: This isn't a CodeIgniter issue. Same errors can be seen in your logs with any framework. This is a problem with the server. I know this because I usually modify the error handler so it emails me when there are errors, and I get these errors from multiple accounts/websites, at the same time, and they are not all using CodeIgniter. Unless you are in control of the server, or your host can provide more information, it's unlikely there's anything you can do about it.

 @skunkbad,

 Thank you for your response.

  I'll definitely discuss with my server administrator.  The error is frustrating for us because it completely makes my site down for 4-5 minute and we ended up with losing some important websites customers.
Reply

#7
You can also try this.

PHP Code:
$this->db->reconnect(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#8
(12-27-2018, 04:59 AM)InsiteFX Wrote: You can also try this.

PHP Code:
$this->db->reconnect(); 

  @InsiteFX,

   Where I can add above line?
Reply

#9
I would run it when you do your queries or in your model constructor.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.