-
Notifications
You must be signed in to change notification settings - Fork 137
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
pylibmc should raise if a negative timeout is used in binary mode #202
Comments
Or to be more specific:
The reason for filing this is that my tests for django-pylibmc/django-pylibmc#36 are failing due to this: It also affects Django supporting binary mode natively in the future: Many thanks :-) |
I've done some further testing on Travis - I can reproduce the issue under all three combinations of:
(eg https://travis-ci.org/edmorley/memcached-test/builds/105901400) ...however I'm not able to do so in my local Vagrant Ubuntu 14.04 environment, even though both it and the 14.04 Travis run are using libmemcached 1.0.8 with memcached server 1.4.14. python-binary-memcached doesn't handle negative binary times at all (eg [1]), and the memcached protocol docs don't specify expected behaviour, so I've filed an issue to clarify it: [1] https://travis-ci.org/edmorley/memcached-test/jobs/105901402#L129 |
Interesting. I'll look at this and get back to you in a second. |
The way pylibmc does it at the moment is just pass the value on to |
I've used this file to test the behaviour against python-memcached, python-binary-memcached & pylibmc (with both binary mode True and False): Results:
Original output... Local testing with Ubuntu 14.04 in Vagrant: Local testing with Ubuntu 15.10 in Vagrant: The Travis runs are here: |
So there are a few issues:
We really need the spec to be clarified IMO: |
Ah the local Vagrant Ubuntu 14.04 environment is x86 (I'd completely forgotten; table now updated above), which explains the difference in results (I'm presuming the -1 wraps around to a different positive int depending on the architecture's size of Judging by the comments about the spec (memcached/memcached#142 (comment)) it seems like negative timeout values should just raise an exception since their behaviour is not deterministic across architectures and/or binary={True,False}. |
I agree, negative timeouts should raise an exception. |
The memcached docs have just been updated: In binary mode the time must be unsigned. In ASCII mode, a negative time means "immediately expire". As such, it would be great if pylibmc generated an exception if a negative timeout is used in binary mode :-) |
@lericson what's the best way to go about implementing this? Should it be in libmemcached, or is that unlikely to happen given it's poorly-maintained, and so best handled in pylibmc? If the latter, where should I start? (Sorry my Python-C binding foo is basically non-existent) Many thanks :-) |
Sorry been super busy, I’ll get back to you in the next 48 hours.
|
Ah yes I think it would make sense to check for signedness at the Python C API level; alternatively fixing libmemcached. Whichever you prefer. Sorry, those 48 hours got drawn out to almost a year. |
The pylibmc docs say:
I interpreted this as meaning:
However the behaviour actually seems to vary depending on whether binary mode is used, eg in an Ubuntu Trusty vagrant environment:
...ie the return value of the
.set()
varies.However on Travis the differences are more extreme - the return value of the
.get()
isn'tNone
when using binary mode, eg:master...edmorley:test-libmemcached-bug
https://travis-ci.org/edmorley/pylibmc/builds/105429852
Any ideas? :-)
The text was updated successfully, but these errors were encountered: