Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.255.2.11
diff -u -r1.255.2.11 menu.inc
--- includes/menu.inc	9 Apr 2008 21:11:44 -0000	1.255.2.11
+++ includes/menu.inc	21 Apr 2008 08:33:45 -0000
@@ -1658,7 +1658,6 @@
       $menu = $cache->data;
     }
     else {
-      db_query('DELETE FROM {menu_router}');
       // We need to manually call each module so that we can know which module
       // a given item came from.
       $callbacks = array();
@@ -2254,6 +2253,11 @@
   }
   array_multisort($sort, SORT_NUMERIC, $menu);
 
+  // To guarantee the consistency of the {menu_router} table,
+  // we have no other choice here than to LOCK the whole table.
+  db_lock_table('{menu_router}');
+  db_query('DELETE FROM {menu_router}');
+
   // Apply inheritance rules.
   foreach ($menu as $path => $v) {
     $item = &$menu[$path];
@@ -2352,6 +2356,8 @@
       $item['title'], $item['title callback'], $title_arguments,
       $item['type'], $item['block callback'], $item['description'], $item['position'], $item['weight'], $item['include file']);
   }
+  db_unlock_tables();
+  
   // Sort the masks so they are in order of descending fit, and store them.
   $masks = array_keys($masks);
   rsort($masks);
