为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:
【操作系统】:
【CPU】:
【问题描述】*:
利用dmflr通过ctl方式批量导入数据,linux使用java调用 shell脚本方式执行导致数据库表死锁。将下面的14个dmflr命令拆分为两个7个dmflr的脚本,执行正常。脚本单独执行都是正常的。
问题出现在java对执行返回的处理:```java
public boolean exeCmd(String commandStr) {
logger.info("exeCmd*****");
logger.debug("commandStr : " + commandStr);
AtomicReference
ExecutorService executor = Executors.newFixedThreadPool(2);
try {
Process p = Runtime.getRuntime().exec(commandStr);
pRef.set(p);
// 读取标准输出流
executor.submit(() -> {
try (BufferedReader stdOut = new BufferedReader(new InputStreamReader(pRef.get().getInputStream(), Charset.forName("UTF-8")))) {
String line;
StringBuilder sbOut = new StringBuilder();
while ((line = stdOut.readLine()) != null) {
logger.info("Standard Output: " + line);
}
} catch (IOException e) {
logger.error("Error reading standard output", e);
}
});
// 读取标准错误流
executor.submit(() -> {
try (BufferedReader stdErr = new BufferedReader(new InputStreamReader(pRef.get().getErrorStream(), Charset.forName("UTF-8")))) {
String line;
StringBuilder sbErr = new StringBuilder();
while ((line = stdErr.readLine()) != null) {
logger.error("Standard Error: " + line);
}
} catch (IOException e) {
logger.error("Error reading standard error", e);
}
});
// 等待子进程完成
int exitCode = p.waitFor();
if (exitCode == 0) {
logger.info("Command executed successfully.");
return true;
} else {
logger.error("Command failed with exit code: " + exitCode);
return false;
}
} catch (Exception e) {
logger.error("Error executing command: " + commandStr, e);
return false;
} finally {
executor.shutdown();
try {
executor.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.error("ExecutorService did not terminate", e);
}
if (pRef.get() != null) {
pRef.get().destroy();
}
}
}
这里是指一起导入的时候死锁的?导入的是同一个表对象吗?数据库版本也可以提供一下。
--查询死锁涉及的事务信息
select dh.trx_id,sh.sess_id,wm_concat(top_sql_text) from v$deadlock_history dh join v$sql_history sh on dh.trx_id = sh.trx_id and dh.sess_id=sh.sess_id group by dh.trx_id,sh.sess_id;
--查询阻塞锁
select * from v$lock where blocked=1;
--查询锁等待
select * from v$trxwait;
--查询被阻塞的信息和引起阻塞的信息
select sysdate stattime,datediff(ss,s1.last_send_time,sysdate) ss,
'被阻塞的信息' wt,s1.sess_id wt_sess_id,s1.sql_text wt_sql_text,s1.state wt_state,
s1.trx_id wt_trx_id,s1.user_name wt_user_name,s1.clnt_ip wt_clnt_ip,
s1.appname wt_appname,s1.last_send_time wt_last_send_time,
'引起阻塞的信息' fm,s2.sess_id fm_sess_id,s2.sql_text fm_sql_text,s2.state wt_state,
s2.trx_id fm_trx_id,s2.user_name fm_user_name,s2.clnt_ip fm_clnt_ip,
s2.appname fm_appname,s2.last_send_time fm_last_send_time from v$sessions s1,v$sessions s2,v$trxwait w
where s1.trx_id=w.id and s2.trx_id=w.wait_for_id;