Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
c1608d05
Unverified
提交
c1608d05
authored
12月 25, 2018
作者:
Andrei Tokar
提交者:
GitHub
12月 25, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1621 from h2database/issue_1619
Issue for #1619: postpone table analysis until after transaction commit
上级
8661c79f
9f72cef6
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
79 行增加
和
11 行删除
+79
-11
Session.java
h2/src/main/org/h2/engine/Session.java
+20
-10
Transaction.java
h2/src/main/org/h2/mvstore/tx/Transaction.java
+1
-1
TestAll.java
h2/src/test/org/h2/test/TestAll.java
+2
-0
TestAnalyzeTableTx.java
h2/src/test/org/h2/test/db/TestAnalyzeTableTx.java
+56
-0
没有找到文件。
h2/src/main/org/h2/engine/Session.java
浏览文件 @
c1608d05
...
@@ -670,16 +670,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -670,16 +670,6 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
public
void
commit
(
boolean
ddl
)
{
public
void
commit
(
boolean
ddl
)
{
checkCommitRollback
();
checkCommitRollback
();
int
rowCount
=
getDatabase
().
getSettings
().
analyzeSample
/
10
;
if
(
tablesToAnalyze
!=
null
)
{
for
(
Table
table
:
tablesToAnalyze
)
{
Analyze
.
analyzeTable
(
this
,
table
,
rowCount
,
false
);
}
// analyze can lock the meta
database
.
unlockMeta
(
this
);
}
tablesToAnalyze
=
null
;
currentTransactionName
=
null
;
currentTransactionName
=
null
;
transactionStart
=
null
;
transactionStart
=
null
;
if
(
transaction
!=
null
)
{
if
(
transaction
!=
null
)
{
...
@@ -717,9 +707,29 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
...
@@ -717,9 +707,29 @@ public class Session extends SessionWithState implements TransactionStore.Rollba
}
}
}
}
if
(
tablesToAnalyze
!=
null
)
{
if
(
database
.
isMVStore
())
{
// table analysis will cause a new transaction(s) to be opened,
// so we need to commit afterwards whatever leftovers might be
analyzeTables
();
commit
(
true
);
}
else
{
analyzeTables
();
}
}
endTransaction
();
endTransaction
();
}
}
private
void
analyzeTables
()
{
int
rowCount
=
getDatabase
().
getSettings
().
analyzeSample
/
10
;
for
(
Table
table
:
tablesToAnalyze
)
{
Analyze
.
analyzeTable
(
this
,
table
,
rowCount
,
false
);
}
// analyze can lock the meta
database
.
unlockMeta
(
this
);
tablesToAnalyze
=
null
;
}
private
void
removeTemporaryLobs
(
boolean
onTimeout
)
{
private
void
removeTemporaryLobs
(
boolean
onTimeout
)
{
assert
this
!=
getDatabase
().
getLobSession
()
||
Thread
.
holdsLock
(
this
)
||
Thread
.
holdsLock
(
getDatabase
());
assert
this
!=
getDatabase
().
getLobSession
()
||
Thread
.
holdsLock
(
this
)
||
Thread
.
holdsLock
(
getDatabase
());
if
(
temporaryLobs
!=
null
)
{
if
(
temporaryLobs
!=
null
)
{
...
...
h2/src/main/org/h2/mvstore/tx/Transaction.java
浏览文件 @
c1608d05
...
@@ -456,7 +456,7 @@ public class Transaction {
...
@@ -456,7 +456,7 @@ public class Transaction {
if
(
status
!=
STATUS_OPEN
)
{
if
(
status
!=
STATUS_OPEN
)
{
throw
DataUtils
.
newIllegalStateException
(
throw
DataUtils
.
newIllegalStateException
(
DataUtils
.
ERROR_TRANSACTION_ILLEGAL_STATE
,
DataUtils
.
ERROR_TRANSACTION_ILLEGAL_STATE
,
"Transaction {0} has status {1}, not
open"
,
transactionId
,
status
);
"Transaction {0} has status {1}, not
OPEN"
,
transactionId
,
STATUS_NAMES
[
status
]
);
}
}
}
}
...
...
h2/src/test/org/h2/test/TestAll.java
浏览文件 @
c1608d05
...
@@ -21,6 +21,7 @@ import org.h2.test.auth.TestAuthentication;
...
@@ -21,6 +21,7 @@ import org.h2.test.auth.TestAuthentication;
import
org.h2.test.bench.TestPerformance
;
import
org.h2.test.bench.TestPerformance
;
import
org.h2.test.db.TestAlter
;
import
org.h2.test.db.TestAlter
;
import
org.h2.test.db.TestAlterSchemaRename
;
import
org.h2.test.db.TestAlterSchemaRename
;
import
org.h2.test.db.TestAnalyzeTableTx
;
import
org.h2.test.db.TestAutoRecompile
;
import
org.h2.test.db.TestAutoRecompile
;
import
org.h2.test.db.TestBackup
;
import
org.h2.test.db.TestBackup
;
import
org.h2.test.db.TestBigDb
;
import
org.h2.test.db.TestBigDb
;
...
@@ -845,6 +846,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
...
@@ -845,6 +846,7 @@ kill -9 `jps -l | grep "org.h2.test." | cut -d " " -f 1`
addTest
(
new
TestMvccMultiThreaded
());
addTest
(
new
TestMvccMultiThreaded
());
addTest
(
new
TestMvccMultiThreaded2
());
addTest
(
new
TestMvccMultiThreaded2
());
addTest
(
new
TestRowLocks
());
addTest
(
new
TestRowLocks
());
addTest
(
new
TestAnalyzeTableTx
());
// synth
// synth
addTest
(
new
TestBtreeIndex
());
addTest
(
new
TestBtreeIndex
());
...
...
h2/src/test/org/h2/test/db/TestAnalyzeTableTx.java
0 → 100644
浏览文件 @
c1608d05
/*
* Copyright 2004-2017 H2 Group. Multiple-Licensed under the MPL 2.0,
* and the EPL 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
test
.
db
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestDb
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.Statement
;
public
class
TestAnalyzeTableTx
extends
TestDb
{
static
final
int
C
=
10_000
;
/**
* Run just this test.
*
* @param a ignored
*/
public
static
void
main
(
String
...
a
)
throws
Exception
{
TestBase
.
createCaller
().
init
().
test
();
}
@Override
public
boolean
isEnabled
()
{
if
(
config
.
networked
||
config
.
big
)
{
return
false
;
}
return
true
;
}
@Override
public
void
test
()
throws
Exception
{
deleteDb
(
getTestName
());
Connection
shared
=
getConnection
(
getTestName
());
Statement
statement
=
shared
.
createStatement
();
statement
.
executeUpdate
(
"DROP TABLE IF EXISTS TEST"
);
statement
.
executeUpdate
(
"CREATE TABLE TEST(ID INT PRIMARY KEY)"
);
Connection
[]
connections
=
new
Connection
[
C
];
for
(
int
i
=
0
;
i
<
C
;
i
++)
{
Connection
c
=
getConnection
(
getTestName
());
c
.
createStatement
().
executeUpdate
(
"INSERT INTO TEST VALUES ("
+
i
+
')'
);
connections
[
i
]
=
c
;
}
try
(
ResultSet
rs
=
statement
.
executeQuery
(
"SELECT * FROM TEST"
))
{
for
(
int
i
=
0
;
i
<
C
;
i
++)
{
if
(!
rs
.
next
())
throw
new
Exception
(
"next"
);
if
(
rs
.
getInt
(
1
)
!=
i
)
throw
new
Exception
(
Integer
.
toString
(
i
));
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论