Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
8e2b0b24
提交
8e2b0b24
authored
9月 06, 2016
作者:
Nick
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Synchronized on database when remove from lockSharedSessions, add test
上级
d78c3fbe
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
99 行增加
和
11 行删除
+99
-11
Session.java
h2/src/main/org/h2/engine/Session.java
+5
-7
RegularTable.java
h2/src/main/org/h2/table/RegularTable.java
+3
-3
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+6
-1
TestBase.java
h2/src/test/org/h2/test/TestBase.java
+5
-0
TestReleaseSelectLock.java
h2/src/test/org/h2/test/synth/TestReleaseSelectLock.java
+80
-0
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
8e2b0b24
...
@@ -923,7 +923,6 @@ public class Session extends SessionWithState {
...
@@ -923,7 +923,6 @@ public class Session extends SessionWithState {
}
}
}
}
if
(
locks
.
size
()
>
0
)
{
if
(
locks
.
size
()
>
0
)
{
synchronized
(
database
)
{
// don't use the enhanced for loop to save memory
// don't use the enhanced for loop to save memory
for
(
int
i
=
0
,
size
=
locks
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
locks
.
size
();
i
<
size
;
i
++)
{
Table
t
=
locks
.
get
(
i
);
Table
t
=
locks
.
get
(
i
);
...
@@ -931,7 +930,6 @@ public class Session extends SessionWithState {
...
@@ -931,7 +930,6 @@ public class Session extends SessionWithState {
}
}
locks
.
clear
();
locks
.
clear
();
}
}
}
savepoints
=
null
;
savepoints
=
null
;
sessionStateChanged
=
true
;
sessionStateChanged
=
true
;
}
}
...
...
h2/src/main/org/h2/table/RegularTable.java
浏览文件 @
8e2b0b24
...
@@ -670,10 +670,10 @@ public class RegularTable extends TableBase {
...
@@ -670,10 +670,10 @@ public class RegularTable extends TableBase {
if
(
lockExclusiveSession
==
s
)
{
if
(
lockExclusiveSession
==
s
)
{
lockExclusiveSession
=
null
;
lockExclusiveSession
=
null
;
}
}
synchronized
(
database
)
{
if
(
lockSharedSessions
.
size
()
>
0
)
{
if
(
lockSharedSessions
.
size
()
>
0
)
{
lockSharedSessions
.
remove
(
s
);
lockSharedSessions
.
remove
(
s
);
}
}
synchronized
(
database
)
{
if
(!
waitingSessions
.
isEmpty
())
{
if
(!
waitingSessions
.
isEmpty
())
{
database
.
notifyAll
();
database
.
notifyAll
();
}
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
8e2b0b24
...
@@ -266,7 +266,7 @@ java org.h2.test.TestAll timer
...
@@ -266,7 +266,7 @@ java org.h2.test.TestAll timer
/**
/**
* Whether the MVStore storage is used.
* Whether the MVStore storage is used.
*/
*/
public
final
boolean
mvStore
=
Constants
.
VERSION_MINOR
>=
4
;
public
boolean
mvStore
=
Constants
.
VERSION_MINOR
>=
4
;
/**
/**
* If the test should run with many rows.
* If the test should run with many rows.
...
@@ -298,6 +298,11 @@ java org.h2.test.TestAll timer
...
@@ -298,6 +298,11 @@ java org.h2.test.TestAll timer
*/
*/
public
boolean
mvcc
=
mvStore
;
public
boolean
mvcc
=
mvStore
;
/**
* If the multi-threaded mode should be used.
*/
public
boolean
multiThreaded
;
/**
/**
* The cipher to use (null for unencrypted).
* The cipher to use (null for unencrypted).
*/
*/
...
...
h2/src/test/org/h2/test/TestBase.java
浏览文件 @
8e2b0b24
...
@@ -280,6 +280,8 @@ public abstract class TestBase {
...
@@ -280,6 +280,8 @@ public abstract class TestBase {
if
(
config
.
mvStore
)
{
if
(
config
.
mvStore
)
{
url
=
addOption
(
url
,
"MV_STORE"
,
"true"
);
url
=
addOption
(
url
,
"MV_STORE"
,
"true"
);
// url = addOption(url, "MVCC", "true");
// url = addOption(url, "MVCC", "true");
}
else
{
url
=
addOption
(
url
,
"MV_STORE"
,
"false"
);
}
}
if
(!
config
.
memory
)
{
if
(!
config
.
memory
)
{
if
(
config
.
smallLog
&&
admin
)
{
if
(
config
.
smallLog
&&
admin
)
{
...
@@ -310,6 +312,9 @@ public abstract class TestBase {
...
@@ -310,6 +312,9 @@ public abstract class TestBase {
if
(
config
.
mvcc
)
{
if
(
config
.
mvcc
)
{
url
=
addOption
(
url
,
"MVCC"
,
"TRUE"
);
url
=
addOption
(
url
,
"MVCC"
,
"TRUE"
);
}
}
if
(
config
.
multiThreaded
)
{
url
=
addOption
(
url
,
"MULTI_THREADED"
,
"TRUE"
);
}
if
(
config
.
cacheType
!=
null
&&
admin
)
{
if
(
config
.
cacheType
!=
null
&&
admin
)
{
url
=
addOption
(
url
,
"CACHE_TYPE"
,
config
.
cacheType
);
url
=
addOption
(
url
,
"CACHE_TYPE"
,
config
.
cacheType
);
}
}
...
...
h2/src/test/org/h2/test/synth/TestReleaseSelectLock.java
0 → 100644
浏览文件 @
8e2b0b24
package
org
.
h2
.
test
.
synth
;
import
org.h2.test.TestBase
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
import
java.util.concurrent.CountDownLatch
;
/**
* Tests lock releasing for concurrent select statements
*/
public
class
TestReleaseSelectLock
extends
TestBase
{
private
static
final
String
TEST_DB_NAME
=
"releaseSelectLock"
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
void
test
()
throws
Exception
{
config
.
mvStore
=
false
;
config
.
mvcc
=
false
;
config
.
multiThreaded
=
true
;
deleteDb
(
TEST_DB_NAME
);
Connection
conn
=
getConnection
(
TEST_DB_NAME
);
final
Statement
statement
=
conn
.
createStatement
();
statement
.
execute
(
"create table test(id int primary key)"
);
runConcurrentSelects
();
// check that all locks have been released by dropping the test table
statement
.
execute
(
"drop table test"
);
statement
.
close
();
conn
.
close
();
deleteDb
(
TEST_DB_NAME
);
}
private
void
runConcurrentSelects
()
throws
InterruptedException
{
int
tryCount
=
500
;
int
threadsCount
=
getSize
(
2
,
4
);
for
(
int
tryNumber
=
0
;
tryNumber
<
tryCount
;
tryNumber
++)
{
final
CountDownLatch
allFinished
=
new
CountDownLatch
(
threadsCount
);
for
(
int
i
=
0
;
i
<
threadsCount
;
i
++)
{
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Connection
conn
=
getConnection
(
TEST_DB_NAME
);
PreparedStatement
stmt
=
conn
.
prepareStatement
(
"select id from test"
);
ResultSet
rs
=
stmt
.
executeQuery
();
while
(
rs
.
next
())
{
rs
.
getInt
(
1
);
}
stmt
.
close
();
conn
.
close
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
allFinished
.
countDown
();
}
}
}).
start
();
}
allFinished
.
await
();
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论