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