提交 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,14 +130,14 @@ public class Analyze extends DefineCommand { ...@@ -130,14 +130,14 @@ 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,
// and then it will take the db lock
db.updateMeta(sysSession, table); db.updateMeta(sysSession, table);
sysSession.commit(true); sysSession.commit(true);
} }
} }
} }
} }
}
public void setTop(int top) { public void setTop(int top) {
this.sampleRows = top; this.sampleRows = top;
......
...@@ -1632,8 +1632,9 @@ public class Database implements DataHandler { ...@@ -1632,8 +1632,9 @@ 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);
synchronized (this) {
int id = obj.getId(); int id = obj.getId();
removeMeta(session, id); removeMeta(session, id);
addMeta(session, obj); addMeta(session, obj);
...@@ -1642,6 +1643,7 @@ public class Database implements DataHandler { ...@@ -1642,6 +1643,7 @@ public class Database implements DataHandler {
objectIds.set(id); objectIds.set(id);
} }
} }
}
/** /**
* Rename a schema object. * Rename a schema object.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论