Bug 1187680 - Error recalculating DynaGroups due to ResourceGroupAlreadyExistsException continues to be reported every 11 minutes
Summary: Error recalculating DynaGroups due to ResourceGroupAlreadyExistsException con...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: JBoss Operations Network
Classification: JBoss
Component: Resource Grouping
Version: JON 3.3.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ER01
: JON 3.3.5
Assignee: Jay Shaughnessy
QA Contact: Sunil Kondkar
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-01-30 16:34 UTC by Larry O'Leary
Modified: 2020-09-10 09:21 UTC (History)
7 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2016-02-03 15:02:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Screenshot-UI-Message (2.97 KB, image/png)
2015-12-17 15:44 UTC, Sunil Kondkar
no flags Details
Server Log (1.13 MB, text/plain)
2015-12-17 15:46 UTC, Sunil Kondkar
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3129191 0 None None None 2017-07-27 10:00:19 UTC
Red Hat Product Errata RHSA-2016:0118 0 normal SHIPPED_LIVE Critical: Red Hat JBoss Operations Network 3.3.5 update 2016-02-03 20:00:55 UTC

Description Larry O'Leary 2015-01-30 16:34:45 UTC
Description of problem:
Every 11 minutes, the following ERROR is reported in server.log:

ERROR [org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean] (RHQScheduler_Worker-1) Error recalculating DynaGroups for GroupDefinition[id=10001]: org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException: ResourceGroup with name DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) ) already exists
	at org.rhq.enterprise.server.resource.group.ResourceGroupManagerBean.createResourceGroup(ResourceGroupManagerBean.java:155) [rhq-server.jar:4.12.0.JON330GA]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_72]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_72]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_72]
    ...
	at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) [jboss-as-ee-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
	at org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal$$$view78.createResourceGroup(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean.calculateGroupMembership_helper(GroupDefinitionManagerBean.java:392) [rhq-server.jar:4.12.0.JON330GA]
	at sun.reflect.GeneratedMethodAccessor180.invoke(Unknown Source) [:1.7.0_72]
    ...
	at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) [jboss-as-ee-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal$$$view166.calculateGroupMembership_helper(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean.calculateGroupMembership(GroupDefinitionManagerBean.java:338) [rhq-server.jar:4.12.0.JON330GA]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_72]
    ...
	at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) [jboss-as-ee-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal$$$view166.calculateGroupMembership(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean.recalculateDynaGroups(GroupDefinitionManagerBean.java:117) [rhq-server.jar:4.12.0.JON330GA]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_72]
    ...
	at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:73) [jboss-as-ee-7.4.0.Final-redhat-19.jar:7.4.0.Final-redhat-19]
	at org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerLocal$$$view166.recalculateDynaGroups(Unknown Source) [rhq-server.jar:4.12.0.JON330GA]
	at org.rhq.enterprise.server.scheduler.jobs.DynaGroupAutoRecalculationJob.executeJobCode(DynaGroupAutoRecalculationJob.java:42) [rhq-server.jar:4.12.0.JON330GA]
	at org.rhq.enterprise.server.scheduler.jobs.AbstractStatefulJob.execute(AbstractStatefulJob.java:48) [rhq-server.jar:4.12.0.JON330GA]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-1.6.5.jar:1.6.5]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) [quartz-1.6.5.jar:1.6.5]


Version-Release number of selected component (if applicable):
3.3.0.GA

How reproducible:
Error is reported every 11 minutes in the log.

Steps to Reproduce:
Unknown

Actual results:
server.log reports error every 11 minutes:
ERROR [org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean] (RHQScheduler_Worker-1) Error recalculating DynaGroups for GroupDefinition[id=10001]: org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException: ResourceGroup with name DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) ) already exists


Expected results:
No error.

Additional info:
This error was seen in a log file from a JBoss ON system that had been recently upgraded from 3.2 to 3.3. The 3.2 server already included DynaGorup definitions.

Comment 1 Libor Zoubek 2015-03-06 14:36:20 UTC
I don't see any relation in this error being thrown and upgrade - not able to reproduce when ugprading from 3.2 to 3.3.

I also don't see any relation to Predefined DynaGroup Expressions installed by plugin because 1) we don't provide dynaGroup with this name 2) it's handled in code, that it does not overwrite user defined dynagroups with same name if existing.

The error is likely, because there is a resource group called "DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) )" but this group had to be manualy created and this error might have been thrown.

Code which generates groups based on DynaGroup definition queries ResourceGroups by it's definitionId (ie. looks if a group previously generated by this definition exists) and if not found, it attempts to create it. It does not handle situation, when there is a group with a name that it is going to generate. If it did, it would have to overwrite it's members.

I recommend closing this as NOTABUG, customer may safely delete resource group called "DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) )" as it will be populated on next dynagroup recalculation.

Comment 2 Larry O'Leary 2015-03-06 14:53:02 UTC
If you are saying that this error is from someone attempting to create a DynaGroup using a name that already exists, wouldn't the client side or UI error be sufficient?

Perhaps the log message should only appear at DEBUG. 

I think what you describe here is a bug in the sense that I can fill up the server logs with meaningless messages by simply running the same CLI command over and over and over.

Comment 3 Libor Zoubek 2015-03-06 15:31:39 UTC
No, it's comming from an existing dynagroup definition which tries to create resource group, which already exists. It tries to do so, because the existing group is not related to definition being recalculated.

I can fix the code so it also tries to look for an existing group by name and in case match is found, just output warning without stacktrace.

Comment 4 Larry O'Leary 2015-03-09 23:32:48 UTC
Libor, it is not clear how an existing dynagroup could be attempting to create a resource group that already exists. 

> No, it's comming from an existing dynagroup definition which tries to create
> resource group, which already exists. It tries to do so, because the
> existing group is not related to definition being recalculated.

This should be impossible. When an attempt is made to create a static group with the name of an existing group or a dynamic group that will result in using the same name as an existing dynamic group or a dynamic group that could conflict with a static group which used "DyanGroup - " at the begging of its name, an error would be generated to the user either via the UI or remote API. The respective group definition or group would not be created.

Even if I were to manually create a group and made its name "DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) )" then attempted to create a dynamic group definition named "Read Only All Resources ( server.example.com(JBoss Main Server) )", my expectation would be a UI (or CLI/API) error that said a group with that name already exists.

The same goes the other way around -- if an attempt is made to create a static group with the name "DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) )" after a dynamic group definition by the same name already exists, again, I expect a UI or remote API error.

I can not see how an existing dynamic group definition would ever recalculate a group member list and happen to generate a group with the same name as an unrelated resource group considering that for the definition to exist, the name had to be unique in the first place.

We have a bug in either the creation of groups allowing the new groups name to use the same name as an existing group or, what I fear here, is that something with the upgrade process or dynamic group changes made in a 3.2 or 3.3 commit is has cause the group that is associated with this dynamic group definition to become "disconnected."

> I can fix the code so it also tries to look for an existing group by name
> and in case match is found, just output warning without stacktrace.

Again, the error or warning should be presented to the user either via the UI or via the remoate API at the time the static group or dynamic group definition is created. No ERROR or WARNING should be logged in the server log. Instead, when this situation occurs, a DEBUG message/stack would be sufficient.

If this issue is not happening on group creation time then again, we have a bug here and a error message is appropriate and we need to fix the bug so the error/stack does not get displayed at all.

Comment 5 Libor Zoubek 2015-03-16 11:59:35 UTC
(In reply to Larry O'Leary from comment #4)
> Libor, it is not clear how an existing dynagroup could be attempting to
> create a resource group that already exists. 
> 
> > No, it's comming from an existing dynagroup definition which tries to create
> > resource group, which already exists. It tries to do so, because the
> > existing group is not related to definition being recalculated.
> 
> This should be impossible. When an attempt is made to create a static group
> with the name of an existing group or a dynamic group that will result in
> using the same name as an existing dynamic group or a dynamic group that
> could conflict with a static group which used "DyanGroup - " at the begging
> of its name, an error would be generated to the user either via the UI or
> remote API. The respective group definition or group would not be created.
> 
> Even if I were to manually create a group and made its name "DynaGroup -
> Read Only All Resources ( server.example.com(JBoss Main Server) )" then
> attempted to create a dynamic group definition named "Read Only All
> Resources ( server.example.com(JBoss Main Server) )", my expectation would
> be a UI (or CLI/API) error that said a group with that name already exists.
This is how it is possible to reproduce the issue. I've easily reproduced it this way on predefined expression called "Groups by platform"

1. delete group "DynaGroup - Groups by platform ( Linux )" if exists
2. manually create "DynaGroup - Groups by platform ( Linux )" - since this point you'll get errors in server log on each recalculate attempt of "Groups by platform" dynagroup
3. go to "Groups by platform" and hit recalculate

At create dynagroup time we don't know yet which and how many groups is it going generate (especially when there is groupby expression) - in fact generated groups can change over time based on what you have in inventory, thatswhy we cannot show UI error. That UI/CLI error could happen only if you hit recalculate in UI. 

> The same goes the other way around -- if an attempt is made to create a
> static group with the name "DynaGroup - Read Only All Resources (
> server.example.com(JBoss Main Server) )" after a dynamic group definition by
> the same name already exists, again, I expect a UI or remote API error.

Yes, this is how it works now - but again .. that dynagroup must have been recalculated at least once.

> I can not see how an existing dynamic group definition would ever
> recalculate a group member list and happen to generate a group with the same
> name as an unrelated resource group considering that for the definition to
> exist, the name had to be unique in the first place.
> 
> We have a bug in either the creation of groups allowing the new groups name
> to use the same name as an existing group or, what I fear here, is that
> something with the upgrade process or dynamic group changes made in a 3.2 or
> 3.3 commit is has cause the group that is associated with this dynamic group
> definition to become "disconnected."
> 
I went through all schema changes we did since 3.2 and we did not touch the relation between dynaGroup definition and generated group. dynaGroup definition is affected only by adding a reference to predefined expression provided by plugins (JON3-5) - which added 1 column.

Comment 6 Libor Zoubek 2015-03-16 12:28:32 UTC
What we can do 'though .. we can handle the situation, when we recalculate dynaGroup definition, and we find out there's an existing group matching with it's name the one we're going to create, but it's not connected to our group definition, we can log a warning and delete the original group and create new one from our definition or just adopt the group and update it's members instead of failure right now, which prevents finishing recalculation. 

I'd be for adopt the "disconnected" group (assumming user knows he should not create groups matching "DynaGroup -*"). In other case (when we don't know how this disconnection happens) - we're going to "repair" the data. Adoption is better than deletion, because it does not generate new ID (as the group could be referenced on dashboards, etc)

Comment 8 Larry O'Leary 2015-04-16 13:55:25 UTC
After discussing this with Libor, the issue here is name conflicts that can occur when the user names a group (non-dynamic) using the same string that JBoss ON is using for the prefix of a dynamic group name. This causes an unintentional conflict in where groups or child/auto groups could end up being named the same as a static group the user has created.

Although this is a very bad design, it is how it was implemented and changing it would be too disruptive. Users should avoid naming groups anything similar or using a string at the beginning that will conflict with the poorly chosen internal naming prefix of 'DynaGroup - '.

Comment 9 Libor Zoubek 2015-09-30 14:40:03 UTC
Actually I was able to reproduce this BZ.

It's enough if dynaGroup expression looks like this:

groupby resource.name

and you have at least one EAP6 standalone and one EAP6 domain in inventory.

The issue happens, because (if you have those 2 servers) there are resources called "Threading" and "threading"

Code which creates resourceGroup first tries to query DB for an existing name using this JPA query:

SELECT rg FROM ResourceGroup AS rg WHERE LOWER(rg.name) = LOWER(:name) AND rg.visible = true"

this means, resource groups called "*threading" and "*Threading" cannot coexist.

Comment 12 Jay Shaughnessy 2015-12-02 19:27:45 UTC
So, as Libor discovered, the issue is that group names (for visible groups) are case insensitive.  This is basically a good thing but it breaks down here, because the dynagroup name uses the 'pivot' values resulting from the group definition. And certain expressions could be a problem, like 'groupby resource.name' because resource names are flexible.  In this case the group name we wanted was:

DynaGroup - Read Only All Resources ( server.example.com(JBoss Main Server) )

But the 'Read Only All Resource' group definition must have generated results with the groupBy clause resulting in both 'server.example.com(JBoss Main Server)' another one that differed only by case.

After looking at this further I think the right thing to do is to "merge" the members of dynagroups with caseInsensitive-equal names. In this way all of the resulting resources end up in a generated dynagroup.  It may be the case that a user could be slightly surprised at the result but it is a logical result given the data. And of course at the moment the buggy behvior is severe.

Master commit 08075f8f5693853183b6f00a937c20bcb3575cfb
Author: Jay Shaughnessy <jshaughn>
Date:   Wed Dec 2 13:55:37 2015 -0500

 In a rare case a groupBy expression can generates multiple groupByClause
 strings differing only in case. Group names are [correctly] case
 insensitive and groupBy [correctly] is not. For example 'groupby
 resource.name' can cause this issue with two resources with the same name,
 ignoring case, like 'CPU' and 'cpu'.  In this situation we need to
 consolidate results into one dyna-group, otherwise we'll get naming
 conflicts in the generated groups. So, merge results where the
 groupByClause is equal, ignoring case.

Comment 13 Simeon Pinder 2015-12-04 19:55:42 UTC
branch: release/jon3.3.x
commit: c99d2ddbee245b59d0d52c60f903662e1be480ca
Author:     Jay Shaughnessy <jshaughn>
AuthorDate: Wed Dec 2 13:55:37 2015 -0500
Commit:     Simeon Pinder <spinder>
CommitDate: Fri Dec 4 09:46:52 2015 -0500

    BZ 1187680 : Error recalculating DynaGroups due to ResourceGroupAlreadyExistsException
...

Comment 14 Simeon Pinder 2015-12-09 06:29:21 UTC
Moving to ON_QA as available to test with the following brew build:

JON Cumulative patch build: https://brewweb.devel.redhat.com/buildinfo?buildID=469635
  *Note: jon-server-patch-3.3.0.GA.zip maps to DR01 build of jon-server-3.3.0.GA-update-05.zip.

Comment 15 Sunil Kondkar 2015-12-17 15:43:21 UTC
Tested on Version :3.3.0.GA Update 05 Build Number :bb9d2ba:95ae59f

Imported couple of EAP servers and created a dynagroup definition with expression - groupby resource.name
Tried clicking on Recalculate button few times. There is no error and the selected group definition is recalculated successfully.

However, referring to the steps in comment#5, following steps still show the ResourceGroupAlreadyExistsException.

-Navigate to Administration->All Groups
-Delete the platform group - DynaGroup - Groups by platform ( Linux )
-Click on New
-Enter the same name "DynaGroup - Groups by platform ( Linux )" and click Next
-Select and move the platform resource to the Assigned resource table in 'Select Members' screen.
-Click Finish
-Go to Administration->Dynagroup Definitions and select 'Groups by platform'.
-Click on Recalculate button.
-It displays error in UI - 'Failed to recalculate the selected group definitions

The server log shows below exception:

10:24:43,192 WARN  [org.rhq.coregui.server.gwt.ResourceGroupGWTServiceImpl] (http-/0.0.0.0:7080-8) Sending exception to client: [1450365883192] : org.rhq.enterprise.server.resource.group.ResourceGroupAlreadyExistsException: ResourceGroup with name DynaGroup - Groups by platform ( Linux ) already exists

Please refer the attached screenshot and server.log

Comment 16 Sunil Kondkar 2015-12-17 15:44:15 UTC
Created attachment 1106761 [details]
Screenshot-UI-Message

Comment 17 Sunil Kondkar 2015-12-17 15:46:26 UTC
Created attachment 1106762 [details]
Server Log

Comment 18 Jay Shaughnessy 2015-12-18 21:23:47 UTC
If the only failure scenario is due to manually created groups named exactly like generated dynagroups then I think the solution is to just have them rename those groups as a workaround.  I can't really imagine this is a real-world scenario and so I'm not sure it's worth any risk trying to handle it.

Sunil, if you can confirm that this is the only failure scenario I think we should discuss whether GSS is satisfied with the current fix.

Comment 19 Larry O'Leary 2015-12-21 16:16:06 UTC
I still think that we should properly handle the scenario described in comment 5 but I do agree with Jay that this is not a normal scenario. It is not even the one the customer was facing. Instead, it was invented as a theory of what the user was most likely doing to get into the situation. 

As indicated in comment 9, the forced duplicate naming issue was not the cause of this bug.

@Sunil, as Jay indicated, if you can confirm that your test failure was due to the forced duplicate naming described in comment 5, then I think we can mark this verified. For completeness, your verification comment should clearly indicate that the issue described in comment 5 is still not fixed but it was determined that what was described in comment 5 was out-of-scope for this BZ and was not the underlying issue.

Comment 20 Sunil Kondkar 2015-12-21 16:32:41 UTC
Yes Jay and Larry,

I tried to reproduce with adding couple of agents, EAP servers - standalone and domain mode and created a dynagroup definition with expression - groupby resource.name
The issue is not reproducible by clicking recalculate button for dynagroups created with above expression.

The test failure was only due to the forced duplicate naming described in comment#5. 
The scenario in comment#5 is still shows the ResourceGroupAlreadyExistsException, but as this scenario is out-of-scope for this bug, marking the bug as verified.

Comment 22 errata-xmlrpc 2016-02-03 15:02:08 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHSA-2016-0118.html


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