Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
d5c9eff7
Unverified
提交
d5c9eff7
authored
6 年前
作者:
Andrei Tokar
提交者:
GitHub
6 年前
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1700 from h2database/double-commit
Double commit in TestKillRestartMulti
上级
f12addc2
64fd3170
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
30 行增加
和
44 行删除
+30
-44
Database.java
h2/src/main/org/h2/engine/Database.java
+1
-4
Session.java
h2/src/main/org/h2/engine/Session.java
+26
-25
TcpServerThread.java
h2/src/main/org/h2/server/TcpServerThread.java
+2
-14
TestKillRestart.java
h2/src/test/org/h2/test/synth/TestKillRestart.java
+1
-1
没有找到文件。
h2/src/main/org/h2/engine/Database.java
浏览文件 @
d5c9eff7
...
@@ -1393,10 +1393,7 @@ public class Database implements DataHandler {
...
@@ -1393,10 +1393,7 @@ public class Database implements DataHandler {
for
(
Session
s
:
all
)
{
for
(
Session
s
:
all
)
{
if
(
s
!=
except
)
{
if
(
s
!=
except
)
{
try
{
try
{
// must roll back, otherwise the session is removed and
// this will rollback outstanding transaction
// the transaction log that contains its uncommitted
// operations as well
s
.
rollback
();
s
.
close
();
s
.
close
();
}
catch
(
DbException
e
)
{
}
catch
(
DbException
e
)
{
trace
.
error
(
e
,
"disconnecting session #{0}"
,
s
.
getId
());
trace
.
error
(
e
,
"disconnecting session #{0}"
,
s
.
getId
());
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
d5c9eff7
...
@@ -15,6 +15,7 @@ import java.util.LinkedList;
...
@@ -15,6 +15,7 @@ import java.util.LinkedList;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.Random
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicReference
;
import
org.h2.api.ErrorCode
;
import
org.h2.api.ErrorCode
;
import
org.h2.command.Command
;
import
org.h2.command.Command
;
import
org.h2.command.CommandInterface
;
import
org.h2.command.CommandInterface
;
...
@@ -114,7 +115,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -114,7 +115,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
private
boolean
autoCommitAtTransactionEnd
;
private
boolean
autoCommitAtTransactionEnd
;
private
String
currentTransactionName
;
private
String
currentTransactionName
;
private
volatile
long
cancelAtNs
;
private
volatile
long
cancelAtNs
;
private
boolean
closed
;
private
final
long
sessionStart
=
System
.
currentTimeMillis
();
private
final
long
sessionStart
=
System
.
currentTimeMillis
();
private
ValueTimestampTimeZone
transactionStart
;
private
ValueTimestampTimeZone
transactionStart
;
private
ValueTimestampTimeZone
currentCommandStart
;
private
ValueTimestampTimeZone
currentCommandStart
;
...
@@ -160,7 +160,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -160,7 +160,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
private
ArrayList
<
Value
>
temporaryLobs
;
private
ArrayList
<
Value
>
temporaryLobs
;
private
Transaction
transaction
;
private
Transaction
transaction
;
private
State
state
=
State
.
INIT
;
private
final
AtomicReference
<
State
>
state
=
new
AtomicReference
<>(
State
.
INIT
)
;
private
long
startStatement
=
-
1
;
private
long
startStatement
=
-
1
;
/**
/**
...
@@ -598,7 +598,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -598,7 +598,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
* @return the prepared statement
* @return the prepared statement
*/
*/
public
Command
prepareLocal
(
String
sql
)
{
public
Command
prepareLocal
(
String
sql
)
{
if
(
closed
)
{
if
(
isClosed
()
)
{
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
throw
DbException
.
get
(
ErrorCode
.
CONNECTION_BROKEN_1
,
"session closed"
);
"session closed"
);
}
}
...
@@ -879,8 +879,9 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -879,8 +879,9 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
@Override
@Override
public
void
close
()
{
public
void
close
()
{
if
(!
closed
)
{
// this is the only operation that can be invoked concurrently
state
=
State
.
CLOSED
;
// so, we should prevent double-closure
if
(
state
.
getAndSet
(
State
.
CLOSED
)
!=
State
.
CLOSED
)
{
try
{
try
{
database
.
checkPowerOff
();
database
.
checkPowerOff
();
...
@@ -898,7 +899,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -898,7 +899,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
// want to take the meta lock using the system session.
// want to take the meta lock using the system session.
database
.
unlockMeta
(
this
);
database
.
unlockMeta
(
this
);
}
finally
{
}
finally
{
closed
=
true
;
database
.
removeSession
(
this
);
database
.
removeSession
(
this
);
}
}
}
}
...
@@ -1038,11 +1038,11 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -1038,11 +1038,11 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
@Override
@Override
public
Trace
getTrace
()
{
public
Trace
getTrace
()
{
if
(
trace
!=
null
&&
!
closed
)
{
if
(
trace
!=
null
&&
!
isClosed
()
)
{
return
trace
;
return
trace
;
}
}
String
traceModuleName
=
"jdbc["
+
id
+
"]"
;
String
traceModuleName
=
"jdbc["
+
id
+
"]"
;
if
(
closed
)
{
if
(
isClosed
()
)
{
return
new
TraceSystem
(
null
).
getTrace
(
traceModuleName
);
return
new
TraceSystem
(
null
).
getTrace
(
traceModuleName
);
}
}
trace
=
database
.
getTraceSystem
().
getTrace
(
traceModuleName
);
trace
=
database
.
getTraceSystem
().
getTrace
(
traceModuleName
);
...
@@ -1204,7 +1204,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -1204,7 +1204,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
@Override
@Override
public
boolean
isClosed
()
{
public
boolean
isClosed
()
{
return
closed
;
return
state
.
get
()
==
State
.
CLOSED
;
}
}
public
void
setThrottle
(
int
throttle
)
{
public
void
setThrottle
(
int
throttle
)
{
...
@@ -1225,15 +1225,17 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -1225,15 +1225,17 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
if
(
lastThrottle
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
Constants
.
THROTTLE_DELAY
)
>
time
)
{
if
(
lastThrottle
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
Constants
.
THROTTLE_DELAY
)
>
time
)
{
return
;
return
;
}
}
State
prevState
=
this
.
state
;
State
prevState
=
this
.
state
.
get
();
lastThrottle
=
time
+
throttleNs
;
if
(
prevState
!=
State
.
CLOSED
)
{
try
{
lastThrottle
=
time
+
throttleNs
;
this
.
state
=
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
this
.
state
=
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
=
command
==
null
?
State
.
SLEEP
:
State
.
RUNNING
;
State
currentState
=
state
.
get
();
if
(
currentState
!=
State
.
CLOSED
)
{
state
.
compareAndSet
(
currentState
,
command
==
null
?
State
.
SLEEP
:
State
.
RUNNING
);
}
}
}
/**
/**
...
@@ -1782,11 +1787,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -1782,11 +1787,7 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
}
}
public
State
getState
()
{
public
State
getState
()
{
return
getBlockingSessionId
()
!=
0
?
State
.
BLOCKED
:
state
;
return
getBlockingSessionId
()
!=
0
?
State
.
BLOCKED
:
state
.
get
();
}
public
void
setState
(
State
state
)
{
this
.
state
=
state
;
}
}
public
int
getBlockingSessionId
()
{
public
int
getBlockingSessionId
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/server/TcpServerThread.java
浏览文件 @
d5c9eff7
...
@@ -183,23 +183,12 @@ public class TcpServerThread implements Runnable {
...
@@ -183,23 +183,12 @@ public class TcpServerThread implements Runnable {
private
void
closeSession
()
{
private
void
closeSession
()
{
if
(
session
!=
null
)
{
if
(
session
!=
null
)
{
RuntimeException
closeError
=
null
;
RuntimeException
closeError
=
null
;
try
{
Command
rollback
=
session
.
prepareLocal
(
"ROLLBACK"
);
rollback
.
executeUpdate
(
false
);
}
catch
(
RuntimeException
e
)
{
closeError
=
e
;
server
.
traceError
(
e
);
}
catch
(
Exception
e
)
{
server
.
traceError
(
e
);
}
try
{
try
{
session
.
close
();
session
.
close
();
server
.
removeConnection
(
threadId
);
server
.
removeConnection
(
threadId
);
}
catch
(
RuntimeException
e
)
{
}
catch
(
RuntimeException
e
)
{
if
(
closeError
==
null
)
{
closeError
=
e
;
closeError
=
e
;
server
.
traceError
(
e
);
server
.
traceError
(
e
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
server
.
traceError
(
e
);
server
.
traceError
(
e
);
}
finally
{
}
finally
{
...
@@ -544,7 +533,6 @@ public class TcpServerThread implements Runnable {
...
@@ -544,7 +533,6 @@ public class TcpServerThread implements Runnable {
}
}
default
:
default
:
trace
(
"Unknown operation: "
+
operation
);
trace
(
"Unknown operation: "
+
operation
);
closeSession
();
close
();
close
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/synth/TestKillRestart.java
浏览文件 @
d5c9eff7
...
@@ -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
};
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论