Hello mmbase developers,
Our configuration: Weblogic 6.1 sp3 jdk1.3.1_06, solaris 2.8 (solaris 8),
Oracle 8.1.7 release 3
We have a publisher which changes the context (owner) state of nodes and
relations. The publisher is a new thread which wakes up every 60 seconds.
The database has indexes on the columns m_number, snumber and dnumber. We
have also an index on the owner column of the tables which we use in this
publisher.
We think we don't need the checkTime method, but does somebody know why we
need this one?
We assume that this method is used to close "unclosed" connections, probably
due to missing close statements in the code
And does somebody know a solution for our issue?
Best regards
Nico Klasens using mailingaddress of Chris Spelberg
This is a snippet of a thread dump which we got from the command "kill -3"
of the java process.
FOUND A JAVA LEVEL DEADLOCK:
----------------------------
"JDBCProbe":
waiting to lock monitor 0xa1128 (object 0xf732da00, a
oracle.jdbc.driver.OracleStatement),
which is locked by "Thread-5"
"Thread-5":
waiting to lock monitor 0xa10f0 (object 0xf7197f48, a
oracle.jdbc.driver.OracleConnection),
which is locked by "JDBCProbe"
JAVA STACK INFORMATION FOR THREADS LISTED ABOVE:
------------------------------------------------
Java Stack for "JDBCProbe":
==========
at
oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:562)
- waiting to lock <f732da00> (a oracle.jdbc.driver.OracleStatement)
at
oracle.jdbc.driver.OracleConnection.close_statements(OracleConnection.java:1
596)
- locked <f7197f48> (a oracle.jdbc.driver.OracleConnection)
at
oracle.jdbc.driver.OracleConnection.close(OracleConnection.java:899)
- locked <f7197f48> (a oracle.jdbc.driver.OracleConnection)
at org.mmbase.module.database.MultiConnection.realclose(Unknown
Source)
at org.mmbase.module.database.MultiPool.checkTime(Unknown Source)
- locked <f5a07618> (a java.lang.Object)
at org.mmbase.module.database.MultiPoolHandler.checkTime(Unknown
Source)
at org.mmbase.module.database.JDBC.checkTime(Unknown Source)
- locked <f596aaf8> (a org.mmbase.module.database.JDBC)
at org.mmbase.module.database.JDBCProbe.run(Unknown Source)
at java.lang.Thread.run(Thread.java:479)
Java Stack for "Thread-5":
==========
at
oracle.jdbc.driver.OracleConnection.needLine(OracleConnection.java:1607)
at
oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1634)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java
:1870)
at
oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:538)
- locked <f732da00> (a oracle.jdbc.driver.OracleStatement)
at org.mmbase.module.database.MultiStatement.executeQuery(Unknown
Source)
at org.mmbase.module.core.MMObjectBuilder.basicSearch(Unknown
Source)
at org.mmbase.module.core.MMObjectBuilder.searchVector(Unknown
Source)
at org.mmbase.bridge.implementation.BasicNodeManager.getList(Unknown
Source)
at nl.vodafone.mmbase.Publisher.testExpiries(Publisher.java:122)
at nl.vodafone.mmbase.Publisher$Runner.run(Publisher.java:265)
at java.lang.Thread.run(Thread.java:479)
Found 1 deadlock.
//*********************************
// nl.vodafone.mmbase.Publisher
//*********************************
/**
* Tests all published site elements for expiration.
* If the expirationtime of a site element is reached,
* create an approved deletion for it. Consequentially,
* it will be unpublished the next time all approved changes are
published.
*/
public void testExpiries()
{
Date now = new Date();
// Get the site element nodemanager.
NodeManager sitel = mmbase.getNodeManager("sitel");
// Iterate over all published site elements.
NodeList publishedSitels =
sitel.getList("owner='content_publ'", null, null);
NodeIterator iPublishedSitels = publishedSitels.nodeIterator();
while (iPublishedSitels.hasNext())
{
Node publishedSitel = iPublishedSitels.nextNode();
Date expireDate =
new Date(1000 * publishedSitel.getLongValue("expiredate"));
if (!now.before(expireDate))
{
// Add version relation to "delete" pool,
// set relation context to "version_approved".
Relation version =
versionManager.createRelation(publishedSitel,
deletePool);
version.commit();
version.setContext("version_appr");
}
}
}
//*********************************
// org.mmbase.module.database.MultiPool
//*********************************
/**
* Check the connections
*/
public void checkTime() {
MultiConnection con,bcon;
int nowTime;
int diff;
nowTime=(int)(System.currentTimeMillis()/1000);
synchronized(synobj) {
for (Enumeration
e=busypool.elements();e.hasMoreElements();) {
con=(MultiConnection)e.nextElement();
diff=nowTime-con.getStartTime();
if (diff>5) {
if (log.isDebugEnabled()) {
log.debug("Checking a busy connection "+con);
}
}
if (diff<30) {
// below 30 we still wait
} else if (diff<120) {
// between 30 and 120 we putback
'zero' connections
if (con.lastSql==null ||
con.lastSql.length()==0) {
log.warn("null connection
putBack");
putBack(con);
}
} else {
// above 120 we close the connection
and open a new one
MultiConnection newcon=null;
if (log.isDebugEnabled()) {
log.debug("KILLED SQL
"+con.lastSql+" time "+diff);
}
try {
Connection
realcon=DriverManager.getConnection(url,name,password);
initConnection(realcon);
newcon=new
MultiConnection(this,realcon);
if (log.isDebugEnabled()) {
log.debug("WOW added
JDBC connection now ("+pool.size()+")");
}
} catch(Exception re) {
log.error("ERROR Can't add
connection to pool");
}
busypool.removeElement(con);
try {
con.realclose();
} catch(Exception re) {
log.error("Can't close a
connection !!!");
}
if (newcon!=null)
pool.addElement(newcon);
}
}
if ((busypool.size()+pool.size())>conMax) {
int i;
if (log.isDebugEnabled()) {
log.debug("JDBC -> Warning number of
connections exceeds conMax "+(busypool.size()+pool.size()));
}
// Check if there are dups in the pools
for(Enumeration
e=busypool.elements();e.hasMoreElements();) {
bcon=(MultiConnection)e.nextElement();
i=pool.indexOf(bcon);
if (i>=0) {
if (log.isDebugEnabled()) {
log.debug("duplicate
connection found at "+i);
}
pool.removeElementAt(i);
}
}
while(((busypool.size()+pool.size())>conMax)
&& pool.size()>2) {
// Remove too much ones.
con=(MultiConnection)pool.elementAt(0);
if (log.isDebugEnabled()) {
log.debug("removing
connection "+con);
}
pool.removeElementAt(0);
}
}
}
}