Giter VIP home page Giter VIP logo

Comments (7)

alevy avatar alevy commented on September 1, 2024

Interesting. OK. This is solvable by using the opaque field in the header. I'll get to it.

from memjs.

alevy avatar alevy commented on September 1, 2024

Aha! The problem is not with memcached responding out of order, but rather with memjs requesting out of order.

What's going on is that since the there is no connection yet (it's established lazily), the first operation (after enqueing the response and error) blocks on the connection to be established. Meanwhile, example.js continues on it's merry way and performs the second operation. Now the connection has been set, so it immediately proceeds to write the request to the socket. Only now do we switch back to the first operation. So the requests are sent out of order.

Nesting both operations within a higher level operation solves this:

client.get('dummy', function() {
  client.get('AAA');
  client.set('BBB', 'ZZZ');
  client.close(); // close really needs to be nested to ensure ordering, but at least on localhost this happens to work
});

In principal, opaque would solve this, but it turns out to be kind of a messy solution that I'd like to avoid if we can rely on ordering. I think this is more easily fixable by mucking with the connection code a bit (specifically sticking requests in a common buffer that's flushed upon the first request that sees a connected socket).

Thanks for finding this! It's a kind of subtle one, but very bad and important to fix.

from memjs.

ithinkihaveacat avatar ithinkihaveacat commented on September 1, 2024

Ah yes, I guess memcached physically can't respond out of order, so it can't be a problem with out of order responses. And whilst memjs might use multiple memcached servers, each of them will have a separate queue, so any queue-based fix should work for them all. Thanks for looking at this. Look forward to the fix!

from memjs.

ithinkihaveacat avatar ithinkihaveacat commented on September 1, 2024

@alevy Is this being worked on? Do you have any sort of idea how long it might take?

from memjs.

alevy avatar alevy commented on September 1, 2024

@ithinkihaveacat thanks for the nudge. My original (to actually write to the socket lazily) turned out to be complicated, but I did something dumber, but that I'm pretty sure works and is fairly clean. Check out the lazyconn branch or pull request #22.

If you can give this a test before i merge that would be awesome!

from memjs.

ithinkihaveacat avatar ithinkihaveacat commented on September 1, 2024

Thanks! I had a bit of a quick test tonight, and it seems okay so far.

from memjs.

ithinkihaveacat avatar ithinkihaveacat commented on September 1, 2024

Looks good to me! Thanks!

from memjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.