Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5ebc7796
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看板
提交
5ebc7796
编写于
11月 05, 2021
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tq invalid free
上级
9edc17e5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
3 deletion
+50
-3
source/dnode/vnode/tq/inc/tqMetaStore.h
source/dnode/vnode/tq/inc/tqMetaStore.h
+2
-0
source/dnode/vnode/tq/src/tqMetaStore.c
source/dnode/vnode/tq/src/tqMetaStore.c
+8
-3
source/dnode/vnode/tq/test/tqMetaTest.cpp
source/dnode/vnode/tq/test/tqMetaTest.cpp
+40
-0
未找到文件。
source/dnode/vnode/tq/inc/tqMetaStore.h
浏览文件 @
5ebc7796
...
...
@@ -92,6 +92,8 @@ int32_t tqStoreClose(TqMetaStore*);
//int32_t tqStoreDelete(TqMetaStore*);
//int32_t TqStoreCommitAll(TqMetaStore*);
int32_t
tqStorePersist
(
TqMetaStore
*
);
//clean deleted idx and data from persistent file
int32_t
tqStoreCompact
(
TqMetaStore
*
);
void
*
tqHandleGet
(
TqMetaStore
*
,
int64_t
key
);
int32_t
tqHandleMovePut
(
TqMetaStore
*
,
int64_t
key
,
void
*
value
);
...
...
source/dnode/vnode/tq/src/tqMetaStore.c
浏览文件 @
5ebc7796
...
...
@@ -153,9 +153,9 @@ TqMetaStore* tqStoreOpen(const char* path,
}
else
{
pNode
->
handle
.
valueInUse
=
TQ_DELETE_TOKEN
;
}
serializedObj
=
POINTER_SHIFT
(
serializedObj
,
serializedObj
->
ssize
);
if
(
serializedObj
->
ssize
!=
sizeof
(
TqSerializedHead
))
{
pMeta
->
deserializer
(
serializedObj
,
&
pNode
->
handle
.
valueInTxn
);
TqSerializedHead
*
ptr
=
POINTER_SHIFT
(
serializedObj
,
serializedObj
->
ssize
);
if
(
ptr
->
ssize
!=
sizeof
(
TqSerializedHead
))
{
pMeta
->
deserializer
(
ptr
,
&
pNode
->
handle
.
valueInTxn
);
}
else
{
pNode
->
handle
.
valueInTxn
=
TQ_DELETE_TOKEN
;
}
...
...
@@ -591,3 +591,8 @@ int32_t tqHandleClear(TqMetaStore* pMeta, int64_t key) {
}
return
-
2
;
}
//TODO: clean deleted idx and data from persistent file
int32_t
tqStoreCompact
(
TqMetaStore
*
pMeta
)
{
return
0
;
}
source/dnode/vnode/tq/test/tqMetaTest.cpp
浏览文件 @
5ebc7796
...
...
@@ -57,6 +57,10 @@ TEST_F(TqMetaTest, copyPutTest) {
Foo
*
pFoo
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo
==
NULL
,
true
);
tqHandleCommit
(
pMeta
,
1
);
pFoo
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo
->
a
,
3
);
}
TEST_F
(
TqMetaTest
,
persistTest
)
{
...
...
@@ -135,6 +139,42 @@ TEST_F(TqMetaTest, deleteTest) {
pMeta
=
tqStoreOpen
(
pathName
,
FooSerializer
,
FooDeserializer
,
FooDeleter
);
ASSERT
(
pMeta
);
pFoo
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo
==
NULL
,
true
);
}
TEST_F
(
TqMetaTest
,
intxnPersist
)
{
Foo
*
pFoo
=
(
Foo
*
)
malloc
(
sizeof
(
Foo
));
pFoo
->
a
=
3
;
tqHandleMovePut
(
pMeta
,
1
,
pFoo
);
tqHandleCommit
(
pMeta
,
1
);
Foo
*
pBar
=
(
Foo
*
)
malloc
(
sizeof
(
Foo
));
pBar
->
a
=
4
;
tqHandleMovePut
(
pMeta
,
1
,
pBar
);
Foo
*
pFoo1
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo1
->
a
,
3
);
tqStoreClose
(
pMeta
);
pMeta
=
tqStoreOpen
(
pathName
,
FooSerializer
,
FooDeserializer
,
FooDeleter
);
ASSERT
(
pMeta
);
pFoo1
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo1
->
a
,
3
);
tqHandleCommit
(
pMeta
,
1
);
pFoo1
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo1
->
a
,
4
);
tqStoreClose
(
pMeta
);
pMeta
=
tqStoreOpen
(
pathName
,
FooSerializer
,
FooDeserializer
,
FooDeleter
);
ASSERT
(
pMeta
);
pFoo1
=
(
Foo
*
)
tqHandleGet
(
pMeta
,
1
);
EXPECT_EQ
(
pFoo1
->
a
,
4
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录