Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aad669e3
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
aad669e3
编写于
7月 14, 2023
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add checkpoint
上级
3020e271
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
8 deletion
+42
-8
source/libs/stream/inc/streamBackendRocksdb.h
source/libs/stream/inc/streamBackendRocksdb.h
+1
-1
source/libs/stream/src/streamBackendRocksdb.c
source/libs/stream/src/streamBackendRocksdb.c
+35
-5
source/libs/stream/src/streamMeta.c
source/libs/stream/src/streamMeta.c
+6
-2
未找到文件。
source/libs/stream/inc/streamBackendRocksdb.h
浏览文件 @
aad669e3
...
@@ -44,7 +44,7 @@ typedef struct {
...
@@ -44,7 +44,7 @@ typedef struct {
int64_t
defaultCfInit
;
int64_t
defaultCfInit
;
}
SBackendWrapper
;
}
SBackendWrapper
;
void
*
streamBackendInit
(
const
char
*
path
);
void
*
streamBackendInit
(
const
char
*
path
,
int64_t
chkpId
);
void
streamBackendCleanup
(
void
*
arg
);
void
streamBackendCleanup
(
void
*
arg
);
void
streamBackendHandleCleanup
(
void
*
arg
);
void
streamBackendHandleCleanup
(
void
*
arg
);
int32_t
streamBackendLoadCheckpointInfo
(
void
*
pMeta
);
int32_t
streamBackendLoadCheckpointInfo
(
void
*
pMeta
);
...
...
source/libs/stream/src/streamBackendRocksdb.c
浏览文件 @
aad669e3
...
@@ -144,10 +144,40 @@ SCfInit ginitDict[] = {
...
@@ -144,10 +144,40 @@ SCfInit ginitDict[] = {
encodeValueFunc
,
decodeValueFunc
},
encodeValueFunc
,
decodeValueFunc
},
};
};
void
*
streamBackendInit
(
const
char
*
path
)
{
int32_t
streamBackendRebuildDirFromCheckpoint
(
const
char
*
stateDir
,
const
char
*
chkpDir
)
{
// impl later
return
0
;
}
void
*
streamBackendInit
(
const
char
*
path
,
int64_t
chkpId
)
{
int32_t
code
=
0
;
char
*
state
=
taosMemoryCalloc
(
1
,
strlen
(
path
)
+
32
);
sprintf
(
state
,
"%s/%s"
,
path
,
"state"
);
if
(
chkpId
!=
0
)
{
char
*
chkp
=
taosMemoryCalloc
(
1
,
strlen
(
path
)
+
64
);
sprintf
(
chkp
,
"%s/%s/checkpoint-%"
PRId64
""
,
path
,
"checkpoints"
,
chkpId
);
if
(
taosIsDir
(
chkp
))
{
if
(
taosIsDir
(
state
))
{
// remove dir if exists
// taosRenameFile(const char *oldName, const char *newName)
taosRemoveDir
(
state
);
}
taosMkDir
(
state
);
code
=
streamBackendRebuildDirFromCheckpoint
(
state
,
chkp
);
if
(
code
!=
0
)
{
qError
(
"failed to restart stream backend from %s, reason: %s"
,
chkp
,
tstrerror
(
TAOS_SYSTEM_ERROR
(
errno
)));
}
}
else
{
qError
(
"failed to start stream backend at %s, reason: %s"
,
chkp
,
tstrerror
(
TAOS_SYSTEM_ERROR
(
errno
)));
taosMkDir
(
state
);
}
}
uint32_t
dbMemLimit
=
nextPow2
(
tsMaxStreamBackendCache
)
<<
20
;
uint32_t
dbMemLimit
=
nextPow2
(
tsMaxStreamBackendCache
)
<<
20
;
qDebug
(
"start to init stream backend at %s"
,
path
);
qDebug
(
"start to init stream backend at %s"
,
state
);
SBackendWrapper
*
pHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SBackendWrapper
));
SBackendWrapper
*
pHandle
=
taosMemoryCalloc
(
1
,
sizeof
(
SBackendWrapper
));
pHandle
->
list
=
tdListNew
(
sizeof
(
SCfComparator
));
pHandle
->
list
=
tdListNew
(
sizeof
(
SCfComparator
));
taosThreadMutexInit
(
&
pHandle
->
mutex
,
NULL
);
taosThreadMutexInit
(
&
pHandle
->
mutex
,
NULL
);
...
@@ -183,7 +213,7 @@ void* streamBackendInit(const char* path) {
...
@@ -183,7 +213,7 @@ void* streamBackendInit(const char* path) {
char
*
err
=
NULL
;
char
*
err
=
NULL
;
size_t
nCf
=
0
;
size_t
nCf
=
0
;
char
**
cfs
=
rocksdb_list_column_families
(
opts
,
path
,
&
nCf
,
&
err
);
char
**
cfs
=
rocksdb_list_column_families
(
opts
,
state
,
&
nCf
,
&
err
);
if
(
nCf
==
0
||
nCf
==
1
||
err
!=
NULL
)
{
if
(
nCf
==
0
||
nCf
==
1
||
err
!=
NULL
)
{
taosMemoryFreeClear
(
err
);
taosMemoryFreeClear
(
err
);
pHandle
->
db
=
rocksdb_open
(
opts
,
path
,
&
err
);
pHandle
->
db
=
rocksdb_open
(
opts
,
path
,
&
err
);
...
@@ -196,12 +226,12 @@ void* streamBackendInit(const char* path) {
...
@@ -196,12 +226,12 @@ void* streamBackendInit(const char* path) {
/*
/*
list all cf and get prefix
list all cf and get prefix
*/
*/
streamStateOpenBackendCf
(
pHandle
,
(
char
*
)
path
,
cfs
,
nCf
);
streamStateOpenBackendCf
(
pHandle
,
(
char
*
)
state
,
cfs
,
nCf
);
}
}
if
(
cfs
!=
NULL
)
{
if
(
cfs
!=
NULL
)
{
rocksdb_list_column_families_destroy
(
cfs
,
nCf
);
rocksdb_list_column_families_destroy
(
cfs
,
nCf
);
}
}
qDebug
(
"succ to init stream backend at %s, backend:%p"
,
path
,
pHandle
);
qDebug
(
"succ to init stream backend at %s, backend:%p"
,
state
,
pHandle
);
return
(
void
*
)
pHandle
;
return
(
void
*
)
pHandle
;
_EXIT:
_EXIT:
...
...
source/libs/stream/src/streamMeta.c
浏览文件 @
aad669e3
...
@@ -23,6 +23,8 @@ static TdThreadOnce streamMetaModuleInit = PTHREAD_ONCE_INIT;
...
@@ -23,6 +23,8 @@ static TdThreadOnce streamMetaModuleInit = PTHREAD_ONCE_INIT;
int32_t
streamBackendId
=
0
;
int32_t
streamBackendId
=
0
;
int32_t
streamBackendCfWrapperId
=
0
;
int32_t
streamBackendCfWrapperId
=
0
;
int64_t
streamGetLatestCheckpointId
(
SStreamMeta
*
pMeta
);
static
void
streamMetaEnvInit
()
{
static
void
streamMetaEnvInit
()
{
streamBackendId
=
taosOpenRef
(
64
,
streamBackendCleanup
);
streamBackendId
=
taosOpenRef
(
64
,
streamBackendCleanup
);
streamBackendCfWrapperId
=
taosOpenRef
(
64
,
streamBackendHandleCleanup
);
streamBackendCfWrapperId
=
taosOpenRef
(
64
,
streamBackendHandleCleanup
);
...
@@ -103,7 +105,9 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
...
@@ -103,7 +105,9 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF
pMeta
->
checkpointCap
=
4
;
pMeta
->
checkpointCap
=
4
;
taosInitRWLatch
(
&
pMeta
->
checkpointDirLock
);
taosInitRWLatch
(
&
pMeta
->
checkpointDirLock
);
pMeta
->
streamBackend
=
streamBackendInit
(
streamPath
);
int64_t
chkpId
=
streamGetLatestCheckpointId
(
pMeta
);
pMeta
->
streamBackend
=
streamBackendInit
(
pMeta
->
path
,
chkpId
);
if
(
pMeta
->
streamBackend
==
NULL
)
{
if
(
pMeta
->
streamBackend
==
NULL
)
{
goto
_err
;
goto
_err
;
}
}
...
@@ -443,7 +447,7 @@ _err:
...
@@ -443,7 +447,7 @@ _err:
return
chkpId
;
return
chkpId
;
}
}
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
,
int64_t
ver
)
{
int32_t
streamLoadTasks
(
SStreamMeta
*
pMeta
,
int64_t
ver
)
{
int64_t
checkpointId
=
streamGetLatestCheckpointId
(
pMeta
)
;
int64_t
checkpointId
=
0
;
TBC
*
pCur
=
NULL
;
TBC
*
pCur
=
NULL
;
if
(
tdbTbcOpen
(
pMeta
->
pTaskDb
,
&
pCur
,
NULL
)
<
0
)
{
if
(
tdbTbcOpen
(
pMeta
->
pTaskDb
,
&
pCur
,
NULL
)
<
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录