Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
45fff147
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
45fff147
编写于
12月 26, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19097 from taosdata/fix/TD-21451
fix(tdb/restore): seek jfd to begin
上级
db859aaf
c4f40874
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
5 deletion
+25
-5
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+23
-3
source/libs/tdb/src/db/tdbTable.c
source/libs/tdb/src/db/tdbTable.c
+2
-2
未找到文件。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
45fff147
...
...
@@ -869,11 +869,19 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
}
if
(
tdbOsLSeek
(
jfd
,
0L
,
SEEK_SET
)
<
0
)
{
tdbError
(
"failed to lseek jfd due to %s. file:%s, offset:0"
,
strerror
(
errno
),
pPager
->
dbFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
}
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
if
(
pageBuf
==
NULL
)
{
return
-
1
;
}
tdbDebug
(
"pager/restore: %p, %d/%d, txnId:%s"
,
pPager
,
pPager
->
dbOrigSize
,
pPager
->
dbFileSize
,
jFileName
);
for
(
int
pgIndex
=
0
;
pgIndex
<
journalSize
;
++
pgIndex
)
{
// read pgno & the page from journal
SPgno
pgno
;
...
...
@@ -884,6 +892,8 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
}
tdbTrace
(
"pager/restore: restore pgno:%d,"
,
pgno
);
ret
=
tdbOsRead
(
jfd
,
pageBuf
,
pPager
->
pageSize
);
if
(
ret
<
0
)
{
tdbOsFree
(
pageBuf
);
...
...
@@ -923,7 +933,7 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) {
return
-
1
;
}
if
(
tdbOsRemove
(
pPager
->
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
if
(
tdbOsRemove
(
jFileName
)
<
0
&&
errno
!=
ENOENT
)
{
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
pPager
->
jFileName
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
...
...
@@ -943,7 +953,12 @@ int tdbPagerRestoreJournals(SPager *pPager) {
while
((
pDirEntry
=
tdbReadDir
(
pDir
))
!=
NULL
)
{
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
tdbPagerRestore
(
pPager
,
name
)
<
0
)
{
char
jname
[
TD_PATH_MAX
]
=
{
0
};
int
dirLen
=
strlen
(
pPager
->
pEnv
->
dbName
);
memcpy
(
jname
,
pPager
->
pEnv
->
dbName
,
dirLen
);
jname
[
dirLen
]
=
'/'
;
memcpy
(
jname
+
dirLen
+
1
,
name
,
strlen
(
name
));
if
(
tdbPagerRestore
(
pPager
,
jname
)
<
0
)
{
tdbCloseDir
(
&
pDir
);
tdbError
(
"failed to restore file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
...
...
@@ -969,7 +984,12 @@ int tdbPagerRollback(SPager *pPager) {
char
*
name
=
tdbDirEntryBaseName
(
tdbGetDirEntryName
(
pDirEntry
));
if
(
strncmp
(
TDB_MAINDB_NAME
"-journal"
,
name
,
16
)
==
0
)
{
if
(
tdbOsRemove
(
name
)
<
0
&&
errno
!=
ENOENT
)
{
char
jname
[
TD_PATH_MAX
]
=
{
0
};
int
dirLen
=
strlen
(
pPager
->
pEnv
->
dbName
);
memcpy
(
jname
,
pPager
->
pEnv
->
dbName
,
dirLen
);
jname
[
dirLen
]
=
'/'
;
memcpy
(
jname
+
dirLen
+
1
,
name
,
strlen
(
name
));
if
(
tdbOsRemove
(
jname
)
<
0
&&
errno
!=
ENOENT
)
{
tdbCloseDir
(
&
pDir
);
tdbError
(
"failed to remove file due to %s. jFileName:%s"
,
strerror
(
errno
),
name
);
...
...
source/libs/tdb/src/db/tdbTable.c
浏览文件 @
45fff147
...
...
@@ -108,13 +108,13 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
ASSERT
(
pPager
!=
NULL
);
if
(
rollback
)
{
tdbPagerRollback
(
pPager
);
}
else
{
ret
=
tdbPagerRestoreJournals
(
pPager
);
if
(
ret
<
0
)
{
tdbOsFree
(
pTb
);
return
-
1
;
}
}
else
{
tdbPagerRollback
(
pPager
);
}
// pTb->pBt
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录