この関数でデッドロックが発生しています。この関数は複数のスレッドから呼び出されています。この行でデッドロックが発生しています
Map<String,Object> out = simpleJdbcCall.execute(map); //deadlock here
ここで非常によく似た問題の記事を読んでください。
手伝って頂けますか ?デッドロックを回避するためにコードを変更する方法
public Status validateElementDetails(DetailsInfo[] elementDetails)
{
StructDescriptor structDescriptor=null;
ArrayDescriptor arrayDescriptor=null;
Object[] arrObj =null;
Object[][] recObj =null;
Connection conn=null;
Status status = new Status();
try{
log.info("Creating SimpleJdbcCall. dataSource:"+dataSource);
SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(dataSource);
log.info("Creating connection ...");
//conn = simpleJdbcCall.getJdbcTemplate().getDataSource().getConnection(); //tried this - deadlock
conn = DataSourceUtils.getConnection(dataSource); //try this
OracleConnection oraConn = (oracle.jdbc.OracleConnection) conn;
log.info("Main conn:"+conn);
log.info("Oracle conn:"+oraConn);
log.info("Creating structDescriptor ...");
structDescriptor = StructDescriptor.createDescriptor(KEY_CIRCUIT, oraConn);
log.info("Creating arrayDescriptor ...");
arrayDescriptor = ArrayDescriptor.createDescriptor(KEY_CIRCUIT_ARRAY, oraConn);
log.info("structDescriptor:"+structDescriptor);
log.info("arrayDescriptor:"+arrayDescriptor);
log.info("Desc created for Site");
int iSize = elementDetails.length;
arrObj = new Object[iSize];
recObj = new Object[iSize][7]; // 4 attributes for validation + 3 for attribute update
int size =0;
for (int j = 0; j < elementDetails.length ;j++)
{
SiteDetailsInfo ob = (SiteDetailsInfo)elementDetails[j];
recObj[size][0]=ob.getSiteId();
recObj[size][1]=ob.getSiteName();
recObj[size][2]="";
//arrObj[size] = new STRUCT(structDescriptor, conn.getMetaData().getConnection(), recObj[size]);
arrObj[size] = new STRUCT(structDescriptor, oraConn, recObj[size]);
log.info("recObj ["+size+"]="+recObj[size]);
log.info("arrObj ["+size+"]="+arrObj[size]);
size++;
}
//ARRAY arr = new ARRAY(arrayDescriptor, conn.getMetaData().getConnection(), arrObj);
log.info("Creating arr ...");
ARRAY arr = new ARRAY(arrayDescriptor, oraConn, arrObj);
log.info("Creating arr done:"+arr);
log.info("SQL object created for validation");
simpleJdbcCall.withCatalogName(BGWConstants.KEY_PACKAGE).withProcedureName(BGWConstants.KEY_VALIDATE_SITE_PROC)
.declareParameters(new SqlParameter("P_SITE_DATA",java.sql.Types.ARRAY,KEY_CIRCUIT_ARRAY))
.declareParameters(new SqlOutParameter(BGWConstants.KEY_STATUS_MESSAGE,java.sql.Types.VARCHAR))
.declareParameters(new SqlOutParameter(BGWConstants.KEY_STATUS,java.sql.Types.VARCHAR));
log.info("simpleJdbcCall.withCatalogName:"+BGWConstants.KEY_VALIDATE_SITE_PROC);
Map<String, Object> map = new HashMap<String, Object>();
map.put("P_SITE_DATA", arr);
log.info("Going to execute DB validation for Site");
Map<String,Object> out = simpleJdbcCall.execute(map); //here we have deadlock
log.info("Going to execute DB validation for Site done");
String dbMessage = (String) out.get(BGWConstants.KEY_STATUS_MESSAGE);
String dbStatus = (String) out.get(BGWConstants.KEY_STATUS);
if(dbStatus != null && dbStatus.equals("1"))
{
status.setMessage(dbMessage);
status.setStatusCode(StatusCode.SUCCESS);
}else{
status.setMessage(dbMessage);
status.setStatusCode(StatusCode.ERROR);
}
log.info("Stored procedure executed with status: "+status.getStatusCode().getValue());
}catch (Exception e) {
status.setStatusCode(StatusCode.ERROR);
status.setMessage("Error while doing Site validation. "+e.getMessage());
log.error("Exception:"+e.getMessage());
log.error("Exception:",e);
}
finally{
try {
if (conn != null){
conn.close();
log.info("Connection from jdbcTemplate is closed");
}
} catch (SQLException e2) {
log.info("problem while closing connection");
}
}
return status;
}
ここにログがあります
[deadlocked thread] [ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)':
---------------------------------------------------------------------------------------------------
Thread '[ACTIVE] [b]ExecuteThread: '14' [/b]for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'oracle.jdbc.driver.T4CConnection@[b]42cb6b0a' [/b]that is held by thread '[ACTIVE] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)''
[code]
Stack trace:
------------
oracle.sql.TypeDescriptor.getName(TypeDescriptor.java:703)
oracle.jdbc.oracore.OracleTypeCOLLECTION.isInHierarchyOf(OracleTypeCOLLECTION.java:149)
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2063)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3571)
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3677)
oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4714)
oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:99)
org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:987)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:985)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:368)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:353)
org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:160)
com.bgw.dao.SiteDAOImpl.validateElementDetails(SiteDAOImpl.java:311)
com.bgw.dao.SiteDAOImpl.updateAllSites(SiteDAOImpl.java:139)
com.bgw.intf.UpdateBGWDBServiceImpl.updateComponentAttributes(UpdateBGWDBServiceImpl.java:154)
com.bgw.webservices.l1c.BGWDBComponent.BGWDBComponentSOAPImpl.updateComponentAttributes(BGWDBComponentSOAPImpl.java:34)
sun.reflect.GeneratedMethodAccessor287.invoke(Unknown Source)
[deadlocked thread] [ACTIVE] ExecuteThread: '9' for queue: 'weblogic.kernel.Default (self-tuning)':
--------------------------------------------------------------------------------------------------
Thread '[ACTIVE] [b]ExecuteThread: '9'[/b] for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'oracle.jdbc.driver.T4CConnection@[b]942f772[/b]' that is held by thread '[ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)''
[code]
Stack trace:
------------
oracle.sql.TypeDescriptor.getName(TypeDescriptor.java:703)
oracle.jdbc.oracore.OracleTypeCOLLECTION.isInHierarchyOf(OracleTypeCOLLECTION.java:149)
oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2063)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3571)
oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3677)
oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4714)
oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:99)
org.springframework.jdbc.core.JdbcTemplate$5.doInCallableStatement(JdbcTemplate.java:987)
org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:936)
org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:985)
org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:368)
org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:353)
org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:160)
com.bgw.dao.SiteDAOImpl.validateElementDetails(SiteDAOImpl.java:311)
com.bgw.dao.SiteDAOImpl.updateAllSites(SiteDAOImpl.java:139)
com.bgw.intf.UpdateBGWDBServiceImpl.updateComponentAttributes(UpdateBGWDBServiceImpl.java:154)
com.bgw.webservices.l1c.BGWDBComponent.BGWDBComponentSOAPImpl.updateComponentAttributes(BGWDBComponentSOAPImpl.java:34)
sun.reflect.GeneratedMethodAccessor287.invoke(Unknown Source)