Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8fee813d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8fee813d
编写于
6月 13, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tdb/alloc-page: new param pTxn to fix memory leaking
上级
621d4b20
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
11 deletion
+19
-11
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+16
-8
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+3
-3
未找到文件。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
8fee813d
...
@@ -338,10 +338,13 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
...
@@ -338,10 +338,13 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
if
(
pTxn
->
jPageSet
)
{
if
(
pTxn
->
jPageSet
)
{
hashset_remove
(
pTxn
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_remove
(
pTxn
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
}
}
tdbTrace
(
"tdb/pager-commit: remove page: %p %d from dirty tree: %p"
,
pPage
,
TDB_PAGE_PGNO
(
pPage
),
&
pPager
->
rbt
);
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
}
}
tdbTrace
(
"
pager/
commit reset dirty tree: %p"
,
&
pPager
->
rbt
);
tdbTrace
(
"
tdb/pager-
commit reset dirty tree: %p"
,
&
pPager
->
rbt
);
tRBTreeCreate
(
&
pPager
->
rbt
,
pageCmpFn
);
tRBTreeCreate
(
&
pPager
->
rbt
,
pageCmpFn
);
// sync the db file
// sync the db file
...
@@ -629,6 +632,8 @@ int tdbPagerFlushPage(SPager *pPager, TXN *pTxn) {
...
@@ -629,6 +632,8 @@ int tdbPagerFlushPage(SPager *pPager, TXN *pTxn) {
return
0
;
return
0
;
}
}
static
int
tdbPagerAllocPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
TXN
*
pTxn
);
int
tdbPagerFetchPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
,
int
),
void
*
arg
,
int
tdbPagerFetchPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
,
int
),
void
*
arg
,
TXN
*
pTxn
)
{
TXN
*
pTxn
)
{
SPage
*
pPage
;
SPage
*
pPage
;
...
@@ -643,7 +648,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPa
...
@@ -643,7 +648,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPa
// alloc new page
// alloc new page
if
(
pgno
==
0
)
{
if
(
pgno
==
0
)
{
loadPage
=
0
;
loadPage
=
0
;
ret
=
tdbPagerAllocPage
(
pPager
,
&
pgno
);
ret
=
tdbPagerAllocPage
(
pPager
,
&
pgno
,
pTxn
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
tdbError
(
"tdb/pager: %p, ret: %d pgno: %"
PRIu32
", alloc page failed."
,
pPager
,
ret
,
pgno
);
tdbError
(
"tdb/pager: %p, ret: %d pgno: %"
PRIu32
", alloc page failed."
,
pPager
,
ret
,
pgno
);
return
-
1
;
return
-
1
;
...
@@ -706,7 +711,7 @@ int tdbPagerInsertFreePage(SPager *pPager, SPgno pgno, TXN *pTxn) {
...
@@ -706,7 +711,7 @@ int tdbPagerInsertFreePage(SPager *pPager, SPgno pgno, TXN *pTxn) {
return
code
;
return
code
;
}
}
static
int
tdbPagerRemoveFreePage
(
SPager
*
pPager
,
SPgno
*
pPgno
)
{
static
int
tdbPagerRemoveFreePage
(
SPager
*
pPager
,
SPgno
*
pPgno
,
TXN
*
pTxn
)
{
int
code
=
0
;
int
code
=
0
;
TBC
*
pCur
;
TBC
*
pCur
;
...
@@ -714,13 +719,14 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
...
@@ -714,13 +719,14 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
return
0
;
return
0
;
}
}
code
=
tdbTbcOpen
(
pPager
->
pEnv
->
pFreeDb
,
&
pCur
,
NULL
);
code
=
tdbTbcOpen
(
pPager
->
pEnv
->
pFreeDb
,
&
pCur
,
pTxn
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
return
0
;
return
0
;
}
}
code
=
tdbTbcMoveToFirst
(
pCur
);
code
=
tdbTbcMoveToFirst
(
pCur
);
if
(
code
)
{
if
(
code
)
{
tdbError
(
"tdb/remove-free-page: moveto first failed with ret: %d."
,
code
);
tdbTbcClose
(
pCur
);
tdbTbcClose
(
pCur
);
return
0
;
return
0
;
}
}
...
@@ -730,6 +736,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
...
@@ -730,6 +736,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
code
=
tdbTbcGet
(
pCur
,
(
const
void
**
)
&
pKey
,
&
nKey
,
NULL
,
NULL
);
code
=
tdbTbcGet
(
pCur
,
(
const
void
**
)
&
pKey
,
&
nKey
,
NULL
,
NULL
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
tdbError
(
"tdb/remove-free-page: tbc get failed with ret: %d."
,
code
);
tdbTbcClose
(
pCur
);
tdbTbcClose
(
pCur
);
return
0
;
return
0
;
}
}
...
@@ -738,6 +745,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
...
@@ -738,6 +745,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
code
=
tdbTbcDelete
(
pCur
);
code
=
tdbTbcDelete
(
pCur
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
tdbError
(
"tdb/remove-free-page: tbc delete failed with ret: %d."
,
code
);
tdbTbcClose
(
pCur
);
tdbTbcClose
(
pCur
);
return
0
;
return
0
;
}
}
...
@@ -745,9 +753,9 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
...
@@ -745,9 +753,9 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno) {
return
0
;
return
0
;
}
}
static
int
tdbPagerAllocFreePage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
static
int
tdbPagerAllocFreePage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
TXN
*
pTxn
)
{
// TODO: Allocate a page from the free list
// TODO: Allocate a page from the free list
return
tdbPagerRemoveFreePage
(
pPager
,
ppgno
);
return
tdbPagerRemoveFreePage
(
pPager
,
ppgno
,
pTxn
);
}
}
static
int
tdbPagerAllocNewPage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
static
int
tdbPagerAllocNewPage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
...
@@ -755,13 +763,13 @@ static int tdbPagerAllocNewPage(SPager *pPager, SPgno *ppgno) {
...
@@ -755,13 +763,13 @@ static int tdbPagerAllocNewPage(SPager *pPager, SPgno *ppgno) {
return
0
;
return
0
;
}
}
int
tdbPagerAllocPage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
static
int
tdbPagerAllocPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
TXN
*
pTxn
)
{
int
ret
;
int
ret
;
*
ppgno
=
0
;
*
ppgno
=
0
;
// Try to allocate from the free list of the pager
// Try to allocate from the free list of the pager
ret
=
tdbPagerAllocFreePage
(
pPager
,
ppgno
);
ret
=
tdbPagerAllocFreePage
(
pPager
,
ppgno
,
pTxn
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
8fee813d
...
@@ -199,9 +199,9 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initP
...
@@ -199,9 +199,9 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initP
TXN
*
pTxn
);
TXN
*
pTxn
);
void
tdbPagerReturnPage
(
SPager
*
pPager
,
SPage
*
pPage
,
TXN
*
pTxn
);
void
tdbPagerReturnPage
(
SPager
*
pPager
,
SPage
*
pPage
,
TXN
*
pTxn
);
int
tdbPagerInsertFreePage
(
SPager
*
pPager
,
SPgno
pgno
,
TXN
*
pTxn
);
int
tdbPagerInsertFreePage
(
SPager
*
pPager
,
SPgno
pgno
,
TXN
*
pTxn
);
int
tdbPagerAllocPage
(
SPager
*
pPager
,
SPgno
*
ppgno
);
//
int tdbPagerAllocPage(SPager *pPager, SPgno *ppgno);
int
tdbPagerRestoreJournals
(
SPager
*
pPager
);
int
tdbPagerRestoreJournals
(
SPager
*
pPager
);
int
tdbPagerRollback
(
SPager
*
pPager
);
int
tdbPagerRollback
(
SPager
*
pPager
);
// tdbPCache.c ====================================
// tdbPCache.c ====================================
#define TDB_PCACHE_PAGE \
#define TDB_PCACHE_PAGE \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录