-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix delete parsing for memcache #283
Conversation
This bug cause to fail to delete in some library. |
@idning could you review this patch? |
we have tested delete_multi here: https://github.com/idning/test-twemproxy/blob/master/test_memcache/test_gets.py#L78 and the protocol say nothing about this https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L249-L254 should we support it? |
@idning, I think it is better to support it. because Memcached accept this case. the document is not applied real code. https://github.com/memcached/memcached/blob/master/memcached.c#L3320 The code can accept when number is 0. I also agree that we don't need to support some irregular cases. |
we should follow the protocol but not the implement. because that's other implement of memcache like twemcache. |
@idning I also agree with you. but, I think this case are somewhat different. I found this bug with python-memcached. and I found this testcase also has bug. we can reproduce this.
so. if we tried get code several times. we can get original data that is not deleted. |
we shouldn't do this - this behavior of memcache's delete handling is not in spec. In fact, as you just mentioned it ignores the |
I'm gonna close this request for now - feel free to reopen if you folks disagree |
@manjuraj @idning , You make sense. to follow spec is important. but I think I can't supply enought information about this problem. before starting, below is another problem and we can ignore this.(this is actually memcached bug) delete key <number> <noreply> but real problem that I think is with python-memcached library.(python-memcached is de-factor python historically to support defer_delete(but this is only exist in 1.2.x of memcache, current version 1.4.x just allow number is 0) python-memcached has default time parameter(and it's default value is 0) and it has two delete functions(delete and delte_multi)
if time is not None and time != 0:
cmd = "%s %s %d%s" % (cmd, key, time, extra)
else:
cmd = "%s %s%s" % (cmd, key, extra)
if time is not None:
for key in server_keys[server]: # These are mangled keys
write("delete %s %d%s\r\n" % (key, time, extra))
else:
for key in server_keys[server]: # These are mangled keys
write("delete %s%s\r\n" % (key, extra)) to avoid this problem. python-memcached users can set time option to None explcit, delete_multi like this conn.delete_multi['key1','key2'], time=None]
not
conn.delete_multi(['key1','key2'] I just wonder that python-memcached users can get bad prejudice like that |
maybe the right fix is
I think the latter makes sense |
@charsyam sorry for the delay. you are right about the bug in our testcase (I assume that it will raise a Exception if server close connection.) About this isuue, i think we should fix delete_multi in python-memcache and I see @charsyam 's PR here: https://github.com/linsomniac/python-memcached/pull/62/files that's great. |
Note: The usage in python-memcached was fixed in linsomniac/python-memcached#27 |
I think we should support memcache delete argument. because memcached delete spec allow arguments.
See process_delete_command in https://github.com/memcached/memcached/blame/master/memcached.c
so delete command syntax like below:
Actually, memcached doesn't handle but, it doesn't return ERROR, just it ignores internally.
so. I just follow current memecached behavior. :)