提交 7ad1aa87 authored 作者: Noel Grandin's avatar Noel Grandin

fix deadlock in multithreaded mode

need to call lockMeta before we synchronize on the Database object or
we get an ABBA deadlock
上级 1b77ee19
...@@ -130,10 +130,10 @@ public class Analyze extends DefineCommand { ...@@ -130,10 +130,10 @@ public class Analyze extends DefineCommand {
// then we can't update the statistics because // then we can't update the statistics because
// that would unlock all locked objects // that would unlock all locked objects
synchronized (sysSession) { synchronized (sysSession) {
synchronized (db) { // can't take the db lock yet, updateMeta needs to call lockMeta,
db.updateMeta(sysSession, table); // and then it will take the db lock
sysSession.commit(true); db.updateMeta(sysSession, table);
} sysSession.commit(true);
} }
} }
} }
......
...@@ -1632,14 +1632,16 @@ public class Database implements DataHandler { ...@@ -1632,14 +1632,16 @@ public class Database implements DataHandler {
* @param session the session * @param session the session
* @param obj the database object * @param obj the database object
*/ */
public synchronized void updateMeta(Session session, DbObject obj) { public void updateMeta(Session session, DbObject obj) {
lockMeta(session); lockMeta(session);
int id = obj.getId(); synchronized (this) {
removeMeta(session, id); int id = obj.getId();
addMeta(session, obj); removeMeta(session, id);
// for temporary objects addMeta(session, obj);
if (id > 0) { // for temporary objects
objectIds.set(id); if (id > 0) {
objectIds.set(id);
}
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论