Bug 880535

Summary: Error inserting events when the message contains null bytes
Product: [Other] RHQ Project Reporter: vlad crc <vlad.craciunoiu>
Component: DatabaseAssignee: RHQ Project Maintainer <rhq-maint>
Status: NEW --- QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.4CC: hrupp, vlad.craciunoiu
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description vlad crc 2012-11-27 04:21:51 EST
Description of problem:

We monitor a JBoss and we activated Log Event Sources. In Jboss there is an application which put some errors in log. RHQ tries to insert these errors in the events table but it fails because "invalid byte sequence for encoding "UTF8": 0x00".
This is a known problem with Postgres, strings containing null characters cannot be inserted in "text" fields because Postgres is written in C where null character is used as string terminator.
The solution would be to process these strings in RHQ by removing null characters.

Version-Release number of selected component (if applicable):
4.4

How reproducible:
always
  
Actual results:
2012-11-27 10:03:25,779 WARN  [org.rhq.enterprise.server.event.EventManagerBean] addEventData: Insert of events failed : Batch entry 1 INSERT INTO RHQ_Event (id, event_source_id, timestamp, severity, detail) VALUES ((SELECT nextval('RHQ_EVENT_id_seq'::text)), (SELECT id FROM RHQ_Event_Source WHERE event_def_id = (SELECT id FROM RHQ_Event_Def WHERE name = 'logEntry' AND resource_type_id = (SELECT id FROM RHQ_Resource_Type WHERE name = 'JBossAS Server' AND plugin = 'JBossAS')) AND resource_id = '10433' AND location = '/home/jboss/projects/jboss-server/2/server/dorun/log/server.log'), '1354006941407', 'ERROR', '###error message not shown###') was aborted.  Call getNextException to see the cause.
2012-11-27 10:03:25,779 WARN  [org.rhq.enterprise.server.event.EventManagerBean]      : ERROR: invalid byte sequence for encoding "UTF8": 0x00

Expected results:
Events with null bytes in message description should be successfully inserted.
Comment 1 Heiko W. Rupp 2013-06-27 15:33:45 EDT
Would you be able to create a patch?
Comment 2 vlad crc 2013-07-16 10:43:08 EDT
I will try, depends on my workload.

I am thinking, though, if this will become useless when the events will go to Cassandra.