Subject: | dbd_jdbc server and oracle commits |
Date: | Wed, 16 Jan 2008 13:41:10 +0000 |
To: | bug-DBD-JDBC [...] rt.cpan.org, gemerson [...] vizdom.com |
From: | Martin Evans <m.d.t.evans [...] qmul.ac.uk> |
Hi,
I'm having some trouble with the dbd_jdbc server not rolling back when
talking to oracle. I have some code that goes like this:
Connect with autocommit off:
$dbo = DBI->connect($jdbc_dsn,$username,$password,
{ 'AutoCommit' => 0, 'PrintError' => 0 })
or die "Can't connect: $DBI::errstr";
Prepare an insert statement.
Start a transaction: $dbo->begin_work();
Execute the insert.
At this point, if a perl die or exit is called or a kill signal is sent
the transaction is committed to oracle (even though $dbo->commit() has
not been called).
My suspicion (by playing with oracles sqlplus command) is that oracle
always commits the current transaction if the client closes its
normally. This is annoying in perl because if you die in the middle of a
transaction you normally don't want that data committed.
I have a crude hack (below) that helps a little. It rollsback if the
client connection vanishes if a SIGTERM is sent (but doesnt if the perl
dies or exits)...
$ diff -u Connection.java.1 Connection.java
--- Connection.java.1 2006-06-22 17:33:22.000000000 +0100
+++ Connection.java 2008-01-16 13:21:28.000000000 +0000
@@ -174,8 +174,10 @@
* handleMessage(Connection conn)
{conn.handleMessage(this)}
*/
request = mBerModule.readFrom(mIn);
- if (request == null)
+ if (request == null) {
+ mConn.rollback();
throw new FatalException("Client disconnected");
+ }
if (gLog.isDebugEnabled())
gLog.debug("Request: " + request);
Regards,
Martin.
--
-- Dr Martin Evans, Computing Services, Queen Mary