Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
9055002f
提交
9055002f
authored
9月 12, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More bugs in the server-less multi-connection mode have been fixed.
上级
a2ab67b9
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
46 行增加
和
24 行删除
+46
-24
changelog.html
h2/src/docsrc/html/changelog.html
+3
-1
Database.java
h2/src/main/org/h2/engine/Database.java
+14
-17
LogSystem.java
h2/src/main/org/h2/log/LogSystem.java
+5
-2
WriterThread.java
h2/src/main/org/h2/store/WriterThread.java
+2
-1
FileUtils.java
h2/src/main/org/h2/util/FileUtils.java
+22
-3
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
9055002f
...
...
@@ -18,7 +18,9 @@ Change Log
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
When loading triggers or other client classes
<ul><li>
More bugs in the server-less multi-connection mode have been fixed:
On Windows, two processes could write to the same database at the same time.
</li><li>
When loading triggers or other client classes
(static functions, database event listener, user aggregate functions, other JDBC drivers),
the database now uses the context class loader if the class could not be found using Class.forName().
</li><li>
Updating many rows with the same CLOB or BLOB values could result in FileNotFoundException.
...
...
h2/src/main/org/h2/engine/Database.java
浏览文件 @
9055002f
...
...
@@ -187,9 +187,6 @@ public class Database implements DataHandler {
accessModeLog
=
"r"
;
}
this
.
fileLockMethod
=
FileLock
.
getFileLockMethod
(
lockMethodName
);
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
)
{
writeDelay
=
SysProperties
.
MIN_WRITE_DELAY
;
}
this
.
databaseURL
=
ci
.
getURL
();
this
.
eventListener
=
ci
.
getDatabaseEventListenerObject
();
ci
.
removeDatabaseEventListenerObject
();
...
...
@@ -357,12 +354,15 @@ public class Database implements DataHandler {
}
String
pos
=
log
==
null
?
null
:
log
.
getWritePos
();
lock
.
setProperty
(
"logPos"
,
pos
);
lock
.
setProperty
(
"changePending"
,
pending
?
"true"
:
null
);
if
(
pending
)
{
lock
.
setProperty
(
"changePending"
,
"true-"
+
Math
.
random
());
}
else
{
lock
.
setProperty
(
"changePending"
,
null
);
}
// ensure that the writer thread will
// not reset the flag before we are done
reconnectCheckNext
=
System
.
currentTimeMillis
()
+
2
*
SysProperties
.
RECONNECT_CHECK_DELAY
;
old
=
lock
.
save
();
if
(
pending
)
{
getTrace
().
debug
(
"wait before writing again"
);
Thread
.
sleep
((
int
)
(
SysProperties
.
RECONNECT_CHECK_DELAY
*
1.1
));
...
...
@@ -1845,18 +1845,15 @@ public class Database implements DataHandler {
public
void
deleteLogFileLater
(
String
fileName
)
throws
SQLException
{
if
(
fileLockMethod
==
FileLock
.
LOCK_SERIALIZED
)
{
// need to truncate the file, because another process could keep it open
try
{
FileSystem
.
getInstance
(
fileName
).
openFileObject
(
fileName
,
"rw"
).
setFileLength
(
0
);
}
catch
(
IOException
e
)
{
throw
Message
.
convertIOException
(
e
,
"could not truncate "
+
fileName
);
}
}
FileUtils
.
setLength
(
fileName
,
0
);
}
else
{
if
(
writer
!=
null
)
{
writer
.
deleteLogFileLater
(
fileName
);
}
else
{
FileUtils
.
delete
(
fileName
);
}
}
}
public
void
setEventListener
(
DatabaseEventListener
eventListener
)
{
this
.
eventListener
=
eventListener
;
...
...
@@ -2341,9 +2338,9 @@ public class Database implements DataHandler {
if
(
fileLockMethod
!=
FileLock
.
LOCK_SERIALIZED
||
readOnly
||
!
reconnectChangePending
||
closing
)
{
return
;
}
synchronized
(
this
)
{
long
now
=
System
.
currentTimeMillis
();
if
(
now
>
reconnectCheckNext
+
SysProperties
.
RECONNECT_CHECK_DELAY
)
{
synchronized
(
this
)
{
getTrace
().
debug
(
"checkpoint"
);
flushIndexes
(
0
);
checkpoint
();
...
...
h2/src/main/org/h2/log/LogSystem.java
浏览文件 @
9055002f
...
...
@@ -301,8 +301,11 @@ public class LogSystem {
// this can happen if the system crashes just
// after creating a new file (before writing the header)
// rename it, so that it doesn't get in the way the next time
FileUtils
.
delete
(
s
+
".corrupt"
);
if
(
FileUtils
.
tryDelete
(
s
+
".corrupt"
))
{
FileUtils
.
rename
(
s
,
s
+
".corrupt"
);
}
else
{
FileUtils
.
setLength
(
s
,
0
);
}
}
if
(
l
!=
null
)
{
if
(
l
.
getPos
()
==
LOG_WRITTEN
)
{
...
...
h2/src/main/org/h2/store/WriterThread.java
浏览文件 @
9055002f
...
...
@@ -124,8 +124,10 @@ public class WriterThread implements Runnable {
flushIndexesIfRequired
(
database
);
}
int
wait
=
writeDelay
;
try
{
if
(
database
.
isFileLockSerialized
())
{
wait
=
SysProperties
.
MIN_WRITE_DELAY
;
database
.
checkpointIfRequired
();
}
else
{
LogSystem
log
=
database
.
getLog
();
...
...
@@ -143,7 +145,6 @@ public class WriterThread implements Runnable {
// TODO log writer: could also flush the dirty cache when there is
// low activity
int
wait
=
writeDelay
;
if
(
wait
<
SysProperties
.
MIN_WRITE_DELAY
)
{
// wait 0 mean wait forever, which is not what we want
wait
=
SysProperties
.
MIN_WRITE_DELAY
;
...
...
h2/src/main/org/h2/util/FileUtils.java
浏览文件 @
9055002f
...
...
@@ -14,6 +14,8 @@ import java.io.RandomAccessFile;
import
java.sql.SQLException
;
import
org.h2.constant.SysProperties
;
import
org.h2.message.Message
;
import
org.h2.store.fs.FileObject
;
import
org.h2.store.fs.FileSystem
;
/**
...
...
@@ -107,9 +109,10 @@ public class FileUtils {
* Try to delete a file.
*
* @param fileName the file name
* @return true if it worked
*/
public
static
void
tryDelete
(
String
fileName
)
{
FileSystem
.
getInstance
(
fileName
).
tryDelete
(
fileName
);
public
static
boolean
tryDelete
(
String
fileName
)
{
return
FileSystem
.
getInstance
(
fileName
).
tryDelete
(
fileName
);
}
/**
...
...
@@ -271,7 +274,7 @@ public class FileUtils {
}
/**
* Get the last modified date of a file
* Get the last modified date of a file
.
*
* @param fileName the file name
* @return the last modified date
...
...
@@ -280,4 +283,20 @@ public class FileUtils {
return
FileSystem
.
getInstance
(
fileName
).
getLastModified
(
fileName
);
}
/**
* Set the file length.
*
* @param fileName the file name
* @param length the new length
*/
public
static
void
setLength
(
String
fileName
,
long
length
)
throws
SQLException
{
try
{
FileObject
f
=
FileSystem
.
getInstance
(
fileName
).
openFileObject
(
fileName
,
"rw"
);
f
.
setFileLength
(
length
);
f
.
close
();
}
catch
(
IOException
e
)
{
throw
Message
.
convertIOException
(
e
,
fileName
+
" length: "
+
length
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论