MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:tomas Date:May 15 2006 2:24pm
Subject:bk commit into 4.1 tree (tomas:1.2473) BUG#16875
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of tomas. When tomas 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
  1.2473 06/05/15 16:23:59 tomas@stripped +11 -0
  Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail
  - invalidate ndb dict cache on cluster disconnect (ClusterMgr.cpp)
  - add check for correct frm on external lock when table cache is found invalid

  mysql-test/t/ndb_autodiscover3.test
    1.1 06/05/15 16:23:55 tomas@stripped +65 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  mysql-test/t/ndb_autodiscover3.test
    1.0 06/05/15 16:23:55 tomas@stripped +0 -0
    BitKeeper file /home/tomas/mysql-4.1/mysql-test/t/ndb_autodiscover3.test

  mysql-test/r/ndb_autodiscover3.result
    1.1 06/05/15 16:23:54 tomas@stripped +9 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  sql/ha_ndbcluster.cc
    1.180 06/05/15 16:23:54 tomas@stripped +16 -1
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/ndb_cluster_connection_impl.hpp
    1.2 06/05/15 16:23:54 tomas@stripped +1 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/ndb_cluster_connection.cpp
    1.21 06/05/15 16:23:54 tomas@stripped +6 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/TransporterFacade.hpp
    1.22 06/05/15 16:23:54 tomas@stripped +6 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/DictCache.hpp
    1.9 06/05/15 16:23:54 tomas@stripped +3 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/DictCache.cpp
    1.14 06/05/15 16:23:54 tomas@stripped +36 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/ClusterMgr.hpp
    1.6 06/05/15 16:23:54 tomas@stripped +1 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/src/ndbapi/ClusterMgr.cpp
    1.17 06/05/15 16:23:54 tomas@stripped +5 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  ndb/include/ndbapi/ndb_cluster_connection.hpp
    1.9 06/05/15 16:23:54 tomas@stripped +1 -0
    Bug #16875 Using stale MySQLD FRM files can cause restored cluster to fail

  mysql-test/r/ndb_autodiscover3.result
    1.0 06/05/15 16:23:54 tomas@stripped +0 -0
    BitKeeper file /home/tomas/mysql-4.1/mysql-test/r/ndb_autodiscover3.result

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	tomas
# Host:	poseidon.ndb.mysql.com
# Root:	/home/tomas/mysql-4.1

--- 1.16/ndb/src/ndbapi/ClusterMgr.cpp	2005-07-14 18:07:55 +02:00
+++ 1.17/ndb/src/ndbapi/ClusterMgr.cpp	2006-05-15 16:23:54 +02:00
@@ -70,6 +70,7 @@
   noOfAliveNodes= 0;
   noOfConnectedNodes= 0;
   theClusterMgrThread= 0;
+  m_connect_count = 0;
   DBUG_VOID_RETURN;
 }
 
@@ -456,6 +457,10 @@
   theNode.nfCompleteRep = false;
   
   if(noOfAliveNodes == 0){
+    theFacade.m_globalDictCache.lock();
+    theFacade.m_globalDictCache.invalidate_all();
+    theFacade.m_globalDictCache.unlock();
+    m_connect_count ++;
     NFCompleteRep rep;
     for(Uint32 i = 1; i<MAX_NODES; i++){
       if(theNodes[i].defined && theNodes[i].nfCompleteRep == false){

--- 1.5/ndb/src/ndbapi/ClusterMgr.hpp	2005-05-04 18:40:52 +02:00
+++ 1.6/ndb/src/ndbapi/ClusterMgr.hpp	2006-05-15 16:23:54 +02:00
@@ -78,6 +78,7 @@
   
   const Node &  getNodeInfo(NodeId) const;
   Uint32        getNoOfConnectedNodes() const;
+  Uint32        m_connect_count;
   
 private:
   Uint32        noOfAliveNodes;

--- 1.13/ndb/src/ndbapi/DictCache.cpp	2005-08-18 14:02:20 +02:00
+++ 1.14/ndb/src/ndbapi/DictCache.cpp	2006-05-15 16:23:54 +02:00
@@ -255,6 +255,42 @@
   abort();
 }
 
+
+unsigned
+GlobalDictCache::get_size()
+{
+  NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
+  int sz = 0;
+  while(curr != 0){
+    sz += curr->theData->size();
+    curr = m_tableHash.getNext(curr);
+  }
+  return sz;
+}
+
+void
+GlobalDictCache::invalidate_all()
+{
+  DBUG_ENTER("GlobalDictCache::invalidate_all");
+  NdbElement_t<Vector<TableVersion> > * curr = m_tableHash.getNext(0);
+  while(curr != 0){
+    Vector<TableVersion> * vers = curr->theData;
+    if (vers->size())
+    {
+      TableVersion * ver = & vers->back();
+      ver->m_impl->m_status = NdbDictionary::Object::Invalid;
+      ver->m_status = DROPPED;
+      if (ver->m_refCount == 0)
+      {
+        delete ver->m_impl;
+        vers->erase(vers->size() - 1);
+      }
+    }
+    curr = m_tableHash.getNext(curr);
+  }
+  DBUG_VOID_RETURN;
+}
+
 void
 GlobalDictCache::release(NdbTableImpl * tab){
   unsigned i;

--- 1.8/ndb/src/ndbapi/DictCache.hpp	2005-08-18 14:02:20 +02:00
+++ 1.9/ndb/src/ndbapi/DictCache.hpp	2006-05-15 16:23:54 +02:00
@@ -71,6 +71,9 @@
 
   void alter_table_rep(const char * name, 
 		       Uint32 tableId, Uint32 tableVersion, bool altered);
+
+  unsigned get_size();
+  void invalidate_all();
 public:
   enum Status {
     OK = 0,

--- 1.21/ndb/src/ndbapi/TransporterFacade.hpp	2006-04-18 14:34:09 +02:00
+++ 1.22/ndb/src/ndbapi/TransporterFacade.hpp	2006-05-15 16:23:54 +02:00
@@ -265,6 +265,12 @@
 #include "ClusterMgr.hpp"
 
 inline
+unsigned Ndb_cluster_connection_impl::get_connect_count() const
+{
+  return TransporterFacade::instance()->theClusterMgr->m_connect_count;
+}
+
+inline
 bool
 TransporterFacade::check_send_size(Uint32 node_id, Uint32 send_size)
 {

--- 1.179/sql/ha_ndbcluster.cc	2006-02-10 17:40:18 +01:00
+++ 1.180/sql/ha_ndbcluster.cc	2006-05-15 16:23:54 +02:00
@@ -3306,8 +3306,23 @@
       {
         m_table= (void *)tab;
         m_table_version = tab->getObjectVersion();
-        if (!(my_errno= build_index_list(ndb, table, ILBP_OPEN)))
+        if ((my_errno= build_index_list(ndb, table, ILBP_OPEN)))
           DBUG_RETURN(my_errno);
+
+        const void *data, *pack_data;
+        uint length, pack_length;
+        if (readfrm(table->path, &data, &length) ||
+            packfrm(data, length, &pack_data, &pack_length) ||
+            pack_length != tab->getFrmLength() ||
+            memcmp(pack_data, tab->getFrmData(), pack_length))
+        {
+          my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
+          my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
+          NdbError err= ndb->getNdbError(NDB_INVALID_SCHEMA_OBJECT);
+          DBUG_RETURN(ndb_to_mysql_error(&err));
+        }
+        my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
+        my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR));
       }
       m_table_info= tab_info;
     }

--- 1.8/ndb/include/ndbapi/ndb_cluster_connection.hpp	2004-12-22 16:28:56 +01:00
+++ 1.9/ndb/include/ndbapi/ndb_cluster_connection.hpp	2006-05-15 16:23:54 +02:00
@@ -83,6 +83,7 @@
   void set_optimized_node_selection(int val);
 
   unsigned no_db_nodes();
+  unsigned get_connect_count() const;
 #endif
 
 private:

--- 1.20/ndb/src/ndbapi/ndb_cluster_connection.cpp	2005-12-13 11:48:24 +01:00
+++ 1.21/ndb/src/ndbapi/ndb_cluster_connection.cpp	2006-05-15 16:23:54 +02:00
@@ -236,6 +236,12 @@
   } while (1);
 }
 
+unsigned Ndb_cluster_connection::get_connect_count() const
+{
+  return m_impl.get_connect_count();
+}
+
+
 
 
 /*
--- New file ---
+++ mysql-test/r/ndb_autodiscover3.result	06/05/15 16:23:54
drop table if exists t1;
create table t1 (a int key) engine=ndbcluster;
begin;
insert into t1 values (1);
insert into t1 values (2);
ERROR HY000: Got temporary error 4025 'Node failure caused abort of transaction' from ndbcluster
commit;
ERROR HY000: Got error 4350 'Transaction already aborted' from ndbcluster
drop table t1;

--- New file ---
+++ mysql-test/t/ndb_autodiscover3.test	06/05/15 16:23:55
-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/not_embedded.inc


--disable_warnings
drop table if exists t1, t2;
--enable_warnings

#
# Transaction ongoing while cluster is restarted
#
--connection server1
create table t1 (a int key) engine=ndbcluster;

begin;
insert into t1 values (1);

--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT

--error 1297
insert into t1 values (2);
--error 1296
commit;

drop table t1;

#
# Stale cache after restart -i
#
--connection server1
create table t2 (a int, b int, primary key(a,b)) engine=ndbcluster;
insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,1);
select * from t2 order by a limit 3;

--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT

--connection server2
create table t2 (a int key) engine=ndbcluster;
insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from t2 order by a limit 3;

# server 1 should have a stale cache, and in this case wrong frm, transaction must be retried
--connection server1
--error 1015
select * from t2 order by a limit 3;
select * from t2 order by a limit 3;

--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT

--connection server1
show tables;
create table t2 (a int key) engine=ndbcluster;
insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
select * from t2 order by a limit 3;

# server 2 should have a stale cache, but with right frm, transaction need not be retried
--connection server2
select * from t2 order by a limit 3;

drop table t2;
# End of 4.1 tests


--- 1.1/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2004-12-20 12:36:05 +01:00
+++ 1.2/ndb/src/ndbapi/ndb_cluster_connection_impl.hpp	2006-05-15 16:23:54 +02:00
@@ -49,6 +49,7 @@
   void init_get_next_node(Ndb_cluster_connection_node_iter &iter);
   Uint32 get_next_node(Ndb_cluster_connection_node_iter &iter);
 
+  inline unsigned get_connect_count() const;
 private:
   friend class Ndb;
   friend class NdbImpl;
Thread
bk commit into 4.1 tree (tomas:1.2473) BUG#16875tomas15 May