MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Andrew Hutchings Date:July 4 2010 9:02pm
Subject:bzr commit into mysql-trunk branch (Andrew.Hutchings:3098) Bug#45166
View as plain text  
#At file:///home/linuxjedi/Programming/Bzr/mysql/mysql-trunk-merge-bug-45166/ based on revid:li-bing.song@stripped

 3098 Andrew Hutchings	2010-07-04
      Bug #45166	Query Cache invalidated row count should show in 'show status'
      
      Add Qcache_queries_removed counter which contains a count of queries removed from the query cache

    modified:
      mysql-test/r/query_cache.result
      mysql-test/t/query_cache.test
      sql/mysqld.cc
      sql/sql_cache.cc
      sql/sql_cache.h
=== modified file 'mysql-test/r/query_cache.result'
--- a/mysql-test/r/query_cache.result	2010-02-26 09:58:33 +0000
+++ b/mysql-test/r/query_cache.result	2010-07-04 21:02:21 +0000
@@ -38,10 +38,18 @@ Qcache_inserts	1
 show status like "Qcache_hits";
 Variable_name	Value
 Qcache_hits	1
+## Should be 0
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	0
 drop table t1;
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
+## Drop should clear out queries, should be 1
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	1
 create table t1 (a int not null);
 insert into t1 values (1),(2),(3);
 create table t2 (a int not null);
@@ -93,6 +101,10 @@ insert into t3 values (8);
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
+## Insert should clear out queries, should be 3
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	3
 select * from t3;
 a
 1
@@ -123,6 +135,10 @@ update t3 set a=10 where a=1;
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
+## Update should clear out queries, should be 5
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	5
 select * from t3;
 a
 10
@@ -154,6 +170,10 @@ show status like "Qcache_queries_in_cach
 Variable_name	Value
 Qcache_queries_in_cache	0
 drop table t1, t2, t3;
+## Drop should clear out queries, should be 7
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	7
 set query_cache_type=demand;
 create table t1 (a int not null);
 insert into t1 values (1),(2),(3);
@@ -187,6 +207,10 @@ reset query cache;
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
+## Reset should clear out queries, should be 8
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	8
 select sql_no_cache * from t1;
 a
 1
@@ -232,6 +256,10 @@ Note	1003	select benchmark(1,1) AS `benc
 show status like "Qcache_queries_in_cache";
 Variable_name	Value
 Qcache_queries_in_cache	0
+## Should still be 8
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	8
 create table t2 (a text not null);
 insert into t1 values("1111111111111111111111111111111111111111111111111111");
 insert into t2 select * from t1;
@@ -258,6 +286,10 @@ Qcache_hits	4
 show status like "Qcache_lowmem_prunes";
 Variable_name	Value
 Qcache_lowmem_prunes	0
+## Should still be 8
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	8
 select a as a1, a as a2 from t1;
 select a as a2, a as a3 from t1;
 select a as a3, a as a4 from t1;
@@ -271,7 +303,15 @@ Qcache_queries_in_cache	2
 show status like "Qcache_lowmem_prunes";
 Variable_name	Value
 Qcache_lowmem_prunes	2
+## Lowmem_prunes should clear out queries, should be 10
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	10
 reset query cache;
+## Reset should clear out queries, should be 12
+show status like "Qcache_queries_removed";
+Variable_name	Value
+Qcache_queries_removed	12
 insert into t2 select * from t1;
 insert into t1 select * from t2;
 insert into t2 select * from t1;

=== modified file 'mysql-test/t/query_cache.test'
--- a/mysql-test/t/query_cache.test	2010-02-26 09:58:33 +0000
+++ b/mysql-test/t/query_cache.test	2010-07-04 21:02:21 +0000
@@ -37,11 +37,15 @@ select length(now()) from t1;
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_inserts";
 show status like "Qcache_hits";
+--echo ## Should be 0
+show status like "Qcache_queries_removed";
 
 drop table t1;
 
 show status like "Qcache_queries_in_cache";
 
+--echo ## Drop should clear out queries, should be 1
+show status like "Qcache_queries_removed";
 #
 # MERGE TABLES with INSERT/UPDATE and DELETE
 #
@@ -63,6 +67,10 @@ show status like "Qcache_hits";
 show status like "Qcache_queries_in_cache";
 insert into t3 values (8);
 show status like "Qcache_queries_in_cache";
+
+--echo ## Insert should clear out queries, should be 3
+show status like "Qcache_queries_removed";
+
 # update
 select * from t3;
 show status like "Qcache_queries_in_cache";
@@ -72,6 +80,9 @@ select * from t1;
 show status like "Qcache_queries_in_cache";
 update t3 set a=10 where a=1;
 show status like "Qcache_queries_in_cache";
+
+--echo ## Update should clear out queries, should be 5
+show status like "Qcache_queries_removed";
 #delete
 select * from t3;
 show status like "Qcache_queries_in_cache";
@@ -82,6 +93,9 @@ show status like "Qcache_queries_in_cach
 delete from t3 where a=10;
 show status like "Qcache_queries_in_cache";
 drop table t1, t2, t3;
+--echo ## Drop should clear out queries, should be 7
+show status like "Qcache_queries_removed";
+
 #
 # SELECT SQL_CACHE ...
 #
@@ -102,6 +116,9 @@ set query_cache_type=on;
 #
 reset query cache;
 show status like "Qcache_queries_in_cache";
+
+--echo ## Reset should clear out queries, should be 8
+show status like "Qcache_queries_removed";
 #
 # SELECT SQL_NO_CACHE
 #
@@ -130,6 +147,10 @@ select CURRENT_USER() from t1;
 select benchmark(1,1) from t1;
 explain extended select benchmark(1,1) from t1;
 show status like "Qcache_queries_in_cache";
+
+--echo ## Should still be 8
+show status like "Qcache_queries_removed";
+
 #
 # Tests when the cache is filled
 #
@@ -156,6 +177,10 @@ insert into t1 select * from t2; # 4181
 
 show status like "Qcache_hits";
 show status like "Qcache_lowmem_prunes";
+
+--echo ## Should still be 8
+show status like "Qcache_queries_removed";
+
 disable_result_log;
 select a as a1, a as a2 from t1;
 select a as a2, a as a3 from t1;
@@ -166,7 +191,11 @@ enable_result_log;
 show status like "Qcache_hits";
 show status like "Qcache_queries_in_cache";
 show status like "Qcache_lowmem_prunes";
+--echo ## Lowmem_prunes should clear out queries, should be 10
+show status like "Qcache_queries_removed";
 reset query cache;
+--echo ## Reset should clear out queries, should be 12
+show status like "Qcache_queries_removed";
 #
 # Query bigger then query_cache_limit
 #

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2010-07-02 19:38:04 +0000
+++ b/sql/mysqld.cc	2010-07-04 21:02:21 +0000
@@ -6797,6 +6797,7 @@ SHOW_VAR status_vars[]= {
   {"Qcache_lowmem_prunes",     (char*) &query_cache.lowmem_prunes, SHOW_LONG},
   {"Qcache_not_cached",        (char*) &query_cache.refused,    SHOW_LONG},
   {"Qcache_queries_in_cache",  (char*) &query_cache.queries_in_cache, SHOW_LONG_NOFLUSH},
+  {"Qcache_queries_removed",   (char*) &query_cache.removed, SHOW_LONG},
   {"Qcache_total_blocks",      (char*) &query_cache.total_blocks, SHOW_LONG_NOFLUSH},
 #endif /*HAVE_QUERY_CACHE*/
   {"Queries",                  (char*) &show_queries,            SHOW_FUNC},

=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2010-05-05 22:02:08 +0000
+++ b/sql/sql_cache.cc	2010-07-04 21:02:21 +0000
@@ -948,6 +948,7 @@ Query_cache::abort(Query_cache_tls *quer
     BLOCK_LOCK_WR(query_block);
     // The following call will remove the lock on query_block
     free_query(query_block);
+    query_cache.removed++;
     query_cache_tls->first_query_block= NULL;
     DBUG_EXECUTE("check_querycache", check_integrity(1););
   }
@@ -1066,7 +1067,7 @@ Query_cache::Query_cache(ulong query_cac
 			 uint def_table_hash_size_arg)
   :query_cache_size(0),
    query_cache_limit(query_cache_limit_arg),
-   queries_in_cache(0), hits(0), inserts(0), refused(0),
+   queries_in_cache(0), hits(0), inserts(0), refused(0), removed(0),
    total_blocks(0), lowmem_prunes(0), m_query_cache_is_disabled(FALSE),
    min_allocation_unit(ALIGN_SIZE(min_allocation_unit_arg)),
    min_result_data_size(ALIGN_SIZE(min_result_data_size_arg)),
@@ -2259,6 +2260,7 @@ void Query_cache::flush_cache()
   {
     BLOCK_LOCK_WR(queries_blocks);
     free_query_internal(queries_blocks);
+    query_cache.removed++;
   }
 }
 
@@ -2299,6 +2301,7 @@ my_bool Query_cache::free_old_query()
     {
       free_query(query_block);
       lowmem_prunes++;
+      query_cache.removed++;
       DBUG_RETURN(0);
     }
   }
@@ -2759,6 +2762,7 @@ Query_cache::invalidate_query_block_list
     Query_cache_block *query_block= list_root->next->block();
     BLOCK_LOCK_WR(query_block);
     free_query(query_block);
+    query_cache.removed++;
     DBUG_EXECUTE_IF("debug_cache_locks", sleep(10););
   }
 }

=== modified file 'sql/sql_cache.h'
--- a/sql/sql_cache.h	2010-04-12 13:17:37 +0000
+++ b/sql/sql_cache.h	2010-07-04 21:02:21 +0000
@@ -285,7 +285,7 @@ public:
   ulong query_cache_size, query_cache_limit;
   /* statistics */
   ulong free_memory, queries_in_cache, hits, inserts, refused,
-    free_memory_blocks, total_blocks, lowmem_prunes;
+    free_memory_blocks, total_blocks, lowmem_prunes, removed;
 
 
 private:


Attachment: [text/bzr-bundle] bzr/andrew.hutchings@sun.com-20100704210221-3i9u09s6wclhp39r.bundle
Thread
bzr commit into mysql-trunk branch (Andrew.Hutchings:3098) Bug#45166Andrew Hutchings4 Jul