Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b44ef3c8
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b44ef3c8
编写于
3月 17, 2022
作者:
C
Cary Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use dataDir to init sma env
上级
5705b76e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
71 addition
and
35 deletion
+71
-35
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+10
-0
source/dnode/mgmt/daemon/src/dmnMain.c
source/dnode/mgmt/daemon/src/dmnMain.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+47
-32
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+7
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+5
-0
tests/pytest/crash_gen/service_manager.py
tests/pytest/crash_gen/service_manager.py
+1
-1
未找到文件。
include/libs/tfs/tfs.h
浏览文件 @
b44ef3c8
...
@@ -198,6 +198,16 @@ void tfsBasename(const STfsFile *pFile, char *dest);
...
@@ -198,6 +198,16 @@ void tfsBasename(const STfsFile *pFile, char *dest);
*/
*/
void
tfsDirname
(
const
STfsFile
*
pFile
,
char
*
dest
);
void
tfsDirname
(
const
STfsFile
*
pFile
,
char
*
dest
);
/**
* @brief Get the absolute file name of rname.
*
* @param pTfs
* @param diskId
* @param rname relative file name
* @param aname absolute file name
*/
void
tfsAbsoluteName
(
STfs
*
pTfs
,
SDiskID
diskId
,
const
char
*
rname
,
char
*
aname
);
/**
/**
* @brief Remove file in tfs.
* @brief Remove file in tfs.
*
*
...
...
source/dnode/mgmt/daemon/src/dmnMain.c
浏览文件 @
b44ef3c8
...
@@ -27,7 +27,7 @@ static struct {
...
@@ -27,7 +27,7 @@ static struct {
}
dmn
=
{
0
};
}
dmn
=
{
0
};
static
void
dmnSigintHandle
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
static
void
dmnSigintHandle
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
uInfo
(
"si
ng
al:%d is received"
,
signum
);
uInfo
(
"si
gn
al:%d is received"
,
signum
);
dmn
.
stop
=
true
;
dmn
.
stop
=
true
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
b44ef3c8
...
@@ -20,8 +20,7 @@ static const char *TSDB_SMA_DNAME[] = {
...
@@ -20,8 +20,7 @@ static const char *TSDB_SMA_DNAME[] = {
"tsma"
,
// TSDB_SMA_TYPE_TIME_RANGE
"tsma"
,
// TSDB_SMA_TYPE_TIME_RANGE
"rsma"
,
// TSDB_SMA_TYPE_ROLLUP
"rsma"
,
// TSDB_SMA_TYPE_ROLLUP
};
};
#define SMA_CHECK_HASH
#undef _TEST_SMA_PRINT_DEBUG_LOG_
#undef SMA_PRINT_DEBUG_LOG
#define SMA_STORAGE_TSDB_DAYS 30
#define SMA_STORAGE_TSDB_DAYS 30
#define SMA_STORAGE_TSDB_TIMES 10
#define SMA_STORAGE_TSDB_TIMES 10
#define SMA_STORAGE_SPLIT_HOURS 24
#define SMA_STORAGE_SPLIT_HOURS 24
...
@@ -33,8 +32,8 @@ static const char *TSDB_SMA_DNAME[] = {
...
@@ -33,8 +32,8 @@ static const char *TSDB_SMA_DNAME[] = {
#define SMA_TEST_INDEX_NAME "smaTestIndexName" // TODO: just for test
#define SMA_TEST_INDEX_NAME "smaTestIndexName" // TODO: just for test
#define SMA_TEST_INDEX_UID 2000000001 // TODO: just for test
#define SMA_TEST_INDEX_UID 2000000001 // TODO: just for test
typedef
enum
{
typedef
enum
{
SMA_STORAGE_LEVEL_TSDB
=
0
,
// use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2
t200.dat
SMA_STORAGE_LEVEL_TSDB
=
0
,
// use days of self-defined e.g. vnode${N}/tsdb/tsma/sma_index_uid/v2
f200.tsma
SMA_STORAGE_LEVEL_DFILESET
=
1
// use days of TS data e.g. vnode${N}/tsdb/
rsma/sma_index_uid/v2r200.dat
SMA_STORAGE_LEVEL_DFILESET
=
1
// use days of TS data e.g. vnode${N}/tsdb/
tsma/sma_index_uid/v2f1906.tsma
}
ESmaStorageLevel
;
}
ESmaStorageLevel
;
typedef
struct
{
typedef
struct
{
...
@@ -47,6 +46,7 @@ typedef struct {
...
@@ -47,6 +46,7 @@ typedef struct {
int32_t
iter
;
int32_t
iter
;
int32_t
fid
;
int32_t
fid
;
}
SmaFsIter
;
}
SmaFsIter
;
typedef
struct
{
typedef
struct
{
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SDBFile
dFile
;
SDBFile
dFile
;
...
@@ -71,11 +71,12 @@ typedef struct {
...
@@ -71,11 +71,12 @@ typedef struct {
}
SSmaStatItem
;
}
SSmaStatItem
;
struct
SSmaStat
{
struct
SSmaStat
{
SHashObj
*
smaStatItems
;
// key: index
Name
, value: SSmaStatItem
SHashObj
*
smaStatItems
;
// key: index
Uid
, value: SSmaStatItem
T_REF_DECLARE
()
T_REF_DECLARE
()
};
};
// declaration of static functions
// declaration of static functions
// expired window
// expired window
static
int32_t
tsdbUpdateExpiredWindow
(
STsdb
*
pTsdb
,
ETsdbSmaType
smaType
,
char
*
msg
);
static
int32_t
tsdbUpdateExpiredWindow
(
STsdb
*
pTsdb
,
ETsdbSmaType
smaType
,
char
*
msg
);
static
int32_t
tsdbInitSmaStat
(
SSmaStat
**
pSmaStat
);
static
int32_t
tsdbInitSmaStat
(
SSmaStat
**
pSmaStat
);
...
@@ -159,22 +160,12 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) {
...
@@ -159,22 +160,12 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
tsdbLockRepo
(
pTsdb
)
!=
0
)
{
if
(
*
pEnv
==
NULL
)
{
return
TSDB_CODE_FAILED
;
}
if
(
*
pEnv
==
NULL
)
{
// 2nd phase check
if
((
*
pEnv
=
tsdbNewSmaEnv
(
pTsdb
,
path
))
==
NULL
)
{
if
((
*
pEnv
=
tsdbNewSmaEnv
(
pTsdb
,
path
))
==
NULL
)
{
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
if
(
tsdbUnlockRepo
(
pTsdb
)
!=
0
)
{
*
pEnv
=
tsdbFreeSmaEnv
(
*
pEnv
);
return
TSDB_CODE_FAILED
;
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -279,6 +270,7 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) {
...
@@ -279,6 +270,7 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) {
}
}
static
int32_t
tsdbCheckAndInitSmaEnv
(
STsdb
*
pTsdb
,
int8_t
smaType
)
{
static
int32_t
tsdbCheckAndInitSmaEnv
(
STsdb
*
pTsdb
,
int8_t
smaType
)
{
// return if already init
switch
(
smaType
)
{
switch
(
smaType
)
{
case
TSDB_SMA_TYPE_TIME_RANGE
:
case
TSDB_SMA_TYPE_TIME_RANGE
:
if
(
pTsdb
->
pTSmaEnv
)
{
if
(
pTsdb
->
pTSmaEnv
)
{
...
@@ -295,10 +287,29 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
...
@@ -295,10 +287,29 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
// SDiskID did = {0};
// init sma env
tsdbLockRepo
(
pTsdb
);
if
(
pTsdb
->
pTSmaEnv
==
NULL
)
{
char
rname
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aname
[
TSDB_FILENAME_LEN
*
2
+
32
]
=
{
0
};
// TODO: make TMPNAME_LEN public as TSDB_FILENAME_LEN?
SDiskID
did
=
{
0
};
tfsAllocDisk
(
pTsdb
->
pTfs
,
TFS_PRIMARY_LEVEL
,
&
did
);
if
(
did
.
level
<
0
||
did
.
id
<
0
)
{
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
}
tsdbGetSmaDir
(
REPO_ID
(
pTsdb
),
smaType
,
rname
);
tfsAbsoluteName
(
pTsdb
->
pTfs
,
did
,
rname
,
aname
);
if
(
tfsMkdirRecurAt
(
pTsdb
->
pTfs
,
rname
,
did
)
!=
TSDB_CODE_SUCCESS
)
{
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
}
SSmaEnv
*
pEnv
=
NULL
;
SSmaEnv
*
pEnv
=
NULL
;
char
smaPath
[
TSDB_FILENAME_LEN
]
=
"/proj/.sma/"
;
if
(
tsdbInitSmaEnv
(
pTsdb
,
aname
,
&
pEnv
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
tsdbInitSmaEnv
(
pTsdb
,
smaPath
,
&
pEnv
)
!=
TSDB_CODE_SUCCESS
)
{
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -307,6 +318,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
...
@@ -307,6 +318,8 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
}
else
{
}
else
{
pTsdb
->
pRSmaEnv
=
pEnv
;
pTsdb
->
pRSmaEnv
=
pEnv
;
}
}
}
tsdbUnlockRepo
(
pTsdb
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
};
};
...
@@ -379,7 +392,7 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
...
@@ -379,7 +392,7 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
int8_t
state
=
TSDB_SMA_STAT_EXPIRED
;
int8_t
state
=
TSDB_SMA_STAT_EXPIRED
;
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
if
(
taosHashPut
(
pItem
->
expiredWindows
,
(
void
*
)(
expiredWindows
+
i
)
,
sizeof
(
TSKEY
),
&
state
,
sizeof
(
state
))
!=
0
)
{
if
(
taosHashPut
(
pItem
->
expiredWindows
,
expiredWindows
+
i
,
sizeof
(
TSKEY
),
&
state
,
sizeof
(
state
))
!=
0
)
{
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
// tell query module to query raw TS data.
// tell query module to query raw TS data.
// N.B.
// N.B.
...
@@ -497,12 +510,12 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
...
@@ -497,12 +510,12 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
#ifdef
SMA_PRINT_DEBUG_LOG
#ifdef
_TEST_SMA_PRINT_DEBUG_LOG_
uint32_t
valueSize
=
0
;
uint32_t
valueSize
=
0
;
void
*
data
=
tsdbGetSmaDataByKey
(
pDBFile
,
smaKey
,
keyLen
,
&
valueSize
);
void
*
data
=
tsdbGetSmaDataByKey
(
pDBFile
,
smaKey
,
keyLen
,
&
valueSize
);
ASSERT
(
data
!=
NULL
);
ASSERT
(
data
!=
NULL
);
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
tsdbWarn
(
"vgId:%d
sma data - val[%d] is
%"
PRIi64
,
REPO_ID
(
pSmaH
->
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
data
,
v
));
tsdbWarn
(
"vgId:%d
insert sma data val[%d]
%"
PRIi64
,
REPO_ID
(
pSmaH
->
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
data
,
v
));
}
}
#endif
#endif
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -935,12 +948,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
...
@@ -935,12 +948,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
tsdbCloseDBF
(
&
tReadH
.
dFile
);
tsdbCloseDBF
(
&
tReadH
.
dFile
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
tfree
(
result
);
#ifdef
SMA_PRINT_DEBUG_LOG
#ifdef
_TEST_SMA_PRINT_DEBUG_LOG_
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
tsdbWarn
(
"vgId:%d v[%d]=%"
PRIi64
,
REPO_ID
(
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
result
,
v
));
tsdbWarn
(
"vgId:%d
get sma data
v[%d]=%"
PRIi64
,
REPO_ID
(
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
result
,
v
));
}
}
#endif
#endif
tfree
(
result
);
// TODO: fill the result to output
#if 0
#if 0
int32_t nResult = 0;
int32_t nResult = 0;
int64_t lastKey = 0;
int64_t lastKey = 0;
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
b44ef3c8
...
@@ -301,8 +301,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -301,8 +301,14 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
break
;
break
;
}
}
SDiskCfg
pDisks
=
{.
level
=
0
,
.
primary
=
1
};
strncpy
(
pDisks
.
dir
,
"/var/lib/taos"
,
TSDB_FILENAME_LEN
);
int32_t
numOfDisks
=
1
;
tsdb
.
pTfs
=
tfsOpen
(
&
pDisks
,
numOfDisks
);
ASSERT_NE
(
tsdb
.
pTfs
,
nullptr
);
char
*
msg
=
(
char
*
)
calloc
(
1
,
100
);
char
*
msg
=
(
char
*
)
calloc
(
1
,
100
);
assert
(
msg
!=
NULL
);
ASSERT_NE
(
msg
,
nullptr
);
ASSERT_EQ
(
tsdbUpdateSmaWindow
(
&
tsdb
,
TSDB_SMA_TYPE_TIME_RANGE
,
msg
),
0
);
ASSERT_EQ
(
tsdbUpdateSmaWindow
(
&
tsdb
,
TSDB_SMA_TYPE_TIME_RANGE
,
msg
),
0
);
// init
// init
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
b44ef3c8
...
@@ -202,6 +202,11 @@ void tfsDirname(const STfsFile *pFile, char *dest) {
...
@@ -202,6 +202,11 @@ void tfsDirname(const STfsFile *pFile, char *dest) {
tstrncpy
(
dest
,
taosDirName
(
tname
),
TSDB_FILENAME_LEN
);
tstrncpy
(
dest
,
taosDirName
(
tname
),
TSDB_FILENAME_LEN
);
}
}
void
tfsAbsoluteName
(
STfs
*
pTfs
,
SDiskID
diskId
,
const
char
*
rname
,
char
*
aname
)
{
STfsDisk
*
pDisk
=
TFS_DISK_AT
(
pTfs
,
diskId
);
snprintf
(
aname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
rname
);
}
int32_t
tfsRemoveFile
(
const
STfsFile
*
pFile
)
{
return
taosRemoveFile
(
pFile
->
aname
);
}
int32_t
tfsRemoveFile
(
const
STfsFile
*
pFile
)
{
return
taosRemoveFile
(
pFile
->
aname
);
}
int32_t
tfsCopyFile
(
const
STfsFile
*
pFile1
,
const
STfsFile
*
pFile2
)
{
int32_t
tfsCopyFile
(
const
STfsFile
*
pFile1
,
const
STfsFile
*
pFile2
)
{
...
...
tests/pytest/crash_gen/service_manager.py
浏览文件 @
b44ef3c8
...
@@ -378,7 +378,7 @@ class TdeSubProcess:
...
@@ -378,7 +378,7 @@ class TdeSubProcess:
@
classmethod
@
classmethod
def
_stopForSure
(
cls
,
proc
:
Popen
,
sig
:
int
):
def
_stopForSure
(
cls
,
proc
:
Popen
,
sig
:
int
):
'''
'''
Stop a process and all sub processes with a si
ng
al, and SIGKILL if necessary
Stop a process and all sub processes with a si
gn
al, and SIGKILL if necessary
'''
'''
def
doKillTdService
(
proc
:
Popen
,
sig
:
int
):
def
doKillTdService
(
proc
:
Popen
,
sig
:
int
):
Logging
.
info
(
"Killing sub-sub process {} with signal {}"
.
format
(
proc
.
pid
,
sig
))
Logging
.
info
(
"Killing sub-sub process {} with signal {}"
.
format
(
proc
.
pid
,
sig
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录