List:Commits« Previous MessageNext Message »
From:damien Date:August 1 2007 8:40pm
Subject:bk commit into 5.1 tree (dkatz:1.2562) BUG#30091
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of dkatz. When dkatz does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-08-01 14:40:35-04:00, dkatz@stripped +1 -0
  Bug #30091  Deadlock in mysql-test-run during bootstrap on Windows with '--debug'

  sql/sql_cache.cc@stripped, 2007-08-01 14:40:18-04:00, dkatz@stripped +144 -141
    Moved the debug check_integrity call to after the cache state is set back to NO_FLUSH_IN_PROGRESS. This was hanging because the check_integrity call can only proceed when the flush is completed, but we were performing the check during a flush.
    
    Changed check_integrity to check that first_block is set before validating the blocks.

diff -Nrup a/sql/sql_cache.cc b/sql/sql_cache.cc
--- a/sql/sql_cache.cc	2007-07-16 14:34:33 -04:00
+++ b/sql/sql_cache.cc	2007-08-01 14:40:18 -04:00
@@ -878,13 +878,13 @@ ulong Query_cache::resize(ulong query_ca
   query_cache_size= query_cache_size_arg;
   ulong new_query_cache_size= init_cache();
 
-  DBUG_EXECUTE("check_querycache",check_integrity(0););
-
   STRUCT_LOCK(&structure_guard_mutex);
   m_cache_status= Query_cache::NO_FLUSH_IN_PROGRESS;
   pthread_cond_signal(&COND_cache_status_changed);
   STRUCT_UNLOCK(&structure_guard_mutex);
 
+  DBUG_EXECUTE("check_querycache",check_integrity(0););
+
   DBUG_RETURN(new_query_cache_size);
 }
 
@@ -4022,149 +4022,152 @@ my_bool Query_cache::check_integrity(boo
 
   DBUG_PRINT("qcache", ("physical address check ..."));
   ulong free=0, used=0;
-  Query_cache_block * block = first_block;
-  do
+  Query_cache_block * block;
+  if(block= first_block)
   {
-    DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
-			  (ulong) block, (uint) block->type));  
-    // Check allignment
-    if ((((long)block) % (long) ALIGN_SIZE(1)) !=
-	(((long)first_block) % (long)ALIGN_SIZE(1)))
-    {
-      DBUG_PRINT("error",
-		 ("block 0x%lx do not aligned by %d", (ulong) block,
-		  (int) ALIGN_SIZE(1)));
-      result = 1;
-    }
-    // Check memory allocation
-    if (block->pnext == first_block) // Is it last block?
+    do
     {
-      if (((uchar*)block) + block->length != 
-	  ((uchar*)first_block) + query_cache_size)
-      {
-	DBUG_PRINT("error", 
-		   ("block 0x%lx, type %u, ended at 0x%lx, but cache ended at 0x%lx",
-		    (ulong) block, (uint) block->type, 
-		    (ulong) (((uchar*)block) + block->length),
-		    (ulong) (((uchar*)first_block) + query_cache_size)));
-	result = 1;
+      DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
+         (ulong) block, (uint) block->type));  
+      // Check allignment
+      if ((((long)block) % (long) ALIGN_SIZE(1)) !=
+          (((long)first_block) % (long)ALIGN_SIZE(1)))
+      {
+        DBUG_PRINT("error",
+          ("block 0x%lx do not aligned by %d", (ulong) block,
+          (int) ALIGN_SIZE(1)));
+        result = 1;
       }
-    }
-    else
-      if (((uchar*)block) + block->length != ((uchar*)block->pnext))
+      // Check memory allocation
+      if (block->pnext == first_block) // Is it last block?
       {
-	DBUG_PRINT("error", 
-		   ("block 0x%lx, type %u, ended at 0x%lx, but next block begining at 0x%lx",
-		    (ulong) block, (uint) block->type, 
-		    (ulong) (((uchar*)block) + block->length),
-		    (ulong) ((uchar*)block->pnext)));
-      }
-    if (block->type == Query_cache_block::FREE)
-      free+= block->length;
-    else
-      used+= block->length;
-    switch(block->type) {
-    case Query_cache_block::FREE:
-    {
-      Query_cache_memory_bin *bin = *((Query_cache_memory_bin **)
-				      block->data());
-      //is it correct pointer?
-      if (((uchar*)bin) < ((uchar*)bins) ||
-	  ((uchar*)bin) >= ((uchar*)first_block))
-      {
-	DBUG_PRINT("error", 
-		   ("free block 0x%lx have bin pointer 0x%lx beyaond of bins array bounds [0x%lx,0x%lx]",
-		    (ulong) block, 
-		    (ulong) bin,
-		    (ulong) bins,
-		    (ulong) first_block));
-	result = 1;
+        if (((uchar*)block) + block->length != 
+            ((uchar*)first_block) + query_cache_size)
+        {
+          DBUG_PRINT("error", 
+            ("block 0x%lx, type %u, ended at 0x%lx, but cache ended at 0x%lx",
+            (ulong) block, (uint) block->type, 
+            (ulong) (((uchar*)block) + block->length),
+            (ulong) (((uchar*)first_block) + query_cache_size)));
+          result = 1;
+        }
       }
       else
-      {
-	int idx = (((uchar*)bin) - ((uchar*)bins)) /
-	  sizeof(Query_cache_memory_bin);
-	if (in_list(bins[idx].free_blocks, block, "free memory"))
-	  result = 1;
+        if (((uchar*)block) + block->length != ((uchar*)block->pnext))
+        {
+          DBUG_PRINT("error", 
+           ("block 0x%lx, type %u, ended at 0x%lx, but next block begining at 0x%lx",
+            (ulong) block, (uint) block->type, 
+            (ulong) (((uchar*)block) + block->length),
+            (ulong) ((uchar*)block->pnext)));
+        }
+      if (block->type == Query_cache_block::FREE)
+        free+= block->length;
+      else
+        used+= block->length;
+      switch(block->type) {
+      case Query_cache_block::FREE:
+      {
+        Query_cache_memory_bin *bin = *((Query_cache_memory_bin **)
+                block->data());
+        //is it correct pointer?
+        if (((uchar*)bin) < ((uchar*)bins) ||
+            ((uchar*)bin) >= ((uchar*)first_block))
+        {
+          DBUG_PRINT("error", 
+           ("free block 0x%lx have bin pointer 0x%lx beyaond of bins array bounds [0x%lx,0x%lx]",
+            (ulong) block, 
+            (ulong) bin,
+            (ulong) bins,
+            (ulong) first_block));
+          result = 1;
+        }
+        else
+        {
+          int idx = (((uchar*)bin) - ((uchar*)bins)) /
+            sizeof(Query_cache_memory_bin);
+          if (in_list(bins[idx].free_blocks, block, "free memory"))
+            result = 1;
+        }
+        break;
       }
-      break;
-    }
-    case Query_cache_block::TABLE:
-      if (in_list(tables_blocks, block, "tables"))
-	result = 1;
-      if (in_table_list(block->table(0),  block->table(0), "table list root"))
-	result = 1;
-      break;
-    case Query_cache_block::QUERY:
-    {
-      if (in_list(queries_blocks, block, "query"))
-	result = 1;
-      for (TABLE_COUNTER_TYPE j=0; j < block->n_tables; j++)
-      {
-	Query_cache_block_table *block_table = block->table(j);
-	Query_cache_block_table *block_table_root = 
-	  (Query_cache_block_table *) 
-	  (((uchar*)block_table->parent) -
-	   ALIGN_SIZE(sizeof(Query_cache_block_table)));
-	
-    	if (in_table_list(block_table, block_table_root, "table list"))
-    	  result = 1;
+      case Query_cache_block::TABLE:
+        if (in_list(tables_blocks, block, "tables"))
+          result = 1;
+        if (in_table_list(block->table(0),  block->table(0), "table list root"))
+          result = 1;
+        break;
+      case Query_cache_block::QUERY:
+      {
+        if (in_list(queries_blocks, block, "query"))
+          result = 1;
+        for (TABLE_COUNTER_TYPE j=0; j < block->n_tables; j++)
+        {
+          Query_cache_block_table *block_table = block->table(j);
+          Query_cache_block_table *block_table_root = 
+            (Query_cache_block_table *) 
+            (((uchar*)block_table->parent) -
+             ALIGN_SIZE(sizeof(Query_cache_block_table)));
+  
+          if (in_table_list(block_table, block_table_root, "table list"))
+            result = 1;
+        }
+        break;
       }
-      break;
-    }
-    case Query_cache_block::RES_INCOMPLETE:
-      // This type of block can be not lincked yet (in multithread environment)
-      break;
-    case Query_cache_block::RES_BEG:
-    case Query_cache_block::RES_CONT:
-    case Query_cache_block::RESULT:
-    {
-      Query_cache_block * query_block = block->result()->parent();
-      if (((uchar*)query_block) < ((uchar*)first_block) ||
-	  ((uchar*)query_block) >= (((uchar*)first_block) + query_cache_size))
-      {
-	DBUG_PRINT("error", 
-		   ("result block 0x%lx have query block pointer 0x%lx beyaond of block pool bounds [0x%lx,0x%lx]",
-		    (ulong) block,
-		    (ulong) query_block,
-		    (ulong) first_block,
-		    (ulong) (((uchar*)first_block) + query_cache_size)));
-	result = 1;
+      case Query_cache_block::RES_INCOMPLETE:
+        // This type of block can be not lincked yet (in multithread environment)
+        break;
+      case Query_cache_block::RES_BEG:
+      case Query_cache_block::RES_CONT:
+      case Query_cache_block::RESULT:
+      {
+        Query_cache_block * query_block = block->result()->parent();
+        if (((uchar*)query_block) < ((uchar*)first_block) ||
+            ((uchar*)query_block) >= (((uchar*)first_block) + query_cache_size))
+        {
+          DBUG_PRINT("error", 
+           ("result block 0x%lx have query block pointer 0x%lx beyaond of block pool bounds [0x%lx,0x%lx]",
+            (ulong) block,
+            (ulong) query_block,
+            (ulong) first_block,
+            (ulong) (((uchar*)first_block) + query_cache_size)));
+          result = 1;
+        }
+        else
+        {
+          BLOCK_LOCK_RD(query_block);
+          if (in_list(queries_blocks, query_block, "query from results"))
+            result = 1;
+          if (in_list(query_block->query()->result(), block,
+                "results"))
+            result = 1;
+          BLOCK_UNLOCK_RD(query_block);
+        }
+        break;
       }
-      else
-      {
-	BLOCK_LOCK_RD(query_block);
-	if (in_list(queries_blocks, query_block, "query from results"))
-	  result = 1;
-	if (in_list(query_block->query()->result(), block,
-		    "results"))
-	  result = 1;
-	BLOCK_UNLOCK_RD(query_block);
+      default:
+        DBUG_PRINT("error", ("block 0x%lx have incorrect type %u",
+                             (long) block, block->type));
+        result = 1;
       }
-      break;
-    }
-    default:
-      DBUG_PRINT("error", ("block 0x%lx have incorrect type %u",
-                           (long) block, block->type));
-      result = 1;
-    }
     
-    block = block->pnext;
-  } while (block != first_block);
+      block = block->pnext;
+    } while (block != first_block);
+  }
   
   if (used + free != query_cache_size)
   {
     DBUG_PRINT("error",
-	       ("used memory (%lu) + free memory (%lu) !=  query_cache_size (%lu)",
-		used, free, query_cache_size));
+         ("used memory (%lu) + free memory (%lu) !=  query_cache_size (%lu)",
+    used, free, query_cache_size));
     result = 1;
   }
   
   if (free != free_memory)
   {
     DBUG_PRINT("error",
-	       ("free memory (%lu) != free_memory (%lu)",
-		free, free_memory));
+         ("free memory (%lu) != free_memory (%lu)",
+    free, free_memory));
     result = 1;
   }
 
@@ -4174,30 +4177,30 @@ my_bool Query_cache::check_integrity(boo
     do
     {
       DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
-			    (ulong) block, (uint) block->type));
+          (ulong) block, (uint) block->type));
       size_t length;
       uchar *key = query_cache_query_get_key((uchar*) block, &length, 0);
       uchar* val = hash_search(&queries, key, length);
       if (((uchar*)block) != val)
       {
-	DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx",
-			     (ulong) block, (ulong) val));
+  DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx",
+           (ulong) block, (ulong) val));
       }
       if (in_blocks(block))
-	result = 1;
+  result = 1;
       Query_cache_block * results = block->query()->result();
       if (results)
       {
-	Query_cache_block * result_block = results;
-	do
-	{
-	  DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
-				(ulong) block, (uint) block->type));
-	  if (in_blocks(result_block))
-	    result = 1;
+  Query_cache_block * result_block = results;
+  do
+  {
+    DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
+        (ulong) block, (uint) block->type));
+    if (in_blocks(result_block))
+      result = 1;
 
-	  result_block = result_block->next;
-	} while (result_block != results);
+    result_block = result_block->next;
+  } while (result_block != results);
       }
       block = block->next;
     } while (block != queries_blocks);
@@ -4209,18 +4212,18 @@ my_bool Query_cache::check_integrity(boo
     do
     {
       DBUG_PRINT("qcache", ("block 0x%lx, type %u...", 
-			    (ulong) block, (uint) block->type));
+          (ulong) block, (uint) block->type));
       size_t length;
       uchar *key = query_cache_table_get_key((uchar*) block, &length, 0);
       uchar* val = hash_search(&tables, key, length);
       if (((uchar*)block) != val)
       {
-	DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx",
-			     (ulong) block, (ulong) val));
+  DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx",
+           (ulong) block, (ulong) val));
       }
       
       if (in_blocks(block))
-	result = 1;
+  result = 1;
       block=block->next;
     } while (block != tables_blocks);
   }
Thread
bk commit into 5.1 tree (dkatz:1.2562) BUG#30091damien1 Aug