Below is the list of changes that have just been committed into a local
5.1 repository of mikron. When mikron 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.1872 05/07/15 16:28:14 mronstrom@stripped +4 -0
Adapted handling of index fragmentation to fit with NDB partitioning
and changed somewhat implementation of default manner although still
using the same basic algorithm.
storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp
1.34 05/07/15 16:28:03 mronstrom@stripped +92 -104
Adapted DIH to new scheme
storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp
1.47 05/07/15 16:28:02 mronstrom@stripped +17 -10
Adapted DICT to new scheme
storage/ndb/include/kernel/signaldata/DictTabInfo.hpp
1.20 05/07/15 16:28:02 mronstrom@stripped +3 -1
Added identifers for Ordered Index and Unique Hash Indexes
sql/ha_ndbcluster.cc
1.199 05/07/15 16:28:02 mronstrom@stripped +6 -1
Modified handler to always send an array of node groups
starting with node group 0 and then letting the kernel
assign from there
# 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: mronstrom
# Host: mikael-ronstr-ms-dator.local
# Root: /Users/mikron/wl1354
--- 1.19/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp 2005-07-13 22:33:42 +02:00
+++ 1.20/storage/ndb/include/kernel/signaldata/DictTabInfo.hpp 2005-07-15 16:28:02 +02:00
@@ -154,7 +154,9 @@
SingleFragment = 3,
DistrKeyHash = 4,
DistrKeyLin = 5,
- UserDefined = 6
+ UserDefined = 6,
+ DistrKeyUniqueHashIndex = 7,
+ DistrKeyOrderedIndex = 8
};
// TableType constants + objects
--- 1.46/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2005-07-13 22:33:44 +02:00
+++ 1.47/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp 2005-07-15 16:28:02 +02:00
@@ -2926,19 +2926,27 @@
CreateFragmentationReq * const req = (CreateFragmentationReq*)theData;
req->senderRef = reference();
req->senderData = createTabPtr.p->key;
- req->fragmentationType = parseRecord.tablePtr.p->fragmentType;
req->primaryTableId = RNIL;
req->noOfFragments = parseRecord.tablePtr.p->ngLen >> 1;
+ req->fragmentationType = parseRecord.tablePtr.p->fragmentType;
for (i = 0; i < req->noOfFragments; i++)
node_group[i] = parseRecord.tablePtr.p->ngData[i];
if (parseRecord.tablePtr.p->isOrderedIndex()) {
+ jam();
// ordered index has same fragmentation as the table
- const Uint32 primaryTableId = parseRecord.tablePtr.p->primaryTableId;
- TableRecordPtr primaryTablePtr;
- c_tableRecordPool.getPtr(primaryTablePtr, primaryTableId);
- // fragmentationType must be consistent
- req->fragmentationType = primaryTablePtr.p->fragmentType;
- req->primaryTableId = primaryTableId;
+ req->primaryTableId = parseRecord.tablePtr.p->primaryTableId;
+ req->fragmentationType = DictTabInfo::DistrKeyOrderedIndex;
+ }
+ else if (parseRecord.tablePtr.p->isHashIndex())
+ {
+ jam();
+ /*
+ Unique hash indexes has same amount of fragments as primary table
+ and distributed in the same manner but has always a normal hash
+ fragmentation.
+ */
+ req->primaryTableId = parseRecord.tablePtr.p->primaryTableId;
+ req->fragmentationType = DictTabInfo::DistrKeyUniqueHashIndex;
}
EXECUTE_DIRECT(DBDIH, GSN_CREATE_FRAGMENTATION_REQ, signal,
CreateFragmentationReq::SignalLength);
@@ -6525,7 +6533,7 @@
initialiseTableRecord(indexPtr);
if (req->getIndexType() == DictTabInfo::UniqueHashIndex) {
indexPtr.p->storedTable = opPtr.p->m_storedIndex;
- indexPtr.p->fragmentType = tablePtr.p->fragmentType;
+ indexPtr.p->fragmentType = DictTabInfo::DistrKeyUniqueHashIndex;
} else if (req->getIndexType() == DictTabInfo::OrderedIndex) {
// first version will not supported logging
if (opPtr.p->m_storedIndex) {
@@ -6535,8 +6543,7 @@
return;
}
indexPtr.p->storedTable = false;
- // follows table fragmentation
- indexPtr.p->fragmentType = tablePtr.p->fragmentType;
+ indexPtr.p->fragmentType = DictTabInfo::DistrKeyOrderedIndex;
} else {
jam();
opPtr.p->m_errorCode = CreateIndxRef::InvalidIndexType;
--- 1.33/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2005-07-14 19:03:41 +02:00
+++ 1.34/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp 2005-07-15 16:28:03 +02:00
@@ -6153,7 +6153,25 @@
3.7.1 A D D T A B L E M A I N L Y
***************************************
*/
+
#define UNDEF_NODEGROUP 65535
+static inline void inc_node_or_group(Uint32 &node, Uint32 max_node)
+{
+ Uint32 next = node + 1;
+ node = (next == max_node ? 0 : next);
+}
+
+/*
+ Spread fragments in backwards compatible mode
+*/
+static void set_default_node_groups(Signal *signal, Uint32 noFrags)
+{
+ Uint16 *node_group_array = (Uint16*)&signal->theData[25];
+ Uint32 i;
+ node_group_array[0] = 0;
+ for (i = 1; i < noFrags; i++)
+ node_group_array[i] = UNDEF_NODEGROUP;
+}
void Dbdih::execCREATE_FRAGMENTATION_REQ(Signal * signal)
{
Uint16 node_group_id[MAX_NDB_PARTITIONS];
@@ -6163,145 +6181,113 @@
const Uint32 senderRef = req->senderRef;
const Uint32 senderData = req->senderData;
- const Uint32 fragmentType = req->fragmentationType;
- const Uint32 fragmentCount = req->noOfFragments;
+ Uint32 noOfFragments = req->noOfFragments;
+ const Uint32 fragType = req->fragmentationType;
const Uint32 primaryTableId = req->primaryTableId;
Uint32 err = 0;
do {
- Uint16 noOfFragments = 0;
- if (fragmentCount == 0)
- {
- jam();
- switch(fragmentType){
- case DictTabInfo::AllNodesSmallTable:
- jam();
- noOfFragments = (Uint16)csystemnodes;
- break;
- case DictTabInfo::AllNodesMediumTable:
- jam();
- noOfFragments = (Uint16)(2 * csystemnodes);
- break;
- case DictTabInfo::AllNodesLargeTable:
- jam();
- noOfFragments = (Uint16)(4 * csystemnodes);
- break;
- case DictTabInfo::SingleFragment:
- jam();
- noOfFragments = (Uint16)1;
- break;
- case DictTabInfo::DistrKeyHash:
- case DictTabInfo::DistrKeyLin:
- case DictTabInfo::UserDefined:
- jam();
- noOfFragments= 0; //Will be set properly below
-#if 0
- case DictTabInfo::SpecifiedFragmentCount:
- noOfFragments = (fragmentCount == 0 ? 1 : (fragmentCount + 1)/ 2);
- break;
-#endif
- default:
- jam();
- err = CreateFragmentationRef::InvalidFragmentationType;
- break;
- }
- if(err)
- break;
- }
NodeGroupRecordPtr NGPtr;
TabRecordPtr primTabPtr;
- if (primaryTableId == RNIL) {
- if (noOfFragments == 1)
- {
- /*
- With single fragment tables we spread those evenly among the
- node groups with a simple round robin structure.
- */
- jam();
- NGPtr.i = c_nextNodeGroup;
- c_nextNodeGroup = (NGPtr.i + 1 == cnoOfNodeGroups ? 0 : NGPtr.i + 1);
- } else if (noOfFragments > 0) {
- /*
- All other fragmentation types spread the fragments over all the
- node groups and we always start with the first.
- */
- jam();
- NGPtr.i = 0;
- } else {
- jam();
- /*
- When we come here the user has specified the exact partition
- and there is an array of node groups sent along as well.
- */
- memcpy(&node_group_id[0], &signal->theData[25], 2 * fragmentCount);
- noOfFragments = (Uint16)fragmentCount;
- }
- } else {
- ndbrequire(fragmentCount == 0);
- if (primaryTableId >= ctabFileSize) {
- jam();
- err = CreateFragmentationRef::InvalidPrimaryTable;
- break;
- }
- primTabPtr.i = primaryTableId;
- ptrAss(primTabPtr, tabRecord);
- if (primTabPtr.p->tabStatus != TabRecord::TS_ACTIVE) {
- jam();
- err = CreateFragmentationRef::InvalidPrimaryTable;
- break;
- }
- }
Uint32 count = 2;
Uint16 noOfReplicas = cnoReplicas;
Uint16 *fragments = (Uint16*)(signal->theData+25);
if (primaryTableId == RNIL) {
jam();
+ switch ((DictTabInfo::FragmentType)fragType)
+ {
+ /*
+ Backward compatability and for all places in code not changed.
+ */
+ case DictTabInfo::AllNodesSmallTable:
+ jam();
+ noOfFragments = csystemnodes;
+ set_default_node_groups(signal, noOfFragments);
+ break;
+ case DictTabInfo::AllNodesMediumTable:
+ jam();
+ noOfFragments = 2 * csystemnodes;
+ set_default_node_groups(signal, noOfFragments);
+ break;
+ case DictTabInfo::AllNodesLargeTable:
+ jam();
+ noOfFragments = 4 * csystemnodes;
+ set_default_node_groups(signal, noOfFragments);
+ break;
+ case DictTabInfo::SingleFragment:
+ jam();
+ noOfFragments = 1;
+ set_default_node_groups(signal, noOfFragments);
+ break;
+ default:
+ break;
+ }
+ /*
+ When we come here the the exact partition is specified
+ and there is an array of node groups sent along as well.
+ */
+ memcpy(&node_group_id[0], &signal->theData[25], 2 * noOfFragments);
Uint16 next_replica_node[MAX_NDB_NODES];
memset(next_replica_node,0,sizeof(next_replica_node));
- for(Uint32 fragNo = 0; fragNo<noOfFragments; fragNo++)
+ Uint32 default_node_group= c_nextNodeGroup;
+ for(Uint32 fragNo = 0; fragNo < noOfFragments; fragNo++)
{
jam();
- if (fragmentCount > 0)
+ NGPtr.i = node_group_id[fragNo];
+ if (NGPtr.i == UNDEF_NODEGROUP)
{
jam();
- NGPtr.i = node_group_id[fragNo];
- if (NGPtr.i == UNDEF_NODEGROUP)
- {
- NGPtr.i = c_nextNodeGroup;
- c_nextNodeGroup =
- (NGPtr.i + 1 == cnoOfNodeGroups ? 0 : NGPtr.i + 1);
- }
- if (NGPtr.i > cnoOfNodeGroups)
- {
- jam();
- err = CreateFragmentationRef::InvalidNodeGroup;
- break;
- }
+ NGPtr.i = default_node_group;
+ }
+ if (NGPtr.i > cnoOfNodeGroups)
+ {
+ jam();
+ err = CreateFragmentationRef::InvalidNodeGroup;
+ break;
}
ptrCheckGuard(NGPtr, MAX_NDB_NODES, nodeGroupRecord);
const Uint32 max = NGPtr.p->nodeCount;
Uint32 tmp= next_replica_node[NGPtr.i];
- for(Uint32 replicaNo = 0; replicaNo<noOfReplicas; replicaNo++)
+ for(Uint32 replicaNo = 0; replicaNo < noOfReplicas; replicaNo++)
{
jam();
- const Uint16 nodeId = NGPtr.p->nodesInGroup[tmp++];
+ const Uint16 nodeId = NGPtr.p->nodesInGroup[tmp];
fragments[count++]= nodeId;
- tmp = (tmp >= max ? 0 : tmp);
+ inc_node_or_group(tmp, max);
}
- tmp++;
- next_replica_node[NGPtr.i]= (tmp >= max ? 0 : tmp);
+ inc_node_or_group(tmp, max);
+ next_replica_node[NGPtr.i]= tmp;
/**
* Next node group for next fragment
*/
- NGPtr.i++;
- NGPtr.i = (NGPtr.i == cnoOfNodeGroups ? 0 : NGPtr.i);
+ inc_node_or_group(default_node_group, cnoOfNodeGroups);
}
if (err)
+ {
+ jam();
break;
+ }
+ else
+ {
+ jam();
+ c_nextNodeGroup = default_node_group;
+ }
} else {
+ if (primaryTableId >= ctabFileSize) {
+ jam();
+ err = CreateFragmentationRef::InvalidPrimaryTable;
+ break;
+ }
+ primTabPtr.i = primaryTableId;
+ ptrAss(primTabPtr, tabRecord);
+ if (primTabPtr.p->tabStatus != TabRecord::TS_ACTIVE) {
+ jam();
+ err = CreateFragmentationRef::InvalidPrimaryTable;
+ break;
+ }
noOfFragments= primTabPtr.p->totalfragments;
for (Uint32 fragNo = 0;
fragNo < noOfFragments; fragNo++) {
@@ -6444,6 +6430,8 @@
tabPtr.p->method= TabRecord::LINEAR_HASH;
break;
case DictTabInfo::DistrKeyHash:
+ case DictTabInfo::DistrKeyUniqueHashIndex:
+ case DictTabInfo::DistrKeyOrderedIndex:
jam();
tabPtr.p->method= TabRecord::NORMAL_HASH;
break;
--- 1.198/sql/ha_ndbcluster.cc 2005-07-14 16:02:47 +02:00
+++ 1.199/sql/ha_ndbcluster.cc 2005-07-15 16:28:02 +02:00
@@ -7457,7 +7457,12 @@
}
}
}
- for (i= 0; i < no_fragments; i++)
+ /*
+ Always start with node group 0 and continue with next node group from
+ there
+ */
+ node_group[0]= 0;
+ for (i= 1; i < no_fragments; i++)
node_group[i]= UNDEF_NODEGROUP;
if (opt_ndb_linear_hash)
ftype= NDBTAB::DistrKeyLin;
| Thread |
|---|
| • bk commit into 5.1 tree (mronstrom:1.1872) | mikael | 15 Jul |