Skip to content

Commit

Permalink
Merge pull request #18320 from jakesmith/HPCC-31312-daliadmin-cluster…
Browse files Browse the repository at this point in the history
…nodes-readlock

HPCC-31312 Use read lock for daliadmin clusternodes

Reviewed-by: Gavin Halliday <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Feb 21, 2024
2 parents 3bfc741 + 4c1d850 commit 3d5dfee
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9878,6 +9878,7 @@ class CInitGroups
StringArray clusternames;
unsigned defaultTimeout;
bool machinesLoaded;
bool writeLock;

GroupType getGroupType(const char *type)
{
Expand Down Expand Up @@ -9953,6 +9954,8 @@ class CInitGroups

void addClusterGroup(const char *name, IPropertyTree *newClusterGroup, bool realCluster)
{
if (!writeLock)
throw makeStringException(0, "CInitGroups::addClusterGroup called in read-only mode");
VStringBuffer prop("Group[@name=\"%s\"]", name);
IPropertyTree *root = groupsconnlock.conn->queryRoot();
IPropertyTree *old = root->queryPropTree(prop.str());
Expand Down Expand Up @@ -10274,11 +10277,12 @@ class CInitGroups
return root->queryPropTree(xpath.str());
}
public:
CInitGroups(unsigned _defaultTimeout)
: groupsconnlock("constructGroup",SDS_GROUPSTORE_ROOT,true,false,false,_defaultTimeout)
CInitGroups(unsigned _defaultTimeout, bool _writeLock)
: groupsconnlock("constructGroup",SDS_GROUPSTORE_ROOT,_writeLock,false,false,_defaultTimeout)
{
defaultTimeout = _defaultTimeout;
machinesLoaded = false;
writeLock = _writeLock;
}

IPropertyTree *queryCluster(const IPropertyTree *env, const char *_clusterName, const char *type, const char *msg, StringBuffer &messages)
Expand Down Expand Up @@ -10591,13 +10595,13 @@ class CInitGroups

void initClusterGroups(bool force, StringBuffer &response, IPropertyTree *oldEnvironment, unsigned timems)
{
CInitGroups init(timems);
CInitGroups init(timems, true);
init.constructGroups(force, response, oldEnvironment);
}

void initClusterAndStoragePlaneGroups(bool force, IPropertyTree *oldEnvironment, unsigned timems)
{
CInitGroups init(timems);
CInitGroups init(timems, true);

StringBuffer response;
init.constructGroups(force, response, oldEnvironment);
Expand All @@ -10612,19 +10616,19 @@ void initClusterAndStoragePlaneGroups(bool force, IPropertyTree *oldEnvironment,

bool resetClusterGroup(const char *clusterName, const char *type, bool spares, StringBuffer &response, unsigned timems)
{
CInitGroups init(timems);
CInitGroups init(timems, true);
return init.resetClusterGroup(clusterName, type, spares, response);
}

bool addClusterSpares(const char *clusterName, const char *type, const std::vector<std::string> &hosts, StringBuffer &response, unsigned timems)
{
CInitGroups init(timems);
CInitGroups init(timems, true);
return init.addSpares(clusterName, type, hosts, response);
}

bool removeClusterSpares(const char *clusterName, const char *type, const std::vector<std::string> &hosts, StringBuffer &response, unsigned timems)
{
CInitGroups init(timems);
CInitGroups init(timems, true);
return init.removeSpares(clusterName, type, hosts, response);
}

Expand All @@ -10648,7 +10652,7 @@ static IGroup *getClusterNodeGroup(const char *clusterName, const char *type, bo
* to DFS and elsewhere.
*/
Owned<IGroup> nodeGroup = queryNamedGroupStore().lookup(nodeGroupName);
CInitGroups init(timems);
CInitGroups init(timems, false);
Owned<IGroup> expandedClusterGroup = init.getGroupFromCluster(type, cluster, true);
if (!expandedClusterGroup)
throwStringExceptionV(0, "Failed to get group for '%s' cluster '%s'", type, clusterName);
Expand Down

0 comments on commit 3d5dfee

Please sign in to comment.