Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ef3102ba
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看板
提交
ef3102ba
编写于
1月 07, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more refact
上级
d083bcb7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
72 deletion
+64
-72
source/dnode/vnode/tsdb2/inc/tsdbBuffer.h
source/dnode/vnode/tsdb2/inc/tsdbBuffer.h
+30
-30
source/dnode/vnode/tsdb2/inc/tsdbint.h
source/dnode/vnode/tsdb2/inc/tsdbint.h
+12
-12
source/dnode/vnode/tsdb2/src/tsdbBuffer.c
source/dnode/vnode/tsdb2/src/tsdbBuffer.c
+5
-1
source/dnode/vnode/tsdb2/src/tsdbCommit.c
source/dnode/vnode/tsdb2/src/tsdbCommit.c
+1
-1
source/dnode/vnode/tsdb2/src/tsdbMain.c
source/dnode/vnode/tsdb2/src/tsdbMain.c
+12
-28
source/dnode/vnode/tsdb2/src/tsdbMemTable.c
source/dnode/vnode/tsdb2/src/tsdbMemTable.c
+4
-0
未找到文件。
source/dnode/vnode/tsdb2/inc/tsdbBuffer.h
浏览文件 @
ef3102ba
...
@@ -13,39 +13,39 @@
...
@@ -13,39 +13,39 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef _TD_TSDB_BUFFER_H_
//
#ifndef _TD_TSDB_BUFFER_H_
#define _TD_TSDB_BUFFER_H_
//
#define _TD_TSDB_BUFFER_H_
typedef
struct
{
//
typedef struct {
int64_t
blockId
;
//
int64_t blockId;
int
offset
;
//
int offset;
int
remain
;
//
int remain;
char
data
[];
//
char data[];
}
STsdbBufBlock
;
//
} STsdbBufBlock;
typedef
struct
{
//
typedef struct {
pthread_cond_t
poolNotEmpty
;
//
pthread_cond_t poolNotEmpty;
int
bufBlockSize
;
//
int bufBlockSize;
int
tBufBlocks
;
//
int tBufBlocks;
int
nBufBlocks
;
//
int nBufBlocks;
int
nRecycleBlocks
;
//
int nRecycleBlocks;
int
nElasticBlocks
;
//
int nElasticBlocks;
int64_t
index
;
//
int64_t index;
SList
*
bufBlockList
;
//
SList* bufBlockList;
}
STsdbBufPool
;
//
} STsdbBufPool;
#define TSDB_BUFFER_RESERVE 1024 // Reseve 1K as commit threshold
//
#define TSDB_BUFFER_RESERVE 1024 // Reseve 1K as commit threshold
STsdbBufPool
*
tsdbNewBufPool
();
//
STsdbBufPool* tsdbNewBufPool();
void
tsdbFreeBufPool
(
STsdbBufPool
*
pBufPool
);
//
void tsdbFreeBufPool(STsdbBufPool* pBufPool);
int
tsdbOpenBufPool
(
STsdb
*
pRepo
);
//
int tsdbOpenBufPool(STsdb* pRepo);
void
tsdbCloseBufPool
(
STsdb
*
pRepo
);
//
void tsdbCloseBufPool(STsdb* pRepo);
SListNode
*
tsdbAllocBufBlockFromPool
(
STsdb
*
pRepo
);
//
SListNode* tsdbAllocBufBlockFromPool(STsdb* pRepo);
int
tsdbExpandPool
(
STsdb
*
pRepo
,
int32_t
oldTotalBlocks
);
//
int tsdbExpandPool(STsdb* pRepo, int32_t oldTotalBlocks);
void
tsdbRecycleBufferBlock
(
STsdbBufPool
*
pPool
,
SListNode
*
pNode
,
bool
bELastic
);
//
void tsdbRecycleBufferBlock(STsdbBufPool* pPool, SListNode *pNode, bool bELastic);
// health cite
//
//
health cite
STsdbBufBlock
*
tsdbNewBufBlock
(
int
bufBlockSize
);
//
STsdbBufBlock *tsdbNewBufBlock(int bufBlockSize);
void
tsdbFreeBufBlock
(
STsdbBufBlock
*
pBufBlock
);
//
void tsdbFreeBufBlock(STsdbBufBlock *pBufBlock);
#endif
/* _TD_TSDB_BUFFER_H_ */
//
#endif /* _TD_TSDB_BUFFER_H_ */
source/dnode/vnode/tsdb2/inc/tsdbint.h
浏览文件 @
ef3102ba
...
@@ -43,8 +43,8 @@ extern "C" {
...
@@ -43,8 +43,8 @@ extern "C" {
#include "tsdbLog.h"
#include "tsdbLog.h"
// Meta
// Meta
#include "tsdbMeta.h"
#include "tsdbMeta.h"
// Buffer
//
//
Buffer
#include "tsdbBuffer.h"
//
#include "tsdbBuffer.h"
// MemTable
// MemTable
#include "tsdbMemTable.h"
#include "tsdbMemTable.h"
// File
// File
...
@@ -74,7 +74,7 @@ struct STsdb {
...
@@ -74,7 +74,7 @@ struct STsdb {
STsdbAppH
appH
;
STsdbAppH
appH
;
STsdbStat
stat
;
STsdbStat
stat
;
STsdbMeta
*
tsdbMeta
;
STsdbMeta
*
tsdbMeta
;
STsdbBufPool
*
pPool
;
//
STsdbBufPool* pPool;
SMemTable
*
mem
;
SMemTable
*
mem
;
SMemTable
*
imem
;
SMemTable
*
imem
;
STsdbFS
*
fs
;
STsdbFS
*
fs
;
...
@@ -105,18 +105,18 @@ int32_t tsdbLoadLastCache(STsdb *pRepo, STable* pTable);
...
@@ -105,18 +105,18 @@ int32_t tsdbLoadLastCache(STsdb *pRepo, STable* pTable);
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
void
tsdbGetRootDir
(
int
repoid
,
char
dirName
[]);
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[]);
void
tsdbGetDataDir
(
int
repoid
,
char
dirName
[]);
static
FORCE_INLINE
STsdbBufBlock
*
tsdbGetCurrBufBlock
(
STsdb
*
pRepo
)
{
//
static FORCE_INLINE STsdbBufBlock* tsdbGetCurrBufBlock(STsdb* pRepo) {
ASSERT
(
pRepo
!=
NULL
);
//
ASSERT(pRepo != NULL);
if
(
pRepo
->
mem
==
NULL
)
return
NULL
;
//
if (pRepo->mem == NULL) return NULL;
SListNode
*
pNode
=
listTail
(
pRepo
->
mem
->
bufBlockList
);
//
SListNode* pNode = listTail(pRepo->mem->bufBlockList);
if
(
pNode
==
NULL
)
return
NULL
;
//
if (pNode == NULL) return NULL;
STsdbBufBlock
*
pBufBlock
=
NULL
;
//
STsdbBufBlock* pBufBlock = NULL;
tdListNodeGetData
(
pRepo
->
mem
->
bufBlockList
,
pNode
,
(
void
*
)(
&
pBufBlock
));
//
tdListNodeGetData(pRepo->mem->bufBlockList, pNode, (void*)(&pBufBlock));
return
pBufBlock
;
//
return pBufBlock;
}
//
}
// static FORCE_INLINE int tsdbGetNextMaxTables(int tid) {
// static FORCE_INLINE int tsdbGetNextMaxTables(int tid) {
// ASSERT(tid >= 1 && tid <= TSDB_MAX_TABLES);
// ASSERT(tid >= 1 && tid <= TSDB_MAX_TABLES);
...
...
source/dnode/vnode/tsdb2/src/tsdbBuffer.c
浏览文件 @
ef3102ba
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#if 0
#include "tsdbHealth.h"
#include "tsdbHealth.h"
#include "tsdbint.h"
#include "tsdbint.h"
...
@@ -210,4 +212,6 @@ void tsdbRecycleBufferBlock(STsdbBufPool *pPool, SListNode *pNode, bool bELastic
...
@@ -210,4 +212,6 @@ void tsdbRecycleBufferBlock(STsdbBufPool *pPool, SListNode *pNode, bool bELastic
TD_DLIST_NELES(pPool->bufBlockList));
TD_DLIST_NELES(pPool->bufBlockList));
} else
} else
pPool->nBufBlocks--;
pPool->nBufBlocks--;
}
}
\ No newline at end of file
#endif
\ No newline at end of file
source/dnode/vnode/tsdb2/src/tsdbCommit.c
浏览文件 @
ef3102ba
...
@@ -575,7 +575,7 @@ _err:
...
@@ -575,7 +575,7 @@ _err:
// rename meta.tmp -> meta
// rename meta.tmp -> meta
tsdbInfo
(
"vgId:%d meta file rename %s -> %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
&
mf
),
tsdbInfo
(
"vgId:%d meta file rename %s -> %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
&
mf
),
TSDB_FILE_FULL_NAME
(
pMFile
));
TSDB_FILE_FULL_NAME
(
pMFile
));
taosRename
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
);
taosRename
File
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
);
tstrncpy
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
,
TSDB_FILENAME_LEN
);
tstrncpy
(
mf
.
f
.
aname
,
pMFile
->
f
.
aname
,
TSDB_FILENAME_LEN
);
tstrncpy
(
mf
.
f
.
rname
,
pMFile
->
f
.
rname
,
TSDB_FILENAME_LEN
);
tstrncpy
(
mf
.
f
.
rname
,
pMFile
->
f
.
rname
,
TSDB_FILENAME_LEN
);
// update current meta file info
// update current meta file info
...
...
source/dnode/vnode/tsdb2/src/tsdbMain.c
浏览文件 @
ef3102ba
...
@@ -89,13 +89,6 @@ STsdb *tsdbOpen(STsdbCfg *pCfg, STsdbAppH *pAppH) {
...
@@ -89,13 +89,6 @@ STsdb *tsdbOpen(STsdbCfg *pCfg, STsdbAppH *pAppH) {
return
NULL
;
return
NULL
;
}
}
if
(
tsdbOpenBufPool
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open TSDB repository while opening buffer pool since %s"
,
config
.
tsdbId
,
tstrerror
(
terrno
));
tsdbClose
(
pRepo
,
false
);
return
NULL
;
}
if
(
tsdbOpenFS
(
pRepo
)
<
0
)
{
if
(
tsdbOpenFS
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open TSDB repository while opening FS since %s"
,
config
.
tsdbId
,
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to open TSDB repository while opening FS since %s"
,
config
.
tsdbId
,
tstrerror
(
terrno
));
tsdbClose
(
pRepo
,
false
);
tsdbClose
(
pRepo
,
false
);
...
@@ -145,7 +138,6 @@ int tsdbClose(STsdb *repo, int toCommit) {
...
@@ -145,7 +138,6 @@ int tsdbClose(STsdb *repo, int toCommit) {
pRepo
->
imem
=
NULL
;
pRepo
->
imem
=
NULL
;
tsdbCloseFS
(
pRepo
);
tsdbCloseFS
(
pRepo
);
tsdbCloseBufPool
(
pRepo
);
tsdbCloseMeta
(
pRepo
);
tsdbCloseMeta
(
pRepo
);
tsdbFreeRepo
(
pRepo
);
tsdbFreeRepo
(
pRepo
);
tsdbDebug
(
"vgId:%d repository is closed"
,
vgId
);
tsdbDebug
(
"vgId:%d repository is closed"
,
vgId
);
...
@@ -193,19 +185,19 @@ int tsdbUnlockRepo(STsdb *pRepo) {
...
@@ -193,19 +185,19 @@ int tsdbUnlockRepo(STsdb *pRepo) {
// return 0;
// return 0;
// }
// }
int
tsdbCheckCommit
(
STsdb
*
pRepo
)
{
//
int tsdbCheckCommit(STsdb *pRepo) {
ASSERT
(
pRepo
->
mem
!=
NULL
);
//
ASSERT(pRepo->mem != NULL);
STsdbCfg
*
pCfg
=
&
(
pRepo
->
config
);
//
STsdbCfg *pCfg = &(pRepo->config);
STsdbBufBlock
*
pBufBlock
=
tsdbGetCurrBufBlock
(
pRepo
);
//
STsdbBufBlock *pBufBlock = tsdbGetCurrBufBlock(pRepo);
ASSERT
(
pBufBlock
!=
NULL
);
//
ASSERT(pBufBlock != NULL);
if
((
pRepo
->
mem
->
extraBuffList
!=
NULL
)
||
//
if ((pRepo->mem->extraBuffList != NULL) ||
((
listNEles
(
pRepo
->
mem
->
bufBlockList
)
>=
pCfg
->
totalBlocks
/
3
)
&&
(
pBufBlock
->
remain
<
TSDB_BUFFER_RESERVE
)))
{
//
((listNEles(pRepo->mem->bufBlockList) >= pCfg->totalBlocks / 3) && (pBufBlock->remain < TSDB_BUFFER_RESERVE))) {
// trigger commit
//
// trigger commit
if
(
tsdbAsyncCommit
(
pRepo
)
<
0
)
return
-
1
;
//
if (tsdbAsyncCommit(pRepo) < 0) return -1;
}
//
}
return
0
;
//
return 0;
}
//
}
STsdbMeta
*
tsdbGetMeta
(
STsdb
*
pRepo
)
{
return
pRepo
->
tsdbMeta
;
}
STsdbMeta
*
tsdbGetMeta
(
STsdb
*
pRepo
)
{
return
pRepo
->
tsdbMeta
;
}
...
@@ -612,13 +604,6 @@ static STsdb *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
...
@@ -612,13 +604,6 @@ static STsdb *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
return
NULL
;
return
NULL
;
}
}
pRepo
->
pPool
=
tsdbNewBufPool
(
pCfg
);
if
(
pRepo
->
pPool
==
NULL
)
{
tsdbError
(
"vgId:%d failed to create buffer pool since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbFreeRepo
(
pRepo
);
return
NULL
;
}
pRepo
->
fs
=
tsdbNewFS
(
pCfg
);
pRepo
->
fs
=
tsdbNewFS
(
pCfg
);
if
(
pRepo
->
fs
==
NULL
)
{
if
(
pRepo
->
fs
==
NULL
)
{
tsdbError
(
"vgId:%d failed to TSDB file system since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to TSDB file system since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
...
@@ -632,7 +617,6 @@ static STsdb *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
...
@@ -632,7 +617,6 @@ static STsdb *tsdbNewRepo(STsdbCfg *pCfg, STsdbAppH *pAppH) {
static
void
tsdbFreeRepo
(
STsdb
*
pRepo
)
{
static
void
tsdbFreeRepo
(
STsdb
*
pRepo
)
{
if
(
pRepo
)
{
if
(
pRepo
)
{
tsdbFreeFS
(
pRepo
->
fs
);
tsdbFreeFS
(
pRepo
->
fs
);
tsdbFreeBufPool
(
pRepo
->
pPool
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
tsdbFreeMeta
(
pRepo
->
tsdbMeta
);
tsdbFreeMergeBuf
(
pRepo
->
mergeBuf
);
tsdbFreeMergeBuf
(
pRepo
->
mergeBuf
);
// tsdbFreeMemTable(pRepo->mem);
// tsdbFreeMemTable(pRepo->mem);
...
...
source/dnode/vnode/tsdb2/src/tsdbMemTable.c
浏览文件 @
ef3102ba
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#if 0
#include "tdataformat.h"
#include "tdataformat.h"
#include "tfunctional.h"
#include "tfunctional.h"
#include "tsdbRowMergeBuf.h"
#include "tsdbRowMergeBuf.h"
...
@@ -1000,3 +1002,5 @@ static int tsdbUpdateTableLatestInfo(STsdb *pRepo, STable *pTable, SMemRow row)
...
@@ -1000,3 +1002,5 @@ static int tsdbUpdateTableLatestInfo(STsdb *pRepo, STable *pTable, SMemRow row)
return 0;
return 0;
}
}
#endif
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录