Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Synchronized java code hanging on a commit

Synchronized java code hanging on a commit

From: Paul <paul_gsm_at_yahoo.co.uk>
Date: 30 Aug 2002 11:17:57 -0700
Message-ID: <6a456574.0208301017.4a9f51df@posting.google.com>


I have a client server application that is hanging when, from what I can tell, doing a commit - but I can't see anything wrong with the code. All the server methods that update or delete data from the database are in the same object and are synchronized (the ones that only read data are not). The server has only one database connection. The read-only methods do not contain transaction markers. The methods that update data do contain transaction markers and these methods protect themselves from nested transactions as shown in the code snippet at the end of the posting (the server hangs on the dbConn.commit() call in the singleDBConn class).

If only one thread can ever be updating data, how can we be getting what appears to be deadlock!?

The database is Oracle 8i. I am not sure what information is relevant but -
the isolation level on the connection is set to TRANSACTION_READ_COMMITTED
auto commit is set to false
the JDBC driver we are using is the OCI8 one.

One more piece of information - when the server hangs, there is a TX and a TM type record on the V$LOCK table, with what appear to be corresponding records in the V$LOCKED_OBJECT and V$TRANSACTION tables.

Any help greatly appreciated!!
Paul


public class C1
{

    public synchronized String updateStuff()
{

        blnMyTrans = singleDBConn.beginTrans();
        ...do db updates...
        if (blnMyTrans)
            singleDBConn.commitTrans();

    }

}

public Class singleDBConn
{

    private boolean transStarted = false;

    public boolean beginTransaction()
{

        boolean thisCallStartedTrans = false;
        if (transStarted == false)
        {
            thisCallStartedTrans = true;
            transStarted = true;
        }
        return thisCallStartedTrans;

    }
    public void commitTransaction()
{
        try
        {
            transStarted = false;
            dbConn.commit();
        }
        catch (SQLException e) { }

    }
} Received on Fri Aug 30 2002 - 13:17:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US