Bug 865698 - Usage of implicitResources in ClusterManagerBean#buildQuery causes performance issue
Summary: Usage of implicitResources in ClusterManagerBean#buildQuery causes performanc...
Keywords:
Status: NEW
Alias: None
Product: RHQ Project
Classification: Other
Component: Core Server
Version: 3.0.0,4.5
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-12 07:42 UTC by Andreas Veithen
Modified: 2022-03-31 04:27 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1240854 0 unspecified CLOSED Group inventory pages (compatible, mixed, all) fail to display groups due to UI timeouts 2021-02-22 00:41:40 UTC

Internal Links: 1240854

Description Andreas Veithen 2012-10-12 07:42:20 UTC
[This is a summary of https://lists.fedorahosted.org/pipermail/rhq-devel/2012-October/002220.html]

ClusterManagerBean#buildQuery (which is used by ClusterManagerBean#getAutoClusterResources) contains the following code:

        // this is an authorization-related query, so use implicitResource (not explicitResources)
        if (1 == size) {
            query
                .append("SELECT rgir FROM ResourceGroup rg JOIN rg.implicitResources rgir WHERE rgir.inventoryStatus = 'COMMITTED' AND rg = "
                + clusterKey.getClusterGroupId());
        } else {
            buildQuery(query, params, clusterKey, nodes.subList(0, size - 1));
        }

We have a situation where the query constructed by this method causes a performance issue. This occurs for depth 3 resources related to the JVM (e.g. as JVM > Memory Subsystem > MarkSweepCompact) in a compatible group. When trying to open the summary for such a resource, the request times out because the database takes too much time to complete the query. Note that other resources at depth 3 are not affected by this problem. My guess is that this is related to the fact that the keys of the resources in the hierarchy ('JVM', 'java.lang:type=Memory' and 'java.lang:name=MarkSweepCompact,type=GarbageCollector' in the example) for these resources are "less unique" than for other resources (we have 39 JVMs in the inventory).

ClusterManagerBean#getAutoClusterResources gets a cluster key as input and is expected to return the corresponding resources. In my case, the cluster key refers to a group of WebSphere servers and its hierarchy is ("JVM", "java.lang:type=Memory", "java.lang:name=MarkSweepCompact,type=GarbageCollector"). The query searches for resources satisfying all of the following conditions:

* The key of the resource is 'java.lang:name=MarkSweepCompact,type=GarbageCollector'.
* The resource key of the parent is 'java.lang:type=Memory '.
* The resource key of the grandparent is 'JVM'.
* The grandgrandparent is an implicit member of the group of WebSphere servers.

That makes sense, except for the usage of the implicit membership in the last condition. In fact, the grandgrandparent can only be a root level member (a WebSphere server in my case), i.e. it is always part of the explicit membership. Therefore the query should use explicitResources instead of implicitResources.

Note that the comment in the code shown above doesn't make sense because authorization is not involved here.

I replaced implicitResources by explicitResources and patched an RHQ 4.5.1 installation with that change. I didn't identify any regressions and the change significantly reduces the time taken by getAutoClusterResources.


Note You need to log in before you can comment on or make changes to this bug.