Bug #72453 InnoDB Memcached Plugin "gets" command
Submitted: 25 Apr 2014 13:51 Modified: 24 Jul 2014 14:57
Reporter: qixiu xiao Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Memcached Severity:S3 (Non-critical)
Version:5.7.4-m14, 5.6.20 OS:Linux (ubuntu 12.04 server x64)
Assigned to: Allen Lai CPU Architecture:Any
Tags: InnoDB Memcached Plugin

[25 Apr 2014 13:51] qixiu xiao
Description:
I use "gets" command to get two values like this:
(The value of "AA" is "HELLO, HELLO", The value of "AA1" is "Hello, Hello")

shell> echo "gets @@aaa.AA @@aaa.AA1" | nc localhost 11211
VALUE @@aaa.AA 8 12 0
4Hello, Hell
VALUE @@aaa.AA1 8 12 1
Hello, Hello
END

The first value is always incorrect, but if I get single value like this:

shell> echo "gets @@aaa.AA" | nc localhost 11211
VALUE @@aaa.AA 8 12 0
HELLO, HELLO
END

The value is right.

How to repeat:
first:

shell> echo -e "add @@aaa.AA1 0 0 12\r\nHello, Hello\r\n" | nc localhost 11211
STORED

second:

shell> echo "gets @@aaa.AA @@aaa.AA1" | nc localhost 11211
VALUE @@aaa.AA 8 12 0
4Hello, Hell
VALUE @@aaa.AA1 8 12 1
Hello, Hello
END
[25 Apr 2014 14:15] qixiu xiao
The bug of multiple value

Attachment: 20140425220902.png (image/png, text), 30.50 KiB.

[29 Apr 2014 18:42] Hartmut Holzgraefe
Wrong Category? Should me Server: MemCached, not Cluster: MemCached?
[2 May 2014 6:11] Erlend Dahl
Allen, can you please take a look?
[8 Jul 2014 12:38] MySQL Verification Team
Hello Xiao,

Thank you for the report and test case.
Verified as described.

Thanks,
Umesh
[8 Jul 2014 12:41] MySQL Verification Team
5.7.4/5.6.20 - affected

$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
add AA1 0 0 12
Hello, Hello
STORED
get AA
VALUE AA 8 12
HELLO, HELLO
END
get AA1
VALUE AA1 0 12
Hello, Hello
END
gets AA AA1
VALUE AA 8 12 0
Hello, Hell
VALUE AA1 0 12 4
Hello, Hello
END
quit
Connection closed by foreign host.
[22 Jul 2014 12:04] qixiu xiao
yeah, but "get" command also cannot obtain multiple records ,
show the follow picture:
[22 Jul 2014 12:05] qixiu xiao
"get"commad

Attachment: QQ截图20140722195514.png (image/png, text), 7.75 KiB.

[22 Jul 2014 12:15] qixiu xiao
The database records

Attachment: 20140722201335.png (image/png, text), 18.02 KiB.

[23 Jul 2014 8:21] Allen Lai
Posted by developer:
 
We block multi-gets for now. Just return an error message to client instead of returning wrong results.
[23 Jul 2014 13:23] Daniel Price
Fixed as of the upcoming 5.6.21, 5.7.5 release, and here's the changelog entry:

Retrieval of multiple values with a single "get" command would return
incorrect results instead of an error message. The "InnoDB" "memcached"
plugin does not currently support retrieval of multiple values with a
single "get" command. 

Thank you for the bug report.
[23 Jul 2014 13:26] Daniel Price
Fixed as of the upcoming 5.6.21, 5.7.5 release, and here's the changelog entry:

Retrieval of multiple values with a single "get" command would return
incorrect results instead of an error message. The "InnoDB" "memcached"
plugin does not currently support retrieval of multiple values with a
single "get" command. 

Thank you for the bug report.
[24 Jul 2014 3:48] Erlend Dahl
Bug#73014 was marked as a duplicate.
[24 Jul 2014 13:27] qixiu xiao
I modify the code, and it can get multiple values.
[24 Jul 2014 13:29] qixiu xiao
header file

Attachment: memcached.h (text/plain), 15.36 KiB.

[24 Jul 2014 13:30] qixiu xiao
c file

Attachment: memcached.c (text/plain), 259.33 KiB.

[24 Jul 2014 14:40] qixiu xiao
This problem is attributed to obtain the same "item*" pointer.

At method:
static inline char* process_get_command(conn *c, token_t *tokens, size_t ntokens, bool return_cas)

code lines:
if (ret == ENGINE_SUCCESS) {
   ret = settings.engine.v1->get(settings.engine.v0, c, &it, key, nkey, 0);
}

But why each value of key is right ?  key value is also get from "item* it" pointer
[24 Jul 2014 14:57] qixiu xiao
The pointer of key reference the same pointer of "item* it".
[25 Jul 2014 1:05] qixiu xiao
update the change

Attachment: memcached.c (text/plain), 259.39 KiB.

[25 Jul 2014 1:46] Allen Lai
Thanks for your anlysis, Qixiu. 
Yes, we can solve this problem by modifying memcached layer. But since we don't want to break any current mechanism in memcached, so I think, the final solution would be that we provide fully support to handle get multi-values by one "get" or "gets" command in our InnoDB memcached plugin.
[25 Sep 2014 12:02] Laurynas Biveinis
revno: 6091
committer: Allen lai <zheng.lai@oracle.com>
branch nick: mysql-5.6
timestamp: Wed 2014-07-23 16:10:01 +0800
message:
  Bug#19172212  InnoDB Memcached Plugin "gets" command
  
  We don't support multi-gets yet. This will be addressed in worklog 6650.
  We block multi-gets for now. Just return an error message to client
  instead of returning wrong results.
  
  Approved by Jimmy on IM.