Bug #73226 Corrupt results from innodb_memcache in 5.6.17 on Mac
Submitted: 7 Jul 2014 22:22 Modified: 6 Aug 2014 12:15
Reporter: Alex Power Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Memcached Severity:S3 (Non-critical)
Version:5.6.17, 5.7.4 OS:MacOS
Assigned to: CPU Architecture:Any

[7 Jul 2014 22:22] Alex Power
Description:
I upgraded from MySQL 5.6.12 to 5.6.17 on my Mac OS X machine, and the memcache API is returning corrupt results when I try to fetch two blobs in the same memcache GET request.  I've recreated the tables and re-installed the innodb_memcache plugin but are still getting corrupt data.  It appears as though we are somehow re-using a buffer; in both cases the second result is the one that is actually correct (the data is snappy encoded).

How to repeat:
The script creating the specific table:

CREATE TABLE users_memcache_header (
    id CHAR(11) NOT NULL PRIMARY KEY,
    pb MEDIUMBLOB NOT NULL
) CHARACTER SET utf8 COLLATE utf8_bin;

INSERT IGNORE INTO innodb_memcache.containers VALUES (
    'users_db_0_users_memcache_header', '$DATABASE',
    'users_memcache_header', 'id', 'pb', 0, 0, 0, 'PRIMARY'
);

Then do two fetches in the same get request.

get @@users_db_0_users_memcache_header.PVdAEAhuq5s @@users_db_0_users_memcache_header.LQQAEA6YyYc
VALUE @@users_db_0_users_memcache_header.PVdAEAhuq5s 0 37
$<???ꇑ????Շ?
<?9??
VALUE @@users_db_0_users_memcache_header.LQQAEA6YyYc 0 37
$<???ꇑ????Շ?
<?9??
END
get  @@users_db_0_users_memcache_header.LQQAEA6YyYc @@users_db_0_users_memcache_header.PVdAEAhuq5s
VALUE @@users_db_0_users_memcache_header.LQQAEA6YyYc 0 37
$<??̅?????????
<?:??
VALUE @@users_db_0_users_memcache_header.PVdAEAhuq5s 0 37
$<??̅?????????
<?:??
END
[12 Jul 2014 8:57] MySQL Verification Team
Thank you for the report.
I see similar behavior in 5.7.4 as well.

// 5.7.4

use test;
CREATE TABLE users_memcache_header (
    id CHAR(11) NOT NULL PRIMARY KEY,
    pb MEDIUMBLOB NOT NULL
) CHARACTER SET utf8 COLLATE utf8_bin;

INSERT IGNORE INTO innodb_memcache.containers VALUES (
    'users_db_0_users_memcache_header', 'test',
    'users_memcache_header', 'id', 'pb', 0, 0, 0, 'PRIMARY'
);

mysql> select md5('><');
+----------------------------------+
| md5('><')                        |
+----------------------------------+
| cda787d1c365702b3fe67533cbfaa7fd |
+----------------------------------+
1 row in set (0.00 sec)

mysql> select length('38559c871fba28d992ead51549367f83');
+--------------------------------------------+
| length('38559c871fba28d992ead51549367f83') |
+--------------------------------------------+
|                                         32 |
+--------------------------------------------+
1 row in set (0.00 sec)

mysql> select * from users_memcache_header;
Empty set (0.00 sec)

//  Set
[ushastry@cluster-repo mysql-5.7.4]$ telnet localhost 11211
Trying ::1...
Connected to localhost.
Escape character is '^]'.
set PVdAEAhuq5s 0 0 37
38559c871fba28d992ead51549367f83AAAAA
STORED
set LQQAEA6YyYc 0 0 37
38559c871fba28d992ead51549367f83BBBBB
STORED

// Confirm stored key/value

mysql> select * from users_memcache_header;
+-------------+---------------------------------------+
| id          | pb                                    |
+-------------+---------------------------------------+
| LQQAEA6YyYc | 38559c871fba28d992ead51549367f83BBBBB |
| PVdAEAhuq5s | 38559c871fba28d992ead51549367f83AAAAA |
+-------------+---------------------------------------+
2 rows in set (0.00 sec)

// Get the details

get PVdAEAhuq5s
VALUE PVdAEAhuq5s 0 37
38559c871fba28d992ead51549367f83AAAAA
END
get LQQAEA6YyYc
VALUE LQQAEA6YyYc 0 37
38559c871fba28d992ead51549367f83BBBBB
END
get @@users_db_0_users_memcache_header.PVdAEAhuq5s
VALUE @@users_db_0_users_memcache_header.PVdAEAhuq5s 0 37
38559c871fba28d992ead51549367f83AAAAA
END
get @@users_db_0_users_memcache_header.LQQAEA6YyYc
VALUE @@users_db_0_users_memcache_header.LQQAEA6YyYc 0 37
38559c871fba28d992ead51549367f83BBBBB
END
get  @@users_db_0_users_memcache_header.PVdAEAhuq5s @@users_db_0_users_memcache_header.LQQAEA6YyYc
VALUE @@users_db_0_users_memcache_header.PVdAEAhuq5s 0 37
38559c871fba28d992ead51549367f83BBBBB
VALUE @@users_db_0_users_memcache_header.LQQAEA6YyYc 0 37
38559c871fba28d992ead51549367f83BBBBB
END

If you notice, second value is correct whereas the first one wrong.
[6 Aug 2014 12:15] Erlend Dahl
Fixed as a duplicate of bug# 72453 in 5.6.21, 5.7.5