[MDEV-6777] Query cache with inconsistent results + TTL Created: 2014-09-24 Updated: 2015-11-17 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Query Cache |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | roberto spadim | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Some applications use inconsistent cache results (even with memcache), i don't know the right name but it's something related to Strong consistency and weak consistency (http://en.wikipedia.org/wiki/Cache_coherence) must review technical documentation to use better names here Today query cache invalidate all queries from query cache when a table change (INSERT/DELETE/UPDATE), the idea is don't invalidate some known queries and only invalidate it with a time to live or a flush command 1) implement a SQL_CACHE_INCONSISTENT keyword or something like it, that tell query cache to not invalidate this query when a table invalidation occur (must check if we will have problems with replication), example:
2) implement a TTL (SQL_CACHE_TTL) query cache (there's a patch, must check if it's nice or not - http://ebergen.net/wordpress/2007/04/23/select-sql_cache_ttl/)
2.1) something to think about (variable query_cache_max_ttl) when insert the first TTL query it will have a variable at struct Query_cache_query, something like
how to check if query is expired or not (using query_cache_max_ttl):
2.2) when invalidate query cache queries? 3) implement a FLUSH INCONSISTENT QUERY CACHE command (we could include this at MDEV-4584), it will remove only queries with SQL_CACHE_INCONSISTENT from query cache 4) at query cache internal (sql_cache.cc /.h)
only remove the table if: m_cached_query_count=m_cached_query_inconsistent_count=0 if table have m_cached_query_inconsistent_count>0, it can't be removed from query cache with a table invalidation, just "consistent" queries should be removed 5) only RESET QUERY CACHE or FLUSH INCONSISTENT QUERY CACHE <WITHOUT_BINLOG> will remove inconsistent queries from query cache 5.1) check what to do with binlog and FLUSH command, for example, we could flush inconsistent query cache at master, but don't replicate this to slaves... must check what's better in this case maybe just add WITHOUT_BINLOG is ok — |
| Comments |
| Comment by roberto spadim [ 2014-09-24 ] |
|
must test this patch if it's usefull or not |