Bug #70055 Expiration time ignored
Submitted: 15 Aug 2013 21:49 Modified: 5 Feb 2015 14:22
Reporter: Miljenko Brkic Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Memcached Severity:S2 (Serious)
Version:5.6.13, 5.7.6 OS:Linux (Ubuntu)
Assigned to: CPU Architecture:Any
Tags: innodb, memcached

[15 Aug 2013 21:49] Miljenko Brkic
Description:
Values don't expire at time set with the "set" command

How to repeat:
Use "cache_only" cache policy:

mysql> select * from cache_policies;
+--------------+------------+------------+---------------+--------------+
| policy_name  | get_policy | set_policy | delete_policy | flush_policy |
+--------------+------------+------------+---------------+--------------+
| cache_policy | cache_only | cache_only | cache_only    | cache_only   |
+--------------+------------+------------+---------------+--------------+
1 row in set (0.00 sec)

Put value with expiration set to 60s:

set k 0 60 1     
v
STORED

Retrieving value few seconds (<60) later fails:

get k
END

Using epoch doesn't work as well.
[19 Jan 2015 13:11] Umesh Shastry
Hello Miljenko Brkic,

Thank you for the report.
Observed this behavior with latest trunk build.

Thanks,
Umesh
[19 Jan 2015 13:11] Umesh Shastry
// Build and version details

commit: d2b966a14472dd11ddbf663e861be5278090c8b0
date: 2015-01-06 12:04:22 +0100
build-date: 2015-01-06 12:30:42 +0100
short: d2b966a
branch: mysql-trunk

MySQL source 5.7.6

mysql> show variables like '%version%';
+-------------------------+---------------------------------------------------------+
| Variable_name           | Value                                                   |
+-------------------------+---------------------------------------------------------+
| innodb_version          | 5.7.6                                                   |
| protocol_version        | 10                                                      |
| slave_type_conversions  |                                                         |
| version                 | 5.7.6-m16-enterprise-commercial-advanced                |
| version_comment         | MySQL Enterprise Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64                                                  |
| version_compile_os      | Linux                                                   |
+-------------------------+---------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> select * from innodb_memcache.cache_policies;
+--------------+------------+------------+---------------+--------------+
| policy_name  | get_policy | set_policy | delete_policy | flush_policy |
+--------------+------------+------------+---------------+--------------+
| cache_policy | cache_only | cache_only | cache_only    | cache_only   |
+--------------+------------+------------+---------------+--------------+
1 row in set (0.00 sec)

// Telnet session

[root@cluster-repo ~]# telnet x.x.x.x 11211
Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
get k
END
set k 0 60 1
v
STORED
get k
END
get k
END

// I didn't observe this issue when catche policy was "innodb_only"

mysql> select * from innodb_memcache.cache_policies;
+--------------+-------------+-------------+---------------+--------------+
| policy_name  | get_policy  | set_policy  | delete_policy | flush_policy |
+--------------+-------------+-------------+---------------+--------------+
| cache_policy | innodb_only | innodb_only | innodb_only   | innodb_only  |
+--------------+-------------+-------------+---------------+--------------+
1 row in set (0.00 sec)

[root@cluster-repo ~]# telnet x.x.x.x 11211
Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
set k 0 60 1
v
STORED
get k
VALUE k 0 1
v
END
get k
VALUE k 0 1
v
END
[19 Jan 2015 13:19] Umesh Shastry
I could not reproduce this issue on latest 5.6 build

commit: 6d7e2a8240516c932ae8220166c10f930705a042
date: 2015-01-06 11:43:32 +0100
build-date: 2015-01-06 13:04:20 +0100
short: 6d7e2a8
branch: mysql-5.6

MySQL source 5.6.24

mysql> show variables like '%version%';
+-------------------------+---------------------------------------------------------+
| Variable_name           | Value                                                   |
+-------------------------+---------------------------------------------------------+
| innodb_version          | 5.6.24                                                  |
| protocol_version        | 10                                                      |
| slave_type_conversions  |                                                         |
| version                 | 5.6.24-enterprise-commercial-advanced                   |
| version_comment         | MySQL Enterprise Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64                                                  |
| version_compile_os      | linux-glibc2.5                                          |
+-------------------------+---------------------------------------------------------+
7 rows in set (0.01 sec)

mysql> select * from innodb_memcache.cache_policies;
+--------------+------------+------------+---------------+--------------+
| policy_name  | get_policy | set_policy | delete_policy | flush_policy |
+--------------+------------+------------+---------------+--------------+
| cache_policy | cache_only | cache_only | cache_only    | cache_only   |
+--------------+------------+------------+---------------+--------------+
1 row in set (0.00 sec)

//

[root@cluster-repo ~]# telnet x.x.x.x 11211
Trying x.x.x.x...
Connected to x.x.x.x.
Escape character is '^]'.
get v
END
get k
END
set k 0 60 1
v
STORED
get k
VALUE k 0 1
v
END
[5 Feb 2015 9:46] Allen Lai
Posted by developer:
 
This bug is caused by the expired time set to a interval value, not a time value.
For example, if the expired time is set to 60 secs, which means after 60 secs from current time, the item will be expired.
So, the expired time of item should be current time + 60 secs, not 60 secs.
[5 Feb 2015 14:22] Daniel Price
Posted by developer:
 
Fixed as of the upcoming 5.6.24, 5.7.6  release, and here's the changelog entry:

The expiration time ("exptime") defined using the "memcached" "set"
command was ignored. "InnoDB" "memcached" set the expiration time to an
interval value instead of a system time value. 

Thank you for the bug report.
[27 Apr 2015 11:18] Laurynas Biveinis
commit 093cdbf635a33f8c1bbd481deee2a375acce8390
Author: Allen.Lai <zheng.lai@oracle.com>
Date:   Thu Feb 5 17:14:13 2015 +0800

    Bug#20381342 EXPIRATION TIME IGNORED
    
    This bug is caused by the expired time set to a interval value, not
    a time value.
    For example, if the expired time is set to 60 secs, which means after 60
    secs from current time, the item will be expired.
    So, the expired time of item should be current time + 60 secs, not 60
    secs.
    
    Reviewed-by: Jimmy Yang<jimmy.yang@oracle.com> on IM.