提交 245ea350 authored 作者: Andrei Tokar's avatar Andrei Tokar

Revert to Command execution at least under a session lock

上级 a7b3ee6e
...@@ -185,7 +185,7 @@ public abstract class Command implements CommandInterface { ...@@ -185,7 +185,7 @@ public abstract class Command implements CommandInterface {
startTimeNanos = 0; startTimeNanos = 0;
long start = 0; long start = 0;
Database database = session.getDatabase(); Database database = session.getDatabase();
Object sync = database.getMvStore() != null ? null : database.isMultiThreaded() ? session : database; Object sync = database.isMultiThreaded() || database.getMvStore() != null ? session : database;
session.waitIfExclusiveModeEnabled(); session.waitIfExclusiveModeEnabled();
boolean callStop = true; boolean callStop = true;
boolean writing = !isReadOnly(); boolean writing = !isReadOnly();
...@@ -201,14 +201,10 @@ public abstract class Command implements CommandInterface { ...@@ -201,14 +201,10 @@ public abstract class Command implements CommandInterface {
database.checkPowerOff(); database.checkPowerOff();
try { try {
ResultInterface result; ResultInterface result;
if (sync != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter //noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (sync) { synchronized (sync) {
result = query(maxrows); result = query(maxrows);
} }
} else {
result = query(maxrows);
}
callStop = !result.isLazy(); callStop = !result.isLazy();
return result; return result;
} catch (DbException e) { } catch (DbException e) {
...@@ -250,7 +246,7 @@ public abstract class Command implements CommandInterface { ...@@ -250,7 +246,7 @@ public abstract class Command implements CommandInterface {
public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest) { public ResultWithGeneratedKeys executeUpdate(Object generatedKeysRequest) {
long start = 0; long start = 0;
Database database = session.getDatabase(); Database database = session.getDatabase();
Object sync = database.getMvStore() != null ? null : database.isMultiThreaded() ? session : database; Object sync = database.isMultiThreaded() || database.getMvStore() != null ? session : database;
session.waitIfExclusiveModeEnabled(); session.waitIfExclusiveModeEnabled();
boolean callStop = true; boolean callStop = true;
boolean writing = !isReadOnly(); boolean writing = !isReadOnly();
...@@ -267,14 +263,10 @@ public abstract class Command implements CommandInterface { ...@@ -267,14 +263,10 @@ public abstract class Command implements CommandInterface {
database.checkPowerOff(); database.checkPowerOff();
try { try {
int updateCount; int updateCount;
if (sync != null) {
//noinspection SynchronizationOnLocalVariableOrMethodParameter //noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (sync) { synchronized (sync) {
updateCount = update(); updateCount = update();
} }
} else {
updateCount = update();
}
if (!Boolean.FALSE.equals(generatedKeysRequest)) { if (!Boolean.FALSE.equals(generatedKeysRequest)) {
return new ResultWithGeneratedKeys.WithKeys(updateCount, return new ResultWithGeneratedKeys.WithKeys(updateCount,
session.getGeneratedKeys().getKeys(session)); session.getGeneratedKeys().getKeys(session));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论