提交 05821d35 authored 作者: Noel Grandin's avatar Noel Grandin

Fix for issue #143, deadlock between two sessions hitting the same

sequence on a column
上级 137a50dc
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Fix for issue #143, deadlock between two sessions hitting the same sequence on a column
</li>
<li>Pull request #137: SourceCompiler should not throw a syntax error on javac warning. <li>Pull request #137: SourceCompiler should not throw a syntax error on javac warning.
</li> </li>
<li>MVStore: out of memory while storing could corrupt the store <li>MVStore: out of memory while storing could corrupt the store
......
...@@ -266,13 +266,16 @@ public class Column { ...@@ -266,13 +266,16 @@ public class Column {
* @return the new or converted value * @return the new or converted value
*/ */
public Value validateConvertUpdateSequence(Session session, Value value) { public Value validateConvertUpdateSequence(Session session, Value value) {
// take a local copy of defaultExpression to avoid holding the lock while calling getValue
final Expression localDefaultExpression;
synchronized (this) {
localDefaultExpression = defaultExpression;
}
if (value == null) { if (value == null) {
if (defaultExpression == null) { if (localDefaultExpression == null) {
value = ValueNull.INSTANCE; value = ValueNull.INSTANCE;
} else { } else {
synchronized (this) { value = localDefaultExpression.getValue(session).convertTo(type);
value = defaultExpression.getValue(session).convertTo(type);
}
if (primaryKey) { if (primaryKey) {
session.setLastIdentity(value); session.setLastIdentity(value);
} }
...@@ -281,9 +284,7 @@ public class Column { ...@@ -281,9 +284,7 @@ public class Column {
Mode mode = session.getDatabase().getMode(); Mode mode = session.getDatabase().getMode();
if (value == ValueNull.INSTANCE) { if (value == ValueNull.INSTANCE) {
if (convertNullToDefault) { if (convertNullToDefault) {
synchronized (this) { value = localDefaultExpression.getValue(session).convertTo(type);
value = defaultExpression.getValue(session).convertTo(type);
}
} }
if (value == ValueNull.INSTANCE && !nullable) { if (value == ValueNull.INSTANCE && !nullable) {
if (mode.convertInsertNullToZero) { if (mode.convertInsertNullToZero) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论