提交 64fd3170 authored 作者: Andrei Tokar's avatar Andrei Tokar

prevent any session state transition away from CLOSE

上级 bbac6fdb
......@@ -1226,14 +1226,16 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
return;
}
State prevState = this.state.get();
lastThrottle = time + throttleNs;
try {
state.set(State.SLEEP);
Thread.sleep(TimeUnit.NANOSECONDS.toMillis(throttleNs));
} catch (Exception e) {
// ignore InterruptedException
} finally {
state.set(prevState);
if (prevState != State.CLOSED) {
lastThrottle = time + throttleNs;
try {
state.compareAndSet(prevState, State.SLEEP);
Thread.sleep(TimeUnit.NANOSECONDS.toMillis(throttleNs));
} catch (Exception e) {
// ignore InterruptedException
} finally {
state.compareAndSet(State.SLEEP, prevState);
}
}
}
......@@ -1250,7 +1252,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
* from
*/
public void setCurrentCommand(Command command, Object generatedKeysRequest) {
this.currentCommand = command;
currentCommand = command;
// Preserve generated keys in case of a new query due to possible nested
// queries in update
if (command != null && !command.isQuery()) {
......@@ -1265,7 +1267,10 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
currentCommandStart = null;
}
}
state.set(command == null ? State.SLEEP : State.RUNNING);
State currentState = state.get();
if(currentState != State.CLOSED) {
state.compareAndSet(currentState, command == null ? State.SLEEP : State.RUNNING);
}
}
/**
......
......@@ -45,7 +45,7 @@ public class TestKillRestart extends TestDb {
String user = getUser(), password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = { getJVM(), selfDestruct,
"-cp", getClassPath(),
"-cp", getClassPath(), "-ea",
getClass().getName(), "-url", url, "-user", user,
"-password", password };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论