You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, getVersion implemented by php-memcached uses memcached_version from libmemcache. Should any memcached server fail, then memcached_version() will return MEMCACHED_SOME_ERRORS which causes getVersion to return false instead not an array of the "working servers". So any failing servers results in validateConnection throwing a \RuntimeException.
This is especially counterproductive when using a replicated memcached setup, in which one or multiple memcached servers could fail without problems - would it not be for the check and which disallows any memcached server to fail.
Both memcached_version from libmemcached as well as getVersion from php-memcached act as intended (as I understand it), so it's not a bug with either. Just using getVersion to validate the connection is not the intended usage. As far as I can tell this is the case with any available libmemcached, at least since 1.0.0. Also php-memcached, at least since 2.0.0.
Steps To Reproduce:
Setup memcached as cache in Laravel using more than one memcached servers
Write a controller, which uses \Cache::(put|get|...) so that MemcachedConnector is created
Simulate an outage in one of the memcached servers
See the \RuntimeException
Here a short test setup. Laravel configured as above is available locally under http://localhost:8080/, then:
# start up memcached
$ memcached -p 11211 &
$ memcached -p 11212 &# issue a request to your Laravel App, while both servers are up
$ curl http://localhost:8080/
# simulate outage of _one_ of the memcached servers
$ iptables -I INPUT -p tcp --destination-port 11211 -j DROP
# issue another request, see the exception
$ curl http://localhost:8080/
Solution (idea)
Either remove the getVersion check, make it controllable (disable/enable) via configuration or use set("some-special-key", ..) + get("some-special-key"). The latter is of course more expensive than getVersion.
I can provide a patch, if you let me know which of the solution ideas you prefer.
The text was updated successfully, but these errors were encountered:
Description:
In the
MemcachedConnector
class thevalidateConnection
method, which is called after memcached servers have been added, usesMemcached::getVersion
to verify that memcached servers have been added.Now,
getVersion
implemented byphp-memcached
usesmemcached_version
from libmemcache. Should any memcached server fail, thenmemcached_version()
will returnMEMCACHED_SOME_ERRORS
which causesgetVersion
to returnfalse
instead not an array of the "working servers". So any failing servers results invalidateConnection
throwing a\RuntimeException
.This is especially counterproductive when using a replicated memcached setup, in which one or multiple memcached servers could fail without problems - would it not be for the check and which disallows any memcached server to fail.
Both
memcached_version
fromlibmemcached
as well asgetVersion
fromphp-memcached
act as intended (as I understand it), so it's not a bug with either. Just usinggetVersion
to validate the connection is not the intended usage. As far as I can tell this is the case with any availablelibmemcached
, at least since 1.0.0. Alsophp-memcached
, at least since 2.0.0.Steps To Reproduce:
\Cache::(put|get|...)
so thatMemcachedConnector
is created\RuntimeException
Here a short test setup. Laravel configured as above is available locally under
http://localhost:8080/
, then:Solution (idea)
Either remove the
getVersion
check, make it controllable (disable/enable) via configuration or useset("some-special-key", ..)
+get("some-special-key")
. The latter is of course more expensive thangetVersion
.I can provide a patch, if you let me know which of the solution ideas you prefer.
The text was updated successfully, but these errors were encountered: