Bug 880535 - Error inserting events when the message contains null bytes
Error inserting events when the message contains null bytes
Status: NEW
Product: RHQ Project
Classification: Other
Component: Database (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: RHQ Project Maintainer
Mike Foley
Depends On:
  Show dependency treegraph
Reported: 2012-11-27 04:21 EST by vlad crc
Modified: 2013-07-16 10:43 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
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):

How reproducible:
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.

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