提交 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 {
// then we can't update the statistics because
// that would unlock all locked objects
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);
sysSession.commit(true);
}
}
}
}
}
public void setTop(int top) {
this.sampleRows = top;
......
......@@ -1632,8 +1632,9 @@ public class Database implements DataHandler {
* @param session the session
* @param obj the database object
*/
public synchronized void updateMeta(Session session, DbObject obj) {
public void updateMeta(Session session, DbObject obj) {
lockMeta(session);
synchronized (this) {
int id = obj.getId();
removeMeta(session, id);
addMeta(session, obj);
......@@ -1642,6 +1643,7 @@ public class Database implements DataHandler {
objectIds.set(id);
}
}
}
/**
* Rename a schema object.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论