Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application exits if memcached server restarts #162

Open
varju opened this issue Feb 19, 2022 · 1 comment
Open

Application exits if memcached server restarts #162

varju opened this issue Feb 19, 2022 · 1 comment

Comments

@varju
Copy link

varju commented Feb 19, 2022

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.

@cannikin
Copy link

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. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants