Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to write session data (memcache)

Tags:

php

memcached

I'm noticing an intermittent issue with our Memcached session handler. The error that occurs is:

Unknown: Failed to write session data (memcache). Please verify that the current setting of session.save_path is correct.

Notes:

  • It seems to be an intermittent issue that occurs 5 or 6 times a day to various users.
  • Memcached is not localhost. i.e. It's on a different server than the web server.
  • I'm using the Memcache extension (as opposed to the MemcacheD extension).
  • I'm using the tcp prefix. If you look at this question, you'll see that the "fix" was to put tcp:// a prefix if you're using the Memcache extension.

My php.ini settings:

session.save_handler = memcache
session.save_path = "tcp://64.233.191.255:11211"

Note that I've also used:

session.save_path = "tcp://64.233.191.255:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

But it doesn't seem to matter.

Checked the memcached.log file, where I found the following error:

Failed to write, and not due to blocking: Connection reset by peer.

Note: This particular error occurs at least once, at the same time (01:07AM), everyday. It will then occur sporadically throughout the day.

like image 951
Wayne Whitty Avatar asked Apr 11 '14 09:04

Wayne Whitty


1 Answers

Maybe you're running out of filehandles? Perhaps the backups make your machine swap, resulting in slower responses, meaning more concurrent connections to the memcached process resulting in a stampeding hurd.

like image 179
Chris Wesseling Avatar answered Oct 02 '22 11:10

Chris Wesseling