Cricalix.Net

Going sane since 1978

Browsing Posts published in September, 2008

$work uses OpenNMS to monitor our various devices (servers, switches, routers, printers etc), mostly via SNMP.  Today, while looking at the various events that had been recorded, I noticed that a relatively simple search was taking more than 2 minutes to process through ~250,000 event rows (plus associated rows in other tables).  I turned on query logging (log_statements = ‘all’ && service postgresql reload), and re-ran the search from the web interface.

Lo and behold, the culprit was revealed – the search went something like

UPPER(eventlogmsg) LIKE ‘%value%’

Even if that field was indexed,the use of the ‘%’ on the front would negate the use of the index.  I threw the query into PGAdmin, and discovered that the query plan that PostgreSQL chose was a pair of nested loop joins – unpleasant to say the least.  A quick gander at the docs, and a few SQL statements later, and I had a full-text index on the eventlogmsg field.  Several test queries convinced me that it was much faster, so I threw the new query into PGAdmin and asked for the pretty query plan.  Two hash joins and a sort, and a query time of 31 milliseconds; or more than 5000 times faster.

So, I’ve filed a Bugzilla entry for this with the OpenNMS team – unfortunately it’s specific to PostgreSQL 8.3, but that’s something that can probably be determined at run-time and install-time.  Hopefully they agree that it’s a worthwhile performance change, as full-text indexes won’t actually help the LIKE usage – the code will have to change to generate new SQL statements.

Caused by: javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
class com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 User unknown

at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1130)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:525)
at javax.mail.Transport.send0(Transport.java:151)
at javax.mail.Transport.send(Transport.java:80)
at alt.javax.mail.TransportImpl.send(TransportImpl.java:18)
at com.atlassian.mail.server.impl.SMTPMailServerImpl.send(SMTPMailServerImpl.java:168)
… 7 more
X connection to localhost:10.0 broken (explicit kill or server shutdown).

What a way to end a day that hasn’t been one of my better ones (more on that later, maybe).  Having got Tomcat back up and running, and slimmed down to just JIRA, I was hoping that the day was going to smooth out, at least for the last working hour.  Instead, I’ve been watching Tomcat just fall over at random, spitting out an error that the X connection went away.  There is nothing in the Tomcat configuration that requires X, so I can only guess that Java noticed that I had an environment variable set, and even though there was no X at the end of the DISPLAY, decided to use it anway.  My only hypothesis is that after some period of time, Java determined that the connection wasn’t there, and terminated Tomcat.

Wonderful.

unset DISPLAY && ./startup.sh

Powered by WordPress Web Design by SRS Solutions © 2010 Cricalix.Net Design by SRS Solutions