From 1091203586669e5e855afd804d5c95c73e885b77 Mon Sep 17 00:00:00 2001
From: unknown <mronstrom@mysql.com>
Date: Mon, 23 Aug 2004 17:34:46 +0200
Subject: [PATCH] 1) Default config is 1 frag per node 2) MAX_FRAG_PER_NODE
 separated from NO_OF_FRAG_PER_NODE and takes into account large fragmentation
 3) SUMA use config parameter instead of hard coded limit

ndb/src/kernel/blocks/backup/BackupInit.cpp:
  Moved addition of system tables and its attributes to Configuration.cpp
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  Medium == default is one fragment per node
ndb/src/kernel/blocks/dbtux/Dbtux.hpp:
  Use MAX_FRAG_PER_NODE, NO_OF_FRAG_PER_NODE is used for
  allocation purposes, still allowed to create a table with
  many fragments
ndb/src/kernel/blocks/suma/SumaInit.cpp:
  Use max no of tables configured instead of maximum configurable
ndb/src/kernel/vm/Configuration.cpp:
  Update configuration to handle also system tables and their attributes
ndb/src/kernel/vm/pc.hpp:
  Maximum fragments per node is 8 in the worst case
---
 ndb/src/kernel/blocks/backup/BackupInit.cpp | 13 +++----------
 ndb/src/kernel/blocks/dbdih/DbdihMain.cpp   |  4 ++--
 ndb/src/kernel/blocks/dbtux/Dbtux.hpp       |  2 +-
 ndb/src/kernel/blocks/suma/SumaInit.cpp     | 10 ++++++++--
 ndb/src/kernel/vm/Configuration.cpp         | 12 ++++++++----
 ndb/src/kernel/vm/pc.hpp                    |  2 +-
 6 files changed, 23 insertions(+), 20 deletions(-)

diff --git a/ndb/src/kernel/blocks/backup/BackupInit.cpp b/ndb/src/kernel/blocks/backup/BackupInit.cpp
index d8cbb36df62..8daad05558b 100644
--- a/ndb/src/kernel/blocks/backup/BackupInit.cpp
+++ b/ndb/src/kernel/blocks/backup/BackupInit.cpp
@@ -45,16 +45,9 @@ Backup::Backup(const Configuration & conf) :
   ndb_mgm_get_int_parameter(p, CFG_DB_PARALLEL_BACKUPS, &noBackups);
   ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES, &noTables));
   ndbrequire(!ndb_mgm_get_int_parameter(p, CFG_DB_NO_ATTRIBUTES, &noAttribs));
-  
-  // To allow for user tables AND SYSTAB 
-  // See ClusterConfig
-  //TODO get this infor from NdbCntr
-  noTables += 2;
-
-  // Considering also TR527, this is a KISS work-around to be able to
-  // continue testing the real thing
-  noAttribs += 2 + 1;
-  
+
+  noAttribs++; //RT 527 bug fix
+
   c_backupPool.setSize(noBackups);
   c_backupFilePool.setSize(3 * noBackups);
   c_tablePool.setSize(noBackups * noTables);
diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
index a34f89b2119..dd86b556f79 100644
--- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
+++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
@@ -6119,7 +6119,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal){
       break;
     case DictTabInfo::AllNodesMediumTable:
       jam();
-      noOfFragments = 2 * cnoOfNodeGroups;
+      noOfFragments = csystemnodes;
       break;
     case DictTabInfo::AllNodesLargeTable:
       jam();
@@ -6141,7 +6141,7 @@ void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal){
     }
     if(err)
       break;
-    
+   
     NodeGroupRecordPtr NGPtr;
     TabRecordPtr primTabPtr;
     if (primaryTableId == RNIL) {
diff --git a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
index 1a3c7f64ac3..36ac20611bb 100644
--- a/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
+++ b/ndb/src/kernel/blocks/dbtux/Dbtux.hpp
@@ -108,7 +108,7 @@ public:
 
 private:
   // sizes are in words (Uint32)
-  static const unsigned MaxIndexFragments = 2 * NO_OF_FRAG_PER_NODE;
+  static const unsigned MaxIndexFragments = 2 * MAX_FRAG_PER_NODE;
   static const unsigned MaxIndexAttributes = MAX_ATTRIBUTES_IN_INDEX;
   static const unsigned MaxAttrDataSize = 2048;
 public:
diff --git a/ndb/src/kernel/blocks/suma/SumaInit.cpp b/ndb/src/kernel/blocks/suma/SumaInit.cpp
index a9fd293b1dd..255abd47c94 100644
--- a/ndb/src/kernel/blocks/suma/SumaInit.cpp
+++ b/ndb/src/kernel/blocks/suma/SumaInit.cpp
@@ -94,9 +94,15 @@ SumaParticipant::SumaParticipant(const Configuration & conf) :
   /**
    * @todo: fix pool sizes
    */
+  Uint32 noTables;
+  const ndb_mgm_configuration_iterator * p = conf.getOwnConfigIterator();
+  ndbrequire(p != 0);
 
-  c_tablePool_.setSize(MAX_TABLES);
-  c_tables.setSize(MAX_TABLES);
+  ndb_mgm_get_int_parameter(p, CFG_DB_NO_TABLES,  
+			    &noTables);
+
+  c_tablePool_.setSize(noTables);
+  c_tables.setSize(noTables);
   
   c_subscriptions.setSize(20); //10
   c_subscriberPool.setSize(64);
diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp
index d0948483289..9dad733b87b 100644
--- a/ndb/src/kernel/vm/Configuration.cpp
+++ b/ndb/src/kernel/vm/Configuration.cpp
@@ -508,15 +508,19 @@ Configuration::calcSizeAlt(ConfigValues * ownConfig){
     }
   }
   noOfNodes = nodeNo;
-  
+
+  noOfTables+= 2; // Add System tables
+  noOfAttributes += 5;  // Add System table attributes
+
+  ConfigValues::Iterator it2(*ownConfig, db.m_config);
+  it2.set(CFG_DB_NO_TABLES, noOfTables);
+  it2.set(CFG_DB_NO_ATTRIBUTES, noOfAttributes);
+
   /**
    * Do size calculations
    */
   ConfigValuesFactory cfg(ownConfig);
 
-  noOfTables+= 2; // Add System tables
-  noOfAttributes += 5;  // Add System table attributes
-
   if (noOfLocalScanRecords == 0) {
     noOfLocalScanRecords = (noOfDBNodes * noOfScanRecords) + 1;
   }
diff --git a/ndb/src/kernel/vm/pc.hpp b/ndb/src/kernel/vm/pc.hpp
index c90b5bdd5fa..5ac95d661a4 100644
--- a/ndb/src/kernel/vm/pc.hpp
+++ b/ndb/src/kernel/vm/pc.hpp
@@ -148,7 +148,7 @@
 // need large value.
 /* ------------------------------------------------------------------------- */
 #define NO_OF_FRAG_PER_NODE 1
-#define MAX_FRAG_PER_NODE (NO_OF_FRAG_PER_NODE * MAX_REPLICAS)
+#define MAX_FRAG_PER_NODE 8
 
 /* ---------------------------------------------------------------- */
 // To avoid synching too big chunks at a time we synch after writing
-- 
2.30.9