Code Monkey home page Code Monkey logo

Comments (12)

jongillham avatar jongillham commented on May 27, 2024

This doesn't sound like a nds specific error. NDS usually emits errors nds: [error type]. Is it consistent or intermittent? In any case, nds is designed to work fine with any type of memcache error or even if the memcache backend completely goes down.

The one caveat is that nds.Delete needs to ensure that memcache.Delete completes successfully before it works so that it can guarantee strong cache consistency.

Please let me know if you find out any more information. I'll leave this issue open a bit longer. My instances haven't logged this error today but I'll keep looking.

from nds.

derekperkins avatar derekperkins commented on May 27, 2024

Sorry, the dev who passed on the log didn't give me the whole thing. This is what was getting thrown.
nds:lockMemcache AddMulti memcache: server error

It was happening on every datastore request, and I haven't seen anything specific that is different that might have caused it. Is there maybe a difference in max record sizes between memcache and datastore?

from nds.

josephbergevin avatar josephbergevin commented on May 27, 2024

Looks like this may be tied to having special characters in the key. I tried 3 specifically: ?, =, %. All 3 cause the memcache: server error to be thrown. I took those out, it worked just fine.

from nds.

jongillham avatar jongillham commented on May 27, 2024

@josephbergevin that's interesting to know, however I don't think this is an issue affecting NDS. The memcache keys will never use those characters. datastore.Key.Encode() uses base 64 encoding and removes the trailing "=". This is identical to what Python's ndb does.

@derekperkins are you still seeing these problems consistently? Could it have been that the API was down at the time?

from nds.

derekperkins avatar derekperkins commented on May 27, 2024

@jongillham I actually work in the same room as @josephbergevin, so yes, I'm seeing the same error. :) I think Joe narrowed the problem down to the length of the StringID.

from nds.

josephbergevin avatar josephbergevin commented on May 27, 2024

I investigated further and it seems the error may be tied to a character limit on the StringID. 147 chars is the max limit I could use in a key. If I go over that, I get these errors/warnings:
GetMulti gives a warning: nds:lockMemcache AddMulti memcache: server error
PutMulti throws an error: memcache: server error

from nds.

jongillham avatar jongillham commented on May 27, 2024

@josephbergevin awesome deductive work! I see the Python and Go SDK functionality differs here. The max key size on both platforms is 250 bytes. However Python automatically hashes the key if it is longer than 250 bytes and Go just raises an error.

This error must be what you are seeing. I'll investigate what type of hashing Python does and then copy it. I suppose there will be risk of hash collision but it must be small enough for the guys that made the Python SDK to not worry about.

What do you think?

from nds.

jongillham avatar jongillham commented on May 27, 2024

Just for reference here's what Python's API does.

MAX_KEY_SIZE = 250

if len(server_key) > MAX_KEY_SIZE:
    server_key = hashlib.sha1(server_key).hexdigest()

I wonder if it is worth using sha256 or sha512 to reduce the possibility of collisions...

http://stackoverflow.com/questions/1867191/probability-of-sha1-collisions

Probably not.

from nds.

derekperkins avatar derekperkins commented on May 27, 2024

Yeah, probably not. For it to be an issue, all of these would have to be the case:

  1. The 2 StringIDs would have to hash to the same key
  2. Both of the total keys have to exceed 250 characters
  3. Both would have to be called in close enough proximity that neither one has been evicted from memcache already.

If it were more persistent data, it might be more of an issue, but I don't forsee this being that big of an problem.

from nds.

josephbergevin avatar josephbergevin commented on May 27, 2024

Yes, I agree with @derekperkins. That sounds great.

from nds.

jongillham avatar jongillham commented on May 27, 2024

Commit 924699e should hopefully fix this issue. I'll await feedback before I close this as the dev environment does not replicate this issue.

from nds.

josephbergevin avatar josephbergevin commented on May 27, 2024

That worked! I think you can go ahead and close the issue. Thanks for the quick responses!

from nds.

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.