Skip to content

Commit f99f4f3

Browse files
committed
Bug#35990372 Wrong index used in ConfigValues::openSection()
Context: Some NDBAPI tests uses ConfigValues::openSection() function in order to get/set config parameters. openSection has as argument the section 'type' (SYSTEM, NODE, CONNECTION ...) and the index to the section we are interested in. Section indexes are sequential, starting from zero and are ordered by nodeId BUT nodeId and index can be different. Problem: In some testes openSection is used with wrong arguments (nodeId is used instead index). Depending on the configuration this can lead openSection to open wrong/invalid section. Solution: Tests changed to always use index instead nodeId to openSection. In particular, when iterating over all sections looking to a parameter, iteration now starts from index 0, preventing any section from being ignored. Change-Id: I10468675b1ef07cf01a89961f5d5a84a498b4568
1 parent 67c8701 commit f99f4f3

File tree

4 files changed

+27
-50
lines changed

4 files changed

+27
-50
lines changed

storage/ndb/test/include/NdbMgmd.hpp

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -482,24 +482,19 @@ class NdbMgmd {
482482

483483
Uint64 default_value = 0;
484484
ConfigValues::Iterator iter(conf.m_configValues->m_config);
485-
for (int nodeid = 1; nodeid < MAX_NODES; nodeid++)
485+
for(int idx=0; iter.openSection(type_of_section, idx); idx++)
486486
{
487-
if (!iter.openSection(type_of_section, nodeid))
488-
continue;
489487
Uint64 old_value = 0;
490488
if (iter.get(config_variable, &old_value))
491489
{
492490
if (default_value == 0)
493491
{
494492
default_value = old_value;
495-
}
496-
else if (old_value != default_value)
497-
{
498-
g_err << "StartDiskPageBufferMemory is not consistent across nodes"
499-
<< ". Node id " << nodeid
500-
<< ": value " << old_value
501-
<< ". Overwriting it with the given value " << new_value
493+
} else if (old_value != default_value) {
494+
g_err << "Config value is not consistent across sections."
502495
<< endl;
496+
iter.closeSection();
497+
return false;
503498
}
504499
}
505500
iter.set(config_variable, new_value);
@@ -544,24 +539,19 @@ class NdbMgmd {
544539

545540
Uint32 default_value = 0;
546541
ConfigValues::Iterator iter(conf.m_configValues->m_config);
547-
for (int nodeid = 1; nodeid < MAX_NODES; nodeid++)
542+
for(int idx=0; iter.openSection(type_of_section, idx); idx++)
548543
{
549-
if (!iter.openSection(type_of_section, nodeid))
550-
continue;
551544
Uint32 old_value = 0;
552545
if (iter.get(config_variable, &old_value))
553546
{
554547
if (default_value == 0)
555548
{
556549
default_value = old_value;
557-
}
558-
else if (old_value != default_value)
559-
{
560-
g_err << "Config value is not consistent across nodes"
561-
<< ". Node id " << nodeid
562-
<< ": value " << old_value
563-
<< ". Overwriting it with the given value " << new_value
550+
} else if (old_value != default_value) {
551+
g_err << "Config value is not consistent across sections."
564552
<< endl;
553+
iter.closeSection();
554+
return false;
565555
}
566556
}
567557
iter.set(config_variable, new_value);
@@ -605,15 +595,12 @@ class NdbMgmd {
605595
}
606596

607597
ConfigValues::Iterator iter(conf.m_configValues->m_config);
608-
for (int nodeid = 1; nodeid < MAX_NODES; nodeid++)
598+
for(int idx=0; iter.openSection(type_of_section, idx); idx++)
609599
{
610-
if (!iter.openSection(type_of_section, nodeid))
611-
continue;
612600
Uint32 current_value = 0;
613-
if (iter.get(config_variable, &current_value))
614-
{
615-
if (current_value > 0)
616-
{
601+
if (iter.get(config_variable, &current_value)) {
602+
if (current_value > 0) {
603+
iter.closeSection();
617604
return current_value;
618605
}
619606
}

storage/ndb/test/ndbapi/testMgm.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2003, 2021, Oracle and/or its affiliates.
2+
Copyright (c) 2003, 2023, Oracle and/or its affiliates.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -3664,12 +3664,9 @@ int runTestNdbApiConfig(NDBT_Context* ctx, NDBT_Step* step)
36643664
return NDBT_FAILED;
36653665

36663666
ConfigValues::Iterator iter(conf.m_configValues->m_config);
3667-
for (Uint32 nodeid = 1; nodeid < MAX_NODES; nodeid ++)
3667+
for(int idx=0; iter.openSection(CFG_SECTION_NODE, idx); idx++)
36683668
{
36693669
Uint32 type;
3670-
if (!iter.openSection(CFG_SECTION_NODE, nodeid))
3671-
continue;
3672-
36733670
if (iter.get(CFG_TYPE_OF_SECTION, &type) &&
36743671
type == NDB_MGM_NODE_TYPE_API)
36753672
{
@@ -3678,7 +3675,6 @@ int runTestNdbApiConfig(NDBT_Context* ctx, NDBT_Step* step)
36783675
iter.set(parameters[param].key, parameters[param].values[i]);
36793676
}
36803677
}
3681-
36823678
iter.closeSection();
36833679
}
36843680

storage/ndb/test/ndbapi/testNodeRestart.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ changeStartPartitionedTimeout(NDBT_Context *ctx, NDBT_Step *step)
6565
g_err << "Setting StartPartitionedTimeout to " << startPartitionedTimeout
6666
<< endl;
6767
ConfigValues::Iterator iter(conf.m_configValues->m_config);
68-
for (int nodeid = 1; nodeid < MAX_NODES; nodeid++)
68+
for(int idx=0; iter.openSection(CFG_SECTION_NODE, idx); idx++)
6969
{
70-
if (!iter.openSection(CFG_SECTION_NODE, nodeid))
71-
continue;
7270
Uint32 oldValue = 0;
7371
if (iter.get(CFG_DB_START_PARTITION_TIMEOUT, oldValue))
7472
{
@@ -78,7 +76,8 @@ changeStartPartitionedTimeout(NDBT_Context *ctx, NDBT_Step *step)
7876
}
7977
else if (oldValue != defaultValue)
8078
{
81-
g_err << "StartPartitionedTimeout is not consistent across nodes" << endl;
79+
g_err << "StartPartitionedTimeout is not consistent across data node"
80+
"sections" << endl;
8281
break;
8382
}
8483
}
@@ -8911,12 +8910,8 @@ int run_PLCP_many_parts(NDBT_Context *ctx, NDBT_Step *step)
89118910
}
89128911
ConfigValues::Iterator iter(conf.m_configValues->m_config);
89138912
Uint32 enabledPartialLCP = 1;
8914-
for (int idx = 0; idx < MAX_NODES; idx ++)
8913+
for(int idx=0; iter.openSection(CFG_SECTION_NODE, idx); idx++)
89158914
{
8916-
if (!iter.openSection(CFG_SECTION_NODE, idx))
8917-
{
8918-
break;
8919-
}
89208915
Uint32 nodeId=0;
89218916
if(iter.get(CFG_NODE_ID, &nodeId))
89228917
{

storage/ndb/test/ndbapi/testRedo.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2012, 2021, Oracle and/or its affiliates.
2+
Copyright (c) 2012, 2023, Oracle and/or its affiliates.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -1317,15 +1317,13 @@ resizeRedoLog(NDBT_Context* ctx, NDBT_Step* step)
13171317
}
13181318

13191319
g_err << "Setting NoOfFragmentLogFiles = " << noOfLogFiles
1320-
<< " FragmentLogFileSize = " << logFileSize
1321-
<< " TimeBetweenLCP " << LCPinterval << endl;
1320+
<< " FragmentLogFileSize = " << logFileSize << " TimeBetweenLCP "
1321+
<< LCPinterval << endl;
13221322
ConfigValues::Iterator iter(conf.m_configValues->m_config);
1323-
for (int nodeid = 1; nodeid < MAX_NODES; nodeid ++)
1323+
for(int idx=0; iter.openSection(CFG_SECTION_NODE, idx); idx++)
13241324
{
13251325
Uint32 oldValue;
1326-
if (!iter.openSection(CFG_SECTION_NODE, nodeid))
1327-
continue;
1328-
if (iter.get(CFG_DB_NO_REDOLOG_FILES, &oldValue))
1326+
if (iter.get(CFG_DB_NO_REDOLOG_FILES, &oldValue))
13291327
{
13301328
iter.set(CFG_DB_NO_REDOLOG_FILES, noOfLogFiles);
13311329
if(defaultNoOfLogFiles == 0)
@@ -1334,7 +1332,8 @@ resizeRedoLog(NDBT_Context* ctx, NDBT_Step* step)
13341332
}
13351333
else if(oldValue != defaultNoOfLogFiles)
13361334
{
1337-
g_err << "NoOfFragmentLogFiles is not consistent across nodes" << endl;
1335+
g_err << "NoOfFragmentLogFiles is not consistent across nodes"
1336+
<< endl;
13381337
break;
13391338
}
13401339
}

0 commit comments

Comments
 (0)