提交 27d8e115 authored 作者: Thomas Mueller's avatar Thomas Mueller

Fixed a deadlock related to very large temporary result sets.

上级 11eed7a3
...@@ -155,20 +155,18 @@ public class ResultTempTable implements ResultExternal { ...@@ -155,20 +155,18 @@ public class ResultTempTable implements ResultExternal {
table.truncate(session); table.truncate(session);
Database database = session.getDatabase(); Database database = session.getDatabase();
synchronized (database) { synchronized (database) {
// This session may not lock the sys table (except if it already has locked it)
// because it must be committed immediately,
// otherwise other threads can not access the sys table.
// If the table is not removed now, it will be when the database
// is opened the next time.
// (the table is truncated, so this is just one record)
if (!database.isSysTableLocked()) { if (!database.isSysTableLocked()) {
Session sysSession = database.getSystemSession(); Session sysSession = database.getSystemSession();
// This session may not lock the sys table (except if it already has locked it) index.removeChildrenAndResources(sysSession);
// because it must be committed immediately, table.removeChildrenAndResources(sysSession);
// otherwise other threads can not access the sys table. // the transaction must be committed immediately
// If the table is not removed now, it will be when the database sysSession.commit(false);
// is opened the next time.
// (the table is truncated, so this is just one record)
synchronized (sysSession) {
index.removeChildrenAndResources(sysSession);
table.removeChildrenAndResources(sysSession);
// the transaction must be committed immediately
sysSession.commit(false);
}
} }
} }
} finally { } finally {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论