[Commits] Rev 3844: Fix possible race condition in Query cache. in file:///home/bell/maria/bzr/work-maria-E351/

sanja at montyprogram.com sanja at montyprogram.com
Mon Aug 5 17:35:32 EEST 2013


At file:///home/bell/maria/bzr/work-maria-E351/

------------------------------------------------------------
revno: 3844
revision-id: sanja at montyprogram.com-20130805143438-laatt984hf8uh9jf
parent: psergey at askmonty.org-20130731132452-4qb11t56i2jw16aa
committer: sanja at montyprogram.com
branch nick: work-maria-E351
timestamp: Mon 2013-08-05 17:34:38 +0300
message:
  Fix possible race condition in Query cache.
-------------- next part --------------
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc	2013-05-30 05:23:49 +0000
+++ b/sql/sql_cache.cc	2013-08-05 14:34:38 +0000
@@ -1312,17 +1312,17 @@ ulong Query_cache::resize(ulong query_ca
     {
       BLOCK_LOCK_WR(block);
       Query_cache_query *query= block->query();
-      if (query && query->writer())
+      if (query->writer())
       {
         /*
-           Drop the writer; this will cancel any attempts to store 
+           Drop the writer; this will cancel any attempts to store
            the processed statement associated with this writer.
          */
         query->writer()->first_query_block= NULL;
         query->writer(0);
         refused++;
       }
-      BLOCK_UNLOCK_WR(block);
+      query->unlock_n_destroy();
       block= block->next;
     } while (block != queries_blocks);
   }
@@ -4247,11 +4247,11 @@ my_bool Query_cache::move_by_type(uchar
     size_t key_length;
     key=query_cache_query_get_key((uchar*) block, &key_length, 0);
     my_hash_first(&queries, (uchar*) key, key_length, &record_idx);
-    // Move table of used tables 
-    memmove((char*) new_block->table(0), (char*) block->table(0),
-	   ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
     block->query()->unlock_n_destroy();
     block->destroy();
+    // Move table of used tables
+    memmove((char*) new_block->table(0), (char*) block->table(0),
+	   ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table)));
     new_block->init(len);
     new_block->type=Query_cache_block::QUERY;
     new_block->used=used;



More information about the commits mailing list