Open 4h0y opened 7 years ago
Is project dead?
@4h0y Did you solve this problem? I have the same issue.
@zhenfan0753 I used a different port. For example 11212
have same problem
changing port doesn't help
first i always receive error
Issue occured on server 127.0.0.1: 11211 {
"server": "127.0.0.1:11211",
"tokens": [ "11211", "127.0.0.1" ],
"messages": [ "object too large for cache" ],
"failures": 5,
"totalFailures": 0
}
then several write operations succeed and then a shower of errors begin
set 'fingate/data_ready_8077bdd9c947d1df84630212e2c57574' '{"expTimeSeconds":30}' size: 259 Error: Server at 127.0.0.1: 11211 not available
at Client.memcachedCommand[as command](/usr/local / nodejs8111 / lib / node_modules / memcached / lib / memcached.js: 306: 70)
at Client.setters(/usr/local / nodejs8111 / lib / node_modules / memcached / lib / memcached.js: 936: 10)
at Client.bowlofcurry[as set](/usr/local / nodejs8111 / lib / node_modules / memcached / lib / utils.js: 126: 15)
Looks like I got it!
this is how my memcached is started
memcached -p 11212 -m 256 -c 1024 -I 20m
and this was the client creation
new Memcached(
options.host + ':' + options.port, {
maxValue: 33554432
}
);
when i corrected maxValue to the value <= 20Mb, for example 10485760
in logs instead of those unexpected errors i sometimes see for too big items
Error: The length of the value is greater than 10485760
which is perfectly fine and all other write operations succeed
Any updates on this ?
Can anyone help me out over this problem ?
any updates on this ???!
Any updates?
We were getting this error (and also Connection readyState is set to readOnly
) and it was due to the client hitting its default 5s timeout when the server was struggling under heavy load.
@WilliamNurmi I get the same "Connection readyState is set to readOnly" during heavy loads.
Were you able to address this?
Have you solved this problem now?I also encountered it
Initialising the client like below fixed my problem:
new MemcachedClient(this.serverEndpoint, { maxValue: 10485760, timeout: 10 * 1000 /* 10 sec. */});
I think I managed to consistently reproduce Error: Connection readyState is set to readOnly
locally.
Basically, you need memcached server running + stress test it with parallel writes.
For me it starts to break at 40 parallel writes (but below I have it set to 100)
Considering that nothing else uses this memcached server & I have only one connection
instance, I think its a library fault that it doesn't try to queue writes.. nor limit how many writes can do at a time & instead seems to just kill memcache.
Steps (using jest / integration test):
const MIN_FAILING_THREADS = 100;
it(`native memcache fails at ${MIN_FAILING_THREADS} concurrent writes`, async () => {
const Memcached = require('memcached');
// ACT
const ops = [];
const connection = new Memcached(['localhost:11211'], {
// timeout: 500, the time after which Memcached sends a connection timeout (in milliseconds)
timeout: 500,
// retries: 5, the number of socket allocation retries per request.
retries: 2,
// failures: 5, the number of failed-attempts to a server before it is regarded as 'dead'.
failures: 5,
// retry: 30000, the time between a server failure and an attempt to set it up back in service.
// the maximum size of the connection pool.
poolSize: 200,
// if true, authorizes the automatic removal of dead servers from the pool.
remove: true,
idle: 5000,
maxValue: 524288, // default is 1048576
encoding: 'binary',
});
connection.on('failure', async () => {
console.error('Lost connection');
});
for (let i = 0; i < MIN_FAILING_THREADS; i++) {
ops.push(
new Promise((resolve, reject) => {
connection.set(`x${i}`, i, 2, (err, result) => {
if (err) {
return reject(err);
}
return resolve(result);
});
}),
);
}
// overload memcache
Promise.all(ops);
const result = await new Promise((resolve, reject) =>
connection.getMulti(['x1'], (err, data) => {
if (err) {
reject(err);
}
resolve(data);
}),
);
// ASSERT
expect(result).toEqual({ x1: 1 });
});
Install memcached in window works for my case.
https://stackoverflow.com/questions/59476616/install-memcached-on-windows
It could be a memcached server problem. I see the problem from Java clients as well.
Looks like I got it!
this is how my memcached is startedmemcached -p 11212 -m 256 -c 1024 -I 20m
and this was the client creation
new Memcached( options.host + ':' + options.port, { maxValue: 33554432 } );
when i corrected maxValue to the value <= 20Mb, for example 10485760
in logs instead of those unexpected errors i sometimes see for too big itemsError: The length of the value is greater than 10485760
which is perfectly fine and all other write operations succeed
Thanks, you just saved my day
LOG
But Memcached active.