From: Laurent G. <lg...@gm...> - 2008-12-05 23:44:08
|
Jonathan, Alright, that makes sense. Now I'm just having some difficulties accessing those methods through JMX. lgeyer@xxx:/usr/local/jrtg$ java -jar /usr/local/bin/cmdline-jmxclient-0.10.3.jar - localhost:8089 com.virtela.poller:type=RTGDBDriver pauseDBInserts 12/05/2008 18:42:40 -0500 org.archive.jmx.Client com.virtela.poller:type=RTGDBDriver is not a registered bean lgeyer@xxx:/usr/local/jrtg$ java -jar /usr/local/bin/cmdline-jmxclient-0.10.3.jar - localhost:8089 com.virtela.poller:type=DBDriver pauseDBInserts 12/05/2008 18:42:47 -0500 org.archive.jmx.Client com.virtela.poller:type=DBDriver is not a registered bean What am I missing here? Thanks for your help, Laurent On Fri, Dec 5, 2008 at 5:46 PM, Leech, Jonathan <jl...@vi...> wrote: > Laurent, > > Very good question. The RTGDBDriver has the commitAllTransactions(), and > reconnectAll() methods exposed through JMX to do extactly that externally. > This would help in scenarios of a planned maintenance, or an outage that is > detected quickly. Also you should call pauseDBInserts() on the DBBuffer > first. So the steps would be > 1) pauseDBInserts() > 2) commitAllTransactions() > 3) perform database maintenance > 4) reconnectAll() > 5) resumeDBInserts(). > > JRTG has not yet been instrumented to automatically reconnect to the > database after certain fatal errors. The place to do this would be either > the DBDriver class or in the ConnectionWrapper class. I intended to do so in > the ConnectionWrapper class, there is even a comment at the top: // TODO: > attempt to reconnect to the database after certain SQL errors. This > recquires some knowledge of which errors should result in a reconnection and > which shouldn't. A good place to find this kind of information might be > JBoss connection pool logic, or a similar connection pooling library. > > The NPE is a bug. Line 193 of JRTGDBDriver should be modified to read: if > (ps != null) ps.close(); It is masking the real SQLExceptions caused by the > database restart. > > Also, if you have a firewall or some other evil device in between your > poller and database, you should probably also add a call to > setQueryTimeout() on the PreparedStatement prior to ps.execute() on line > 178. I don't know specifically how the mySQL JDBC driver would react to a > connection dropped by a firewall, or if it implements setQueryTimeout(), but > I can attest to the fact that the Oracle JDBC driver will hang indefinitely > on the execute() method if the connection is dropped, unless a timeout is > provided. > > -Jonathan > > ------------------------------ > *From:* Laurent Geyer [mailto:lg...@gm...] > *Sent:* Friday, December 05, 2008 1:52 PM > *To:* jrt...@li... > *Subject:* [Jrtg-users] insert() error - NullPointerException > > Hi, > > So far so good. Have had jrtg running little over a month now and it's been > solid. > > Unfortunately today I noticed I lost about two days worth of data. The date > it stopped collecting coincided with a MySQL server restart following a > MySQL upgrade. > > Dec 5, 2008 3:44:34 PM com.virtela.poller.DBDriver insert > WARNING: insert() error. > java.lang.NullPointerException > at com.virtela.poller.RTGDBDriver.insert(RTGDBDriver.java:193) > at com.virtela.poller.DBDriver.insert(DBDriver.java:220) > at com.virtela.poller.DBDriver.insert(DBDriver.java:200) > at com.virtela.poller.DBBuffer$3.call(DBBuffer.java:253) > at com.virtela.poller.DBBuffer$3.call(DBBuffer.java:250) > at > java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) > at java.util.concurrent.FutureTask.run(FutureTask.java:138) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) > at java.lang.Thread.run(Thread.java:619) > > Is there any way I can reconnect the MySQL session and commit the inserts > following a restart or loss of connectivity? > > Thanks, > > Laurent > > > |