Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
loser646
TDengine
提交
9e8379a5
T
TDengine
项目概览
loser646
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9e8379a5
编写于
3月 05, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-3130
上级
32510fa4
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
63 addition
and
19 deletion
+63
-19
src/inc/taosdef.h
src/inc/taosdef.h
+2
-2
src/inc/taoserror.h
src/inc/taoserror.h
+3
-0
src/inc/taosmsg.h
src/inc/taosmsg.h
+2
-1
src/inc/tp.h
src/inc/tp.h
+1
-0
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+17
-12
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+15
-0
src/util/src/terror.c
src/util/src/terror.c
+3
-0
src/vnode/inc/vnodeInt.h
src/vnode/inc/vnodeInt.h
+2
-1
src/vnode/src/vnodeCfg.c
src/vnode/src/vnodeCfg.c
+13
-3
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+5
-0
未找到文件。
src/inc/taosdef.h
浏览文件 @
9e8379a5
...
...
@@ -309,8 +309,8 @@ do { \
#define TSDB_MAX_DB_REPLICA_OPTION 3
#define TSDB_DEFAULT_DB_REPLICA_OPTION 1
#define TSDB_MIN_DB_PARTITON_OPTION
1
#define TSDB_MAX_DB_PARTITON_OPTION
50
000
#define TSDB_MIN_DB_PARTITON_OPTION
0
#define TSDB_MAX_DB_PARTITON_OPTION
1
000
#define TSDB_DEFAULT_DB_PARTITON_OPTION 4
#define TSDB_MIN_DB_QUORUM_OPTION 1
...
...
src/inc/taoserror.h
浏览文件 @
9e8379a5
...
...
@@ -185,6 +185,9 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) //"Invalid database option: days out of range")
#define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) //"Invalid database option: keep >= keep1 >= keep0 >= days")
#define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) //"Invalid topic name)
#define TSDB_CODE_MND_INVALID_TOPIC_OPTION TAOS_DEF_ERROR_CODE(0, 0x0393) //"Invalid topic option)
// dnode
#define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) //"Message not processed")
#define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) //"Dnode out of memory")
...
...
src/inc/taosmsg.h
浏览文件 @
9e8379a5
...
...
@@ -683,7 +683,8 @@ typedef struct {
int8_t
cacheLastRow
;
int32_t
vgCfgVersion
;
int8_t
dbReplica
;
int8_t
reserved
[
9
];
int8_t
dbType
;
int8_t
reserved
[
8
];
}
SVnodeCfg
;
typedef
struct
{
...
...
src/inc/tp.h
浏览文件 @
9e8379a5
...
...
@@ -22,6 +22,7 @@ extern "C" {
int32_t
tpInit
();
void
tpCleanUp
();
void
tpUpdateTs
(
int32_t
*
seq
,
void
*
pMsg
);
#ifdef __cplusplus
}
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
9e8379a5
...
...
@@ -49,12 +49,13 @@ static int32_t mnodeSetDbDropping(SDbObj *pDb);
static
int32_t
mnodeGetDbMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeRetrieveDbs
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
int32_t
mnodeProcessCreateDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropDbMsg
(
SMnodeMsg
*
pMsg
);
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
);
#ifndef _TOPIC
int32_t
tpInit
()
{}
void
tpCleanUp
()
{}
void
tpUpdateTs
(
int32_t
*
seq
,
void
*
pMsg
)
{}
#endif
static
void
mnodeDestroyDb
(
SDbObj
*
pDb
)
{
...
...
@@ -180,16 +181,9 @@ int32_t mnodeInitDbs() {
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_DB
,
mnodeCancelGetNextDb
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_CREATE_TP
,
mnodeProcessCreateDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_ALTER_TP
,
mnodeProcessAlterDbMsg
);
mnodeAddWriteMsgHandle
(
TSDB_MSG_TYPE_CM_DROP_TP
,
mnodeProcessDropDbMsg
);
mnodeAddShowMetaHandle
(
TSDB_MGMT_TABLE_TP
,
mnodeGetDbMeta
);
mnodeAddShowRetrieveHandle
(
TSDB_MGMT_TABLE_TP
,
mnodeRetrieveDbs
);
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_TP
,
mnodeCancelGetNextDb
);
mDebug
(
"table:dbs table is created"
);
return
0
;
return
tpInit
()
;
}
void
*
mnodeGetNextDb
(
void
*
pIter
,
SDbObj
**
pDb
)
{
...
...
@@ -345,6 +339,17 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
if
(
pCfg
->
dbType
<
0
||
pCfg
->
dbType
>
1
)
{
mError
(
"invalid db option dbType:%d valid range: [%d, %d]"
,
pCfg
->
dbType
,
0
,
1
);
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
if
(
pCfg
->
partitions
<
TSDB_MIN_DB_PARTITON_OPTION
||
pCfg
->
partitions
>
TSDB_MAX_DB_PARTITON_OPTION
)
{
mError
(
"invalid db option partitions:%d valid range: [%d, %d]"
,
pCfg
->
partitions
,
TSDB_MIN_DB_PARTITON_OPTION
,
TSDB_MAX_DB_PARTITON_OPTION
);
return
TSDB_CODE_MND_INVALID_DB_OPTION
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -697,7 +702,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
pShow
->
pIter
=
mnodeGetNextDb
(
pShow
->
pIter
,
&
pDb
);
if
(
pDb
==
NULL
)
break
;
if
(
pDb
->
pAcct
!=
pUser
->
pAcct
||
pDb
->
status
!=
TSDB_DB_STATUS_READY
/*|| pDb->cfg.dbType != TSDB_DB_TYPE_DEFAULT*/
)
{
if
(
pDb
->
pAcct
!=
pUser
->
pAcct
||
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mnodeDecDbRef
(
pDb
);
continue
;
}
...
...
@@ -1092,7 +1097,7 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
return
code
;
}
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
SAlterDbMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mDebug
(
"db:%s, alter db msg is received from thandle:%p"
,
pAlter
->
db
,
pMsg
->
rpcMsg
.
handle
);
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
9e8379a5
...
...
@@ -367,6 +367,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
maxIdPoolSize
=
MAX
(
maxIdPoolSize
,
idPoolSize
);
}
// create one table each vnode
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
)
{
maxIdPoolSize
=
1
;
}
// new vgroup
if
(
pInputVgroup
->
idPool
==
NULL
)
{
pInputVgroup
->
idPool
=
taosInitIdPool
(
maxIdPoolSize
);
...
...
@@ -379,6 +384,11 @@ static int32_t mnodeAllocVgroupIdPool(SVgObj *pInputVgroup) {
}
}
// create one table each vnode
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
)
{
return
TSDB_CODE_SUCCESS
;
}
// realloc all vgroups in db
int32_t
newIdPoolSize
;
if
(
minIdPoolSize
*
4
<
tsTableIncStepPerVnode
)
{
...
...
@@ -449,6 +459,10 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi
maxVgroupsPerDb
=
MIN
(
maxVgroupsPerDb
,
TSDB_MAX_VNODES_PER_DB
);
}
if
(
pDb
->
cfg
.
dbType
==
TSDB_DB_TYPE_TOPIC
&&
pDb
->
cfg
.
partitions
>
0
)
{
maxVgroupsPerDb
=
pDb
->
cfg
.
partitions
;
}
int32_t
code
=
TSDB_CODE_MND_NO_ENOUGH_DNODES
;
if
(
pDb
->
numOfVgroups
<
maxVgroupsPerDb
)
{
mDebug
(
"msg:%p, app:%p db:%s, try to create a new vgroup, numOfVgroups:%d maxVgroupsPerDb:%d"
,
pMsg
,
...
...
@@ -880,6 +894,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
pCfg
->
update
=
pDb
->
cfg
.
update
;
pCfg
->
cacheLastRow
=
pDb
->
cfg
.
cacheLastRow
;
pCfg
->
dbReplica
=
pDb
->
cfg
.
replications
;
pCfg
->
dbType
=
pDb
->
cfg
.
dbType
;
SVnodeDesc
*
pNodes
=
pVnode
->
nodes
;
for
(
int32_t
j
=
0
;
j
<
pVgroup
->
numOfVnodes
;
++
j
)
{
...
...
src/util/src/terror.c
浏览文件 @
9e8379a5
...
...
@@ -197,6 +197,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_READY, "Database unsynced")
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_DB_OPTION_DAYS
,
"Invalid database option: days out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_DB_OPTION_KEEP
,
"Invalid database option: keep >= keep1 >= keep0 >= days"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TOPIC
,
"Invalid topic name"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_TOPIC_OPTION
,
"Invalid topic option"
)
// dnode
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_MSG_NOT_PROCESSED
,
"Message not processed"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DND_OUT_OF_MEMORY
,
"Dnode out of memory"
)
...
...
src/vnode/inc/vnodeInt.h
浏览文件 @
9e8379a5
...
...
@@ -40,6 +40,7 @@ typedef struct {
int32_t
queuedWMsg
;
int32_t
queuedRMsg
;
int32_t
flowctrlLevel
;
int32_t
sequence
;
// for topic
int8_t
status
;
int8_t
role
;
int8_t
accessState
;
...
...
@@ -47,7 +48,7 @@ typedef struct {
int8_t
isCommiting
;
int8_t
dbReplica
;
int8_t
dropped
;
int8_t
reserved
;
int8_t
dbType
;
uint64_t
version
;
// current version
uint64_t
cversion
;
// version while commit start
uint64_t
fversion
;
// version on saved data file
...
...
src/vnode/src/vnodeCfg.c
浏览文件 @
9e8379a5
...
...
@@ -42,6 +42,7 @@ static void vnodeLoadCfg(SVnodeObj *pVnode, SCreateVnodeMsg* vnodeMsg) {
pVnode
->
syncCfg
.
replica
=
vnodeMsg
->
cfg
.
vgReplica
;
pVnode
->
syncCfg
.
quorum
=
vnodeMsg
->
cfg
.
quorum
;
pVnode
->
dbReplica
=
vnodeMsg
->
cfg
.
dbReplica
;
pVnode
->
dbType
=
vnodeMsg
->
cfg
.
dbType
;
for
(
int
i
=
0
;
i
<
pVnode
->
syncCfg
.
replica
;
++
i
)
{
SVnodeDesc
*
node
=
&
vnodeMsg
->
nodes
[
i
];
...
...
@@ -214,7 +215,7 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
dbReplica
=
cJSON_GetObjectItem
(
root
,
"dbReplica"
);
if
(
!
dbReplica
||
dbReplica
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId:%d, failed to read %s, dbReplica not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId:%d, failed to read %s, dbReplica not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
dbReplica
=
vnodeMsg
.
cfg
.
vgReplica
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
...
...
@@ -230,7 +231,7 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
update
=
cJSON_GetObjectItem
(
root
,
"update"
);
if
(
!
update
||
update
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId: %d, failed to read %s, update not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId: %d, failed to read %s, update not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
update
=
0
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
...
...
@@ -239,13 +240,21 @@ int32_t vnodeReadCfg(SVnodeObj *pVnode) {
cJSON
*
cacheLastRow
=
cJSON_GetObjectItem
(
root
,
"cacheLastRow"
);
if
(
!
cacheLastRow
||
cacheLastRow
->
type
!=
cJSON_Number
)
{
v
Error
(
"vgId: %d, failed to read %s, cacheLastRow not found"
,
pVnode
->
vgId
,
file
);
v
Warn
(
"vgId: %d, failed to read %s, cacheLastRow not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
cacheLastRow
=
0
;
vnodeMsg
.
cfg
.
vgCfgVersion
=
0
;
}
else
{
vnodeMsg
.
cfg
.
cacheLastRow
=
(
int8_t
)
cacheLastRow
->
valueint
;
}
cJSON
*
dbType
=
cJSON_GetObjectItem
(
root
,
"dbType"
);
if
(
!
dbType
||
dbType
->
type
!=
cJSON_Number
)
{
vWarn
(
"vgId: %d, failed to read %s, dbType not found"
,
pVnode
->
vgId
,
file
);
vnodeMsg
.
cfg
.
dbType
=
0
;
}
else
{
vnodeMsg
.
cfg
.
dbType
=
(
int8_t
)
dbType
->
valueint
;
}
cJSON
*
nodeInfos
=
cJSON_GetObjectItem
(
root
,
"nodeInfos"
);
if
(
!
nodeInfos
||
nodeInfos
->
type
!=
cJSON_Array
)
{
vError
(
"vgId:%d, failed to read %s, nodeInfos not found"
,
pVnode
->
vgId
,
file
);
...
...
@@ -337,6 +346,7 @@ int32_t vnodeWriteCfg(SCreateVnodeMsg *pMsg) {
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
quorum
\"
: %d,
\n
"
,
pMsg
->
cfg
.
quorum
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
update
\"
: %d,
\n
"
,
pMsg
->
cfg
.
update
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
cacheLastRow
\"
: %d,
\n
"
,
pMsg
->
cfg
.
cacheLastRow
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
dbType
\"
: %d,
\n
"
,
pMsg
->
cfg
.
dbType
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
nodeInfos
\"
: [{
\n
"
);
for
(
int32_t
i
=
0
;
i
<
pMsg
->
cfg
.
vgReplica
;
i
++
)
{
SVnodeDesc
*
node
=
&
pMsg
->
nodes
[
i
];
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
9e8379a5
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "os.h"
#include "tp.h"
#include "taosmsg.h"
#include "taoserror.h"
#include "tglobal.h"
...
...
@@ -139,6 +140,10 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR
vTrace
(
"vgId:%d, submit msg is processed"
,
pVnode
->
vgId
);
if
(
pVnode
->
dbType
==
TSDB_DB_TYPE_TOPIC
&&
pVnode
->
role
==
TAOS_SYNC_ROLE_MASTER
)
{
tpUpdateTs
(
&
pVnode
->
sequence
,
pCont
);
}
// save insert result into item
SShellSubmitRspMsg
*
pRsp
=
NULL
;
if
(
pRet
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录