This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours

Bug 748448

Summary: Purged plugin in RHQ Server fail
Product: [Other] RHQ Project Reporter: Bruno Leite Alves <brunoleitealves>
Component: PluginsAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 4.0.1CC: hrupp, jshaughn, mazz
Target Milestone: ---   
Target Release: RHQ 4.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-12 17:22:25 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Attachments:
Description Flags
Log of RHQ Server
none
XML do plugin rhq none

Description Bruno Leite Alves 2011-10-24 10:00:37 EDT
Description of problem: Purged plugin in RHQ Server fail


Version-Release number of selected component (if applicable): RHQ Server 4.0.1


How reproducible:


Steps to Reproduce:
1. Disabled plugin
2. Deleted plugin
3. Purged plugin
  
Actual results:
The RHQ Server return "NoResultException" when click in the plugin in the list to see the detail. When click in purged again, the system show the message that the plugin will purge, but doesn't purge.

Expected results:
Plugin purged.

Additional info:
In the database (postgre) the status of plugin was just "deleted". I deleted the plugin "by hand" in the database and then the plugin left of the list.
Comment 1 Bruno Leite Alves 2011-10-24 10:14:01 EDT
Created attachment 529880 [details]
Log of RHQ Server

Log of RHQ Server
Comment 2 John Mazzitelli 2011-10-24 10:29:53 EDT
This is the error that causes the problem:

2011-10-24 10:27:35,443 INFO  [org.rhq.enterprise.server.core.plugin.AgentPluginScanner] Plugin file [C:\rhq-server-4.0.1\jbossas\server\default\deploy\rhq.ear\rhq-downloads\rhq-plugins\pdvexpert-rhqplugin-0.9.2-SNAPSHOT.jar] has been deleted from the file system.

2011-10-24 10:28:02,081 INFO  [org.rhq.enterprise.server.resource.metadata.PluginManagerBean] Scheduling plugin [AgentPlugin [id=10051, name=PdvExpertJmxPlugin, md5=d23db50eb155f223291d835fd470a7f3]] to be purged from the database.

2011-10-24 10:30:04,355 WARN  [org.hibernate.util.JDBCExceptionReporter] SQL Error: 0, SQLState: 22025

2011-10-24 10:30:04,355 ERROR [org.hibernate.util.JDBCExceptionReporter] ERRO: cadeia de caracteres de escape inválida
  Hint: Cadeia de caracteres de escape deve ser vazia ou ter um caracter.

2011-10-24 10:30:04,357 ERROR [org.rhq.enterprise.server.scheduler.jobs.AbstractStatefulJob] Failed to execute job [PurgePluginsJob]

javax.ejb.EJBTransactionRolledbackException: org.hibernate.exception.DataException: could not execute query


Unknown why this happened. Postgres error 22025: Invalid escape sequence: HINT: Escape string must be empty or one character.

I wonder if it had something to do with the filename being a Windows path that has backslashes??? That's the only thing I can think of that would be "escaped" in the query. But this is just a wild guess, because I know this worked on Windows before.
Comment 3 John Mazzitelli 2011-10-24 10:39:58 EDT
looking closer at the stack trace, I see this is where it technically failed:

Caused by: javax.persistence.PersistenceException:
org.hibernate.exception.DataException: could not execute query
 at
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
 at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:99)
 at
org.rhq.enterprise.server.util.CriteriaQueryRunner.getCount(CriteriaQueryRunner.java:124)
 at
org.rhq.enterprise.server.util.CriteriaQueryRunner.execute(CriteriaQueryRunner.java:76)
 at
org.rhq.enterprise.server.resource.ResourceTypeManagerBean.findResourceTypesByCriteria(ResourceTypeManagerBean.java:474)
...
 at $Proxy214.findResourceTypesByCriteria(Unknown Source)
 at org.rhq.enterprise.server.resource.metadata.PluginManagerBean.isReadyForPurge(PluginManagerBean.java:108)

Here's the code building the criteria that gets the types:

    public boolean isReadyForPurge(Plugin plugin) {
        ResourceTypeCriteria criteria = new ResourceTypeCriteria();
        criteria.addFilterPluginName(plugin.getName());
        criteria.setRestriction(Criteria.Restriction.COUNT_ONLY);
        PageList results =
resourceTypeMgr.findResourceTypesByCriteria(subjectMgr.getOverlord(),
criteria);
        return results.getTotalSize() == 0;
    }

Is it possible for you to attach the plugin jar to this BZ, or at least attach
the plugin descriptor .xml?
Comment 4 Bruno Leite Alves 2011-10-24 15:27:59 EDT
Created attachment 529952 [details]
XML do plugin rhq

XML do plugin rhq
Comment 5 Charles Crouch 2011-10-31 11:59:01 EDT
(10:53:14 AM) mazz: I never figured out what the issue there was. Looks like it 
was happening when doing development of a plugin and doing the delete/purge 
cycle somehow screwed up.
(10:53:33 AM) mazz: we'd need to replicate over here to get a good sense of 
what the problem is
(10:54:07 AM) mazz: Postgres error 22025: Invalid escape sequence: HINT: Escape 
string must be empty or one character.
(10:54:19 AM) mazz: that's the cause - I have a sense it might be an i18n'ish 
issue
(10:54:42 AM) mazz: but I really don't know. need to replicate
(10:55:05 AM) ccrouch: mazz: did the rhq-plugin.xml he added help?
(10:56:01 AM) mazz: not by visual inspection. I was actually looking to see 
what his plugin name was - perhaps it had some non-English/ASCII characters in 
it.
(10:56:03 AM) mazz: it doesn't
(10:56:16 AM) mazz: the description had some spanish chars in it
(10:56:31 AM) mazz: but I never actually ran a test with this to see if that 
really would cause problems
(10:56:35 AM) mazz: we only query on the plugin name
Comment 6 John Mazzitelli 2011-10-31 14:51:51 EDT
what version of Postgres are you using? If its 9.1, this sounds like bug #741855 - it too mentions:

   Caused by: org.postgresql.util.PSQLException: ERROR: invalid escape string
     Escape string must be empty or one character.

Please read that issue and see if its suggestion corrects the problem. I suspect that is the cause for your issue (since the error looks to be the same).
Comment 7 Jay Shaughnessy 2013-09-12 17:22:25 EDT
There has been a lot of work in this area and I believe the issue has been resolved.  Never received any requested info.  Closing as CURRENTRELEASE.  Please open a new BZ if the issue is rediscovered.