If the memcached server is restarted after the client has already opened a socket connection, the next client request causes the application to exit.
Note that this problem only seems to occur when using a remote memcached server, e.g. in a remote Docker server. I have not been able to reproduce when running locally.
Sample code that helps demonstrate the problem:
const memjs = require('memjs');
async function main() {
const client = memjs.Client.create('remote.docker.host');
let i = 0;
while (true) {
try {
i++;
const key = `Record${i}`;
console.log(`Storing ${key}`);
await client.set(key, 'value');
const result = await client.get(key);
const value = result && result.value ? result.value.toString() : null;
console.log(`Loaded ${key}=${value}`);
} catch (e) {
console.log('Loop failed', e);
}
}
}
main().then(() => {
console.log('Done');
}).catch(e => {
console.log('Failed', e);
});
While this is running, docker restart memcached on the remote server and you should see the process exit with no errors.
Any updates on this one? I'm trying to added Memjs to RedwoodJS and I'm seeing something similar: if the memcached server goes away the next request just hangs forever. :(
If the memcached server is restarted after the client has already opened a socket connection, the next client request causes the application to exit.
Note that this problem only seems to occur when using a remote memcached server, e.g. in a remote Docker server. I have not been able to reproduce when running locally.
Sample code that helps demonstrate the problem:
While this is running,
docker restart memcached
on the remote server and you should see the process exit with no errors.