简体   繁体   中英

Innodb memcached plugin in RDS not deleting expired rows

I recently setup an RDS instance in AWS for MySQL 5.6 with the new Memcached InnoDB plugin. Everything works great and my app can store and retrieve cached items from the mapped table. When I store items I provide a timeout, and memcached correctly does not return the item once its TTL has expired. So far so good....

However when I look at the underlying table, it is full of rows which have already expired.

The MySQL documentation ( http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-intro.html ) indicates that item expiration has no effect when using the " innodb_only " caching policy (although it doesn't explicitly indicate which operation it is referring to). In any case my cache_policies table looks like this:

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

So, per the docs the expiration field should be respected.

For reference my containers table looks like this:

mysql> select * from innodb_memcache.containers;
+---------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| name    | db_schema | db_table  | key_columns | value_columns | flags | cas_column | expire_time_column | unique_idx_name_on_key |
+---------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
| default | sessions  | userData  | sessionID   | data          | c3    | c4         | c5                 | PRIMARY                | 
+---------+-----------+-----------+-------------+---------------+-------+------------+--------------------+------------------------+
2 rows in set (0.00 sec)

And the data table is:

mysql> desc sessions.userData;
+-----------+---------------------+------+-----+---------+-------+
| Field     | Type                | Null | Key | Default | Extra |
+-----------+---------------------+------+-----+---------+-------+
| sessionID | varchar(128)        | NO   | PRI | NULL    |       | 
| data      | blob                | YES  |     | NULL    |       | 
| c3        | int(11)             | YES  |     | NULL    |       | 
| c4        | bigint(20) unsigned | YES  |     | NULL    |       | 
| c5        | int(11)             | YES  |     | NULL    |       | 
+-----------+---------------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

One more detail, the MySQL docs state that after modifying caching policies you need to re-install the Memcached plugin, but I did not find a way to do this on RDS, so I removed the Memcached option group, rebooted, added the memcached option group again, rebooted again... but there was no apparent change in behavior.

So, to conclude, am I missing some step or configuration here? I would hate to have to create a separate process just to delete the expired rows from the table, since I was expecting the Memcached integration to do this for me.

I'm by no means an expert, as I've just started to play around with memcached myself. However, this is from the MySQL documentation for the python tutorial.

It seems to be saying that if you use the InnoDB memcached plugin, MySQL will handle cache expiration, and it really doesn't matter what you enter for the cache expire time.

And for the flags, expire, and CAS values, we specify corresponding columns based on the settings from the sample table demo.test. These values are typically not significant in applications using the InnoDB memcached plugin, because MySQL keeps the data synchronized and there is no need to worry about data expiring or being stale.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM