Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1da21799
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
1da21799
编写于
6月 16, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-570] update logs
上级
15f0e77c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
134 addition
and
93 deletion
+134
-93
src/mnode/inc/mnodeInt.h
src/mnode/inc/mnodeInt.h
+4
-4
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+3
-3
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+127
-86
未找到文件。
src/mnode/inc/mnodeInt.h
浏览文件 @
1da21799
...
@@ -36,10 +36,10 @@ extern int32_t sdbDebugFlag;
...
@@ -36,10 +36,10 @@ extern int32_t sdbDebugFlag;
#define mLWarn(...) { monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
#define mLWarn(...) { monitorSaveLog(1, __VA_ARGS__); mWarn(__VA_ARGS__) }
#define mLPrint(...) { monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) }
#define mLPrint(...) { monitorSaveLog(0, __VA_ARGS__); mPrint(__VA_ARGS__) }
#define sdbError(...) { if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR
MND-
SDB ", 255, __VA_ARGS__); }}
#define sdbError(...) { if (sdbDebugFlag & DEBUG_ERROR) { taosPrintLog("ERROR SDB ", 255, __VA_ARGS__); }}
#define sdbWarn(...) { if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN
MND-
SDB ", sdbDebugFlag, __VA_ARGS__); }}
#define sdbWarn(...) { if (sdbDebugFlag & DEBUG_WARN) { taosPrintLog("WARN SDB ", sdbDebugFlag, __VA_ARGS__); }}
#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("
MND-
SDB ", sdbDebugFlag, __VA_ARGS__);}}
#define sdbTrace(...) { if (sdbDebugFlag & DEBUG_TRACE) { taosPrintLog("SDB ", sdbDebugFlag, __VA_ARGS__);}}
#define sdbPrint(...) { taosPrintLog("
MND-
SDB ", 255, __VA_ARGS__); }
#define sdbPrint(...) { taosPrintLog("SDB ", 255, __VA_ARGS__); }
#define sdbLError(...) { monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) }
#define sdbLError(...) { monitorSaveLog(2, __VA_ARGS__); sdbError(__VA_ARGS__) }
#define sdbLWarn(...) { monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) }
#define sdbLWarn(...) { monitorSaveLog(1, __VA_ARGS__); sdbWarn(__VA_ARGS__) }
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
1da21799
...
@@ -643,7 +643,7 @@ int32_t sdbInsertRow(SSdbOper *pOper) {
...
@@ -643,7 +643,7 @@ int32_t sdbInsertRow(SSdbOper *pOper) {
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, insert action is add to
write
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
sdbTrace
(
"app:%p:%p, insert action is add to
sdb
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
}
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
...
@@ -704,7 +704,7 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
...
@@ -704,7 +704,7 @@ int32_t sdbDeleteRow(SSdbOper *pOper) {
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, delete action is add to
write
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
sdbTrace
(
"app:%p:%p, delete action is add to
sdb
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
}
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
...
@@ -752,7 +752,7 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
...
@@ -752,7 +752,7 @@ int32_t sdbUpdateRow(SSdbOper *pOper) {
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, update action is add to
write
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
sdbTrace
(
"app:%p:%p, update action is add to
sdb
queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
}
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
...
...
src/mnode/src/mnodeTable.c
浏览文件 @
1da21799
...
@@ -669,20 +669,21 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
...
@@ -669,20 +669,21 @@ static int32_t mnodeProcessCreateTableMsg(SMnodeMsg *pMsg) {
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDb
(
pCreate
->
db
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDb
(
pCreate
->
db
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"
table:%s, failed to create, db not selected"
,
pCreate
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to create, db not selected"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
}
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pCreate
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pCreate
->
tableId
);
if
(
pMsg
->
pTable
!=
NULL
&&
pMsg
->
retry
==
0
)
{
if
(
pMsg
->
pTable
!=
NULL
&&
pMsg
->
retry
==
0
)
{
if
(
pCreate
->
getMeta
)
{
if
(
pCreate
->
getMeta
)
{
mTrace
(
"
table:%s, continue to get meta"
,
pCreate
->
tableId
);
mTrace
(
"
app:%p:%p, table:%s, continue to get meta"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
mnodeGetChildTableMeta
(
pMsg
);
return
mnodeGetChildTableMeta
(
pMsg
);
}
else
if
(
pCreate
->
igExists
)
{
}
else
if
(
pCreate
->
igExists
)
{
mTrace
(
"
table:%s, is already exist"
,
pCreate
->
tableId
);
mTrace
(
"
app:%p:%p, table:%s, is already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
mError
(
"table:%s, failed to create, table already exist"
,
pCreate
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to create, table already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_TABLE_ALREADY_EXIST
;
return
TSDB_CODE_MND_TABLE_ALREADY_EXIST
;
}
}
}
}
...
@@ -702,31 +703,32 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -702,31 +703,32 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
SCMDropTableMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
SCMDropTableMsg
*
pDrop
=
pMsg
->
rpcMsg
.
pCont
;
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pDrop
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pDrop
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"
table:%s, failed to drop table, db not selected"
,
pDrop
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to drop table, db not selected"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
}
}
if
(
mnodeCheckIsMonitorDB
(
pMsg
->
pDb
->
name
,
tsMonitorDbName
))
{
if
(
mnodeCheckIsMonitorDB
(
pMsg
->
pDb
->
name
,
tsMonitorDbName
))
{
mError
(
"table:%s, failed to drop table, in monitor database"
,
pDrop
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to drop table, in monitor database"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
TSDB_CODE_MND_MONITOR_DB_FORBIDDEN
;
return
TSDB_CODE_MND_MONITOR_DB_FORBIDDEN
;
}
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pDrop
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pDrop
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
pDrop
->
igNotExists
)
{
if
(
pDrop
->
igNotExists
)
{
mTrace
(
"
table:%s, table is not exist, think drop success"
,
pDrop
->
tableId
);
mTrace
(
"
app:%p:%p, table:%s, table is not exist, think drop success"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
else
{
}
else
{
mError
(
"
table:%s, failed to drop table, table not exist"
,
pDrop
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to drop table, table not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
}
}
}
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
mPrint
(
"
table:%s, start to drop stable"
,
pDrop
->
tableId
);
mPrint
(
"
app:%p:%p, table:%s, start to drop stable"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
mnodeProcessDropSuperTableMsg
(
pMsg
);
return
mnodeProcessDropSuperTableMsg
(
pMsg
);
}
else
{
}
else
{
mPrint
(
"
table:%s, start to drop ctable"
,
pDrop
->
tableId
);
mPrint
(
"
app:%p:%p, table:%s, start to drop ctable"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
return
mnodeProcessDropChildTableMsg
(
pMsg
);
return
mnodeProcessDropChildTableMsg
(
pMsg
);
}
}
}
}
...
@@ -734,21 +736,25 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
...
@@ -734,21 +736,25 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessTableMetaMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessTableMetaMsg
(
SMnodeMsg
*
pMsg
)
{
SCMTableInfoMsg
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
SCMTableInfoMsg
*
pInfo
=
pMsg
->
rpcMsg
.
pCont
;
pInfo
->
createFlag
=
htons
(
pInfo
->
createFlag
);
pInfo
->
createFlag
=
htons
(
pInfo
->
createFlag
);
mTrace
(
"table:%s, table meta msg is received from thandle:%p, createFlag:%d"
,
pInfo
->
tableId
,
pMsg
->
rpcMsg
.
handle
,
pInfo
->
createFlag
);
mTrace
(
"app:%p:%p, table:%s, table meta msg is received from thandle:%p, createFlag:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
,
pMsg
->
rpcMsg
.
handle
,
pInfo
->
createFlag
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pInfo
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pInfo
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"table:%s, failed to get table meta, db not selected"
,
pInfo
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to get table meta, db not selected"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
);
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
}
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pInfo
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pInfo
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
!
pInfo
->
createFlag
)
{
if
(
!
pInfo
->
createFlag
)
{
mError
(
"table:%s, failed to get table meta, table not exist"
,
pInfo
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to get table meta, table not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
else
{
}
else
{
mTrace
(
"table:%s, failed to get table meta, start auto create table "
,
pInfo
->
tableId
);
mTrace
(
"app:%p:%p, table:%s, failed to get table meta, start auto create table "
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
);
return
mnodeAutoCreateChildTable
(
pMsg
);
return
mnodeAutoCreateChildTable
(
pMsg
);
}
}
}
else
{
}
else
{
...
@@ -762,9 +768,9 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
...
@@ -762,9 +768,9 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
static
int32_t
mnodeProcessCreateSuperTableMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessCreateSuperTableMsg
(
SMnodeMsg
*
pMsg
)
{
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SSuperTableObj
*
pStable
=
calloc
(
1
,
sizeof
(
SSuperTableObj
));
SSuperTableObj
*
pStable
=
calloc
(
1
,
sizeof
(
SSuperTableObj
));
if
(
pStable
==
NULL
)
{
if
(
pStable
==
NULL
)
{
mError
(
"
table:%s, failed to create, no enough memory"
,
pCreate
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to create, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
...
@@ -782,7 +788,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -782,7 +788,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
pStable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
pStable
->
schema
=
(
SSchema
*
)
calloc
(
1
,
schemaSize
);
if
(
pStable
->
schema
==
NULL
)
{
if
(
pStable
->
schema
==
NULL
)
{
free
(
pStable
);
free
(
pStable
);
mError
(
"
table:%s, failed to create, no schema input"
,
pCreate
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to create, no schema input"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
}
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
memcpy
(
pStable
->
schema
,
pCreate
->
schema
,
numOfCols
*
sizeof
(
SSchema
));
...
@@ -808,9 +814,10 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -808,9 +814,10 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
int32_t
code
=
sdbInsertRow
(
&
oper
);
int32_t
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mnodeDestroySuperTable
(
pStable
);
mnodeDestroySuperTable
(
pStable
);
mError
(
"
table:%s, failed to create, sdb error"
,
pCreate
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to create, sdb error"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
}
else
{
}
else
{
mLPrint
(
"table:%s, is created, tags:%d fields:%d"
,
pStable
->
info
.
tableId
,
pStable
->
numOfTags
,
pStable
->
numOfColumns
);
mLPrint
(
"app:%p:%p, table:%s, is created, tags:%d fields:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
pStable
->
numOfTags
,
pStable
->
numOfColumns
);
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
...
@@ -831,10 +838,11 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
...
@@ -831,10 +838,11 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
pDrop
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pDrop
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pDrop
->
uid
=
htobe64
(
pStable
->
uid
);
pDrop
->
uid
=
htobe64
(
pStable
->
uid
);
mnodeExtractTableName
(
pStable
->
info
.
tableId
,
pDrop
->
tableId
);
mnodeExtractTableName
(
pStable
->
info
.
tableId
,
pDrop
->
tableId
);
mPrint
(
"stable:%s, send drop stable msg to vgId:%d"
,
pStable
->
info
.
tableId
,
pVgroup
->
vgId
);
mPrint
(
"app:%p:%p, stable:%s, send drop stable msg to vgId:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
pVgroup
->
vgId
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromVgroup
(
pVgroup
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromVgroup
(
pVgroup
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pDrop
,
.
contLen
=
sizeof
(
SMDDropSTableMsg
),
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_STABLE
};
SRpcMsg
rpcMsg
=
{.
pCont
=
pDrop
,
.
contLen
=
sizeof
(
SMDDropSTableMsg
),
.
msgType
=
TSDB_MSG_TYPE_MD_DROP_STABLE
};
dnodeSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
dnodeSendMsgToDnode
(
&
ipSet
,
&
rpcMsg
);
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
}
}
...
@@ -872,18 +880,20 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
...
@@ -872,18 +880,20 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
static
int32_t
mnodeAddSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ntags
)
{
static
int32_t
mnodeAddSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ntags
)
{
if
(
pStable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
if
(
pStable
->
numOfTags
+
ntags
>
TSDB_MAX_TAGS
)
{
mError
(
"
stable:%s, add tag, too many tags"
,
pStable
->
info
.
tableId
);
mError
(
"
app:%p:%p, stable:%s, add tag, too many tags"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_MND_TOO_MANY_TAGS
;
return
TSDB_CODE_MND_TOO_MANY_TAGS
;
}
}
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
ntags
;
i
++
)
{
if
(
mnodeFindSuperTableColumnIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
if
(
mnodeFindSuperTableColumnIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"stable:%s, add tag, column:%s already exist"
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
mError
(
"app:%p:%p, stable:%s, add tag, column:%s already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
return
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
return
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
}
}
if
(
mnodeFindSuperTableTagIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
if
(
mnodeFindSuperTableTagIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"stable:%s, add tag, tag:%s already exist"
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
mError
(
"app:%p:%p, stable:%s, add tag, tag:%s already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
}
}
}
...
@@ -910,17 +920,19 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSuperTableObj *pStable, S
...
@@ -910,17 +920,19 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSuperTableObj *pStable, S
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"stable %s, succeed to add tag %s"
,
pStable
->
info
.
tableId
,
schema
[
0
].
name
);
mPrint
(
"app:%p:%p, stable %s, succeed to add tag %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
schema
[
0
].
name
);
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
static
int32_t
mnodeDropSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
char
*
tagName
)
{
static
int32_t
mnodeDropSuperTableTag
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
char
*
tagName
)
{
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
tagName
);
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
tagName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"stable:%s, drop tag, tag:%s not exist"
,
pStable
->
info
.
tableId
,
tagName
);
mError
(
"app:%p:%p, stable:%s, drop tag, tag:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tagName
);
return
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
TSDB_CODE_MND_TAG_NOT_EXIST
;
}
}
...
@@ -938,17 +950,19 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, SSuperTableObj *pStable,
...
@@ -938,17 +950,19 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, SSuperTableObj *pStable,
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"
stable %s, succeed to drop tag %s"
,
pStable
->
info
.
tableId
,
tagName
);
mPrint
(
"
app:%p:%p, stable %s, succeed to drop tag %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
tagName
);
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
static
int32_t
mnodeModifySuperTableTagName
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
char
*
oldTagName
,
char
*
newTagName
)
{
static
int32_t
mnodeModifySuperTableTagName
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
char
*
oldTagName
,
char
*
newTagName
)
{
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
oldTagName
);
int32_t
col
=
mnodeFindSuperTableTagIndex
(
pStable
,
oldTagName
);
if
(
col
<
0
)
{
if
(
col
<
0
)
{
mError
(
"stable:%s, failed to modify table tag, oldName: %s, newName: %s"
,
pStable
->
info
.
tableId
,
oldTagName
,
newTagName
);
mError
(
"app:%p:%p, stable:%s, failed to modify table tag, oldName: %s, newName: %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
oldTagName
,
newTagName
);
return
TSDB_CODE_MND_TAG_NOT_EXIST
;
return
TSDB_CODE_MND_TAG_NOT_EXIST
;
}
}
...
@@ -975,7 +989,8 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, SSuperTableObj *pSt
...
@@ -975,7 +989,8 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, SSuperTableObj *pSt
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"stable %s, succeed to modify tag %s to %s"
,
pStable
->
info
.
tableId
,
oldTagName
,
newTagName
);
mPrint
(
"app:%p:%p, stable %s, succeed to modify tag %s to %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
oldTagName
,
newTagName
);
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
...
@@ -996,18 +1011,20 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
...
@@ -996,18 +1011,20 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
static
int32_t
mnodeAddSuperTableColumn
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ncols
)
{
static
int32_t
mnodeAddSuperTableColumn
(
SMnodeMsg
*
pMsg
,
SSuperTableObj
*
pStable
,
SSchema
schema
[],
int32_t
ncols
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
if
(
ncols
<=
0
)
{
if
(
ncols
<=
0
)
{
mError
(
"
stable:%s, add column, ncols:%d <= 0"
,
pStable
->
info
.
tableId
);
mError
(
"
app:%p:%p, stable:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
return
TSDB_CODE_MND_APP_ERROR
;
return
TSDB_CODE_MND_APP_ERROR
;
}
}
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mnodeFindSuperTableColumnIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
if
(
mnodeFindSuperTableColumnIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"stable:%s, add column, column:%s already exist"
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
mError
(
"app:%p:%p, stable:%s, add column, column:%s already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
}
if
(
mnodeFindSuperTableTagIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
if
(
mnodeFindSuperTableTagIndex
(
pStable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"stable:%s, add column, tag:%s already exist"
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
mError
(
"app:%p:%p, stable:%s, add column, tag:%s already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
schema
[
i
].
name
);
return
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
return
TSDB_CODE_MND_TAG_ALREAY_EXIST
;
}
}
}
}
...
@@ -1042,7 +1059,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStable
...
@@ -1042,7 +1059,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStable
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"
stable %s, succeed to add column"
,
pStable
->
info
.
tableId
);
mPrint
(
"
app:%p:%p, stable %s, succeed to add column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
...
@@ -1053,7 +1070,8 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStabl
...
@@ -1053,7 +1070,8 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStabl
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
colName
);
int32_t
col
=
mnodeFindSuperTableColumnIndex
(
pStable
,
colName
);
if
(
col
<=
0
)
{
if
(
col
<=
0
)
{
mError
(
"stable:%s, drop column, column:%s not exist"
,
pStable
->
info
.
tableId
,
colName
);
mError
(
"app:%p:%p, stable:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
,
colName
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
}
...
@@ -1081,10 +1099,10 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStabl
...
@@ -1081,10 +1099,10 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, SSuperTableObj *pStabl
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"
stable %s, succeed to delete column"
,
pStable
->
info
.
tableId
);
mPrint
(
"
app:%p:%p, stable %s, succeed to delete column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pStable
->
info
.
tableId
);
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
...
@@ -1274,8 +1292,9 @@ static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
...
@@ -1274,8 +1292,9 @@ static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
pMeta
->
contLen
=
htons
(
pMeta
->
contLen
);
pMeta
->
contLen
=
htons
(
pMeta
->
contLen
);
pMsg
->
rpcRsp
.
rsp
=
pMeta
;
pMsg
->
rpcRsp
.
rsp
=
pMeta
;
mTrace
(
"stable:%s, uid:%"
PRIu64
" table meta is retrieved"
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
mTrace
(
"app:%p:%p, stable:%s, uid:%"
PRIu64
" table meta is retrieved"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1306,12 +1325,13 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
...
@@ -1306,12 +1325,13 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
;
char
*
stableName
=
(
char
*
)
pInfo
+
sizeof
(
SCMSTableVgroupMsg
)
+
(
TSDB_TABLE_ID_LEN
)
*
i
;
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
SSuperTableObj
*
pTable
=
mnodeGetSuperTable
(
stableName
);
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"
stable:%s, not exist while get stable vgroup info"
,
stableName
);
mError
(
"
app:%p:%p, stable:%s, not exist while get stable vgroup info"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
stableName
);
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
continue
;
continue
;
}
}
if
(
pTable
->
vgHash
==
NULL
)
{
if
(
pTable
->
vgHash
==
NULL
)
{
mError
(
"stable:%s, not vgroup exist while get stable vgroup info"
,
stableName
);
mError
(
"app:%p:%p, stable:%s, not vgroup exist while get stable vgroup info"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
stableName
);
mnodeDecTableRef
(
pTable
);
mnodeDecTableRef
(
pTable
);
// even this super table has no corresponding table, still return
// even this super table has no corresponding table, still return
...
@@ -1473,7 +1493,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
...
@@ -1473,7 +1493,7 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateTableMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SChildTableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SChildTableObj
));
SChildTableObj
*
pTable
=
calloc
(
1
,
sizeof
(
SChildTableObj
));
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"
table:%s, failed to alloc memory"
,
pCreate
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to alloc memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
...
@@ -1492,7 +1512,8 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
...
@@ -1492,7 +1512,8 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
STagData
*
pTagData
=
(
STagData
*
)
pCreate
->
schema
;
// it is a tag key
STagData
*
pTagData
=
(
STagData
*
)
pCreate
->
schema
;
// it is a tag key
SSuperTableObj
*
pSuperTable
=
mnodeGetSuperTable
(
pTagData
->
name
);
SSuperTableObj
*
pSuperTable
=
mnodeGetSuperTable
(
pTagData
->
name
);
if
(
pSuperTable
==
NULL
)
{
if
(
pSuperTable
==
NULL
)
{
mError
(
"table:%s, corresponding super table:%s does not exist"
,
pCreate
->
tableId
,
pTagData
->
name
);
mError
(
"app:%p:%p, table:%s, corresponding super table:%s does not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
,
pTagData
->
name
);
mnodeDestroyChildTable
(
pTable
);
mnodeDestroyChildTable
(
pTable
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
}
...
@@ -1533,7 +1554,8 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
...
@@ -1533,7 +1554,8 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
}
}
memcpy
(
pTable
->
sql
,
(
char
*
)
(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pTable
->
sqlLen
);
memcpy
(
pTable
->
sql
,
(
char
*
)
(
pCreate
->
schema
)
+
numOfCols
*
sizeof
(
SSchema
),
pTable
->
sqlLen
);
pTable
->
sql
[
pTable
->
sqlLen
-
1
]
=
0
;
pTable
->
sql
[
pTable
->
sqlLen
-
1
]
=
0
;
mTrace
(
"table:%s, stream sql len:%d sql:%s"
,
pTable
->
info
.
tableId
,
pTable
->
sqlLen
,
pTable
->
sql
);
mTrace
(
"app:%p:%p, table:%s, stream sql len:%d sql:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
pTable
->
sqlLen
,
pTable
->
sql
);
}
}
}
}
...
@@ -1550,12 +1572,13 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
...
@@ -1550,12 +1572,13 @@ static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
int32_t
code
=
sdbInsertRow
(
&
desc
);
int32_t
code
=
sdbInsertRow
(
&
desc
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
free
(
pTable
);
free
(
pTable
);
mError
(
"table:%s, update sdb error"
,
pCreate
->
tableId
);
mError
(
"app:%p:%p, table:%s, update sdb error, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCreate
->
tableId
,
tstrerror
(
code
));
pMsg
->
pTable
=
NULL
;
pMsg
->
pTable
=
NULL
;
return
code
;
return
code
;
}
else
{
}
else
{
mTrace
(
"
table:%s, create table in vgroup:%d, id:%d, uid:%"
PRIu64
,
pTable
->
info
.
tableId
,
pVgroup
->
vgId
,
pTable
->
sid
,
mTrace
(
"
app:%p:%p, table:%s, create table in vgroup:%d, id:%d, uid:%"
PRIu64
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
uid
);
pTable
->
info
.
tableId
,
pVgroup
->
vgId
,
pTable
->
sid
,
pTable
->
uid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
}
}
...
@@ -1617,13 +1640,15 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
...
@@ -1617,13 +1640,15 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to drop ctable, vgroup not exist"
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, table:%s, failed to drop ctable, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_APP_ERROR
;
return
TSDB_CODE_MND_APP_ERROR
;
}
}
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
SMDDropTableMsg
*
pDrop
=
rpcMallocCont
(
sizeof
(
SMDDropTableMsg
));
if
(
pDrop
==
NULL
)
{
if
(
pDrop
==
NULL
)
{
mError
(
"table:%s, failed to drop ctable, no enough memory"
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, table:%s, failed to drop ctable, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
...
@@ -1635,7 +1660,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
...
@@ -1635,7 +1660,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
SRpcIpSet
ipSet
=
mnodeGetIpSetFromVgroup
(
pMsg
->
pVgroup
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromVgroup
(
pMsg
->
pVgroup
);
mPrint
(
"
table:%s, send drop ctable msg"
,
pDrop
->
tableId
);
mPrint
(
"
app:%p:%p, table:%s, send drop ctable msg"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pDrop
->
tableId
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
pMsg
,
.
handle
=
pMsg
,
.
pCont
=
pDrop
,
.
pCont
=
pDrop
,
...
@@ -1667,13 +1692,14 @@ static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *col
...
@@ -1667,13 +1692,14 @@ static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *col
static
int32_t
mnodeAddNormalTableColumn
(
SMnodeMsg
*
pMsg
,
SChildTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
)
{
static
int32_t
mnodeAddNormalTableColumn
(
SMnodeMsg
*
pMsg
,
SChildTableObj
*
pTable
,
SSchema
schema
[],
int32_t
ncols
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
if
(
ncols
<=
0
)
{
if
(
ncols
<=
0
)
{
mError
(
"
table:%s, add column, ncols:%d <= 0"
,
pTable
->
info
.
tableId
);
mError
(
"
app:%p:%p, table:%s, add column, ncols:%d <= 0"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_APP_ERROR
;
return
TSDB_CODE_MND_APP_ERROR
;
}
}
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
ncols
;
i
++
)
{
if
(
mnodeFindNormalTableColumnIndex
(
pTable
,
schema
[
i
].
name
)
>
0
)
{
if
(
mnodeFindNormalTableColumnIndex
(
pTable
,
schema
[
i
].
name
)
>
0
)
{
mError
(
"table:%s, add column, column:%s already exist"
,
pTable
->
info
.
tableId
,
schema
[
i
].
name
);
mError
(
"app:%p:%p, table:%s, add column, column:%s already exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
schema
[
i
].
name
);
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
return
TSDB_CODE_MND_FIELD_ALREAY_EXIST
;
}
}
}
}
...
@@ -1706,10 +1732,10 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTable
...
@@ -1706,10 +1732,10 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTable
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mPrint
(
"
table %s, succeed to add column"
,
pTable
->
info
.
tableId
);
mPrint
(
"
app:%p:%p, table %s, succeed to add column"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
...
@@ -1717,7 +1743,8 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTabl
...
@@ -1717,7 +1743,8 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTabl
SDbObj
*
pDb
=
pMsg
->
pDb
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
colName
);
int32_t
col
=
mnodeFindNormalTableColumnIndex
(
pTable
,
colName
);
if
(
col
<=
0
)
{
if
(
col
<=
0
)
{
mError
(
"table:%s, drop column, column:%s not exist"
,
pTable
->
info
.
tableId
,
colName
);
mError
(
"app:%p:%p, table:%s, drop column, column:%s not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
colName
);
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
return
TSDB_CODE_MND_FIELD_NOT_EXIST
;
}
}
...
@@ -1740,10 +1767,10 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTabl
...
@@ -1740,10 +1767,10 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, SChildTableObj *pTabl
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mPrint
(
"
table %s, succeed to drop column %s"
,
pTable
->
info
.
tableId
,
colName
);
mPrint
(
"
app:%p:%p, table %s, succeed to drop column %s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
colName
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
...
@@ -1783,10 +1810,11 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
...
@@ -1783,10 +1810,11 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
pMeta
->
numOfColumns
=
htons
((
int16_t
)
pTable
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
((
int16_t
)
pTable
->
numOfColumns
);
pMeta
->
contLen
=
sizeof
(
STableMetaMsg
)
+
mnodeSetSchemaFromNormalTable
(
pMeta
->
schema
,
pTable
);
pMeta
->
contLen
=
sizeof
(
STableMetaMsg
)
+
mnodeSetSchemaFromNormalTable
(
pMeta
->
schema
,
pTable
);
}
}
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
pMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
pMsg
->
pVgroup
==
NULL
)
{
if
(
pMsg
->
pVgroup
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, vgroup not exist"
,
pTable
->
info
.
tableId
);
mError
(
"app:%p:%p, table:%s, failed to get table meta, vgroup not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
);
return
TSDB_CODE_MND_VGROUP_NOT_EXIST
;
return
TSDB_CODE_MND_VGROUP_NOT_EXIST
;
}
}
...
@@ -1800,7 +1828,8 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
...
@@ -1800,7 +1828,8 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
}
}
pMeta
->
vgroup
.
vgId
=
htonl
(
pMsg
->
pVgroup
->
vgId
);
pMeta
->
vgroup
.
vgId
=
htonl
(
pMsg
->
pVgroup
->
vgId
);
mTrace
(
"table:%s, uid:%"
PRIu64
" table meta is retrieved"
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
mTrace
(
"app:%p:%p, table:%s, uid:%"
PRIu64
" table meta is retrieved"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pTable
->
info
.
tableId
,
pTable
->
uid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1812,7 +1841,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
...
@@ -1812,7 +1841,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
int32_t
contLen
=
sizeof
(
SCMCreateTableMsg
)
+
offsetof
(
STagData
,
data
)
+
ntohl
(
pTag
->
dataLen
);
int32_t
contLen
=
sizeof
(
SCMCreateTableMsg
)
+
offsetof
(
STagData
,
data
)
+
ntohl
(
pTag
->
dataLen
);
SCMCreateTableMsg
*
pCreateMsg
=
rpcMallocCont
(
contLen
);
SCMCreateTableMsg
*
pCreateMsg
=
rpcMallocCont
(
contLen
);
if
(
pCreateMsg
==
NULL
)
{
if
(
pCreateMsg
==
NULL
)
{
mError
(
"table:%s, failed to create table while get meta info, no enough memory"
,
pInfo
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to create table while get meta info, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
...
@@ -1824,7 +1854,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
...
@@ -1824,7 +1854,8 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
pCreateMsg
->
contLen
=
htonl
(
contLen
);
pCreateMsg
->
contLen
=
htonl
(
contLen
);
memcpy
(
pCreateMsg
->
schema
,
pInfo
->
tags
,
contLen
-
sizeof
(
SCMCreateTableMsg
));
memcpy
(
pCreateMsg
->
schema
,
pInfo
->
tags
,
contLen
-
sizeof
(
SCMCreateTableMsg
));
mTrace
(
"table:%s, start to create on demand, stable:%s"
,
pInfo
->
tableId
,
((
STagData
*
)(
pCreateMsg
->
schema
))
->
name
);
mTrace
(
"app:%p:%p, table:%s, start to create on demand, stable:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pInfo
->
tableId
,
((
STagData
*
)(
pCreateMsg
->
schema
))
->
name
);
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
pMsg
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CM_CREATE_TABLE
;
pMsg
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CM_CREATE_TABLE
;
...
@@ -1835,9 +1866,11 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
...
@@ -1835,9 +1866,11 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
}
}
static
int32_t
mnodeGetChildTableMeta
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeGetChildTableMeta
(
SMnodeMsg
*
pMsg
)
{
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
));
STableMetaMsg
*
pMeta
=
rpcMallocCont
(
sizeof
(
STableMetaMsg
)
+
sizeof
(
SSchema
)
*
(
TSDB_MAX_TAGS
+
TSDB_MAX_COLUMNS
+
16
));
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
mError
(
"table:%s, failed to get table meta, no enough memory"
,
pMsg
->
pTable
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to get table meta, no enough memory"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pMsg
->
pTable
->
tableId
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
}
...
@@ -1952,11 +1985,13 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
...
@@ -1952,11 +1985,13 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
dnodeId
=
htonl
(
pCfg
->
dnodeId
);
pCfg
->
vgId
=
htonl
(
pCfg
->
vgId
);
pCfg
->
vgId
=
htonl
(
pCfg
->
vgId
);
pCfg
->
sid
=
htonl
(
pCfg
->
sid
);
pCfg
->
sid
=
htonl
(
pCfg
->
sid
);
mTrace
(
"dnode:%d, vgId:%d sid:%d, receive table config msg"
,
pCfg
->
dnodeId
,
pCfg
->
vgId
,
pCfg
->
sid
);
mTrace
(
"app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCfg
->
dnodeId
,
pCfg
->
vgId
,
pCfg
->
sid
);
SChildTableObj
*
pTable
=
mnodeGetTableByPos
(
pCfg
->
vgId
,
pCfg
->
sid
);
SChildTableObj
*
pTable
=
mnodeGetTableByPos
(
pCfg
->
vgId
,
pCfg
->
sid
);
if
(
pTable
==
NULL
)
{
if
(
pTable
==
NULL
)
{
mError
(
"dnode:%d, vgId:%d sid:%d, table not found"
,
pCfg
->
dnodeId
,
pCfg
->
vgId
,
pCfg
->
sid
);
mError
(
"app:%p:%p, dnode:%d, vgId:%d sid:%d, table not found"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pCfg
->
dnodeId
,
pCfg
->
vgId
,
pCfg
->
sid
);
return
TSDB_CODE_MND_INVALID_TABLE_ID
;
return
TSDB_CODE_MND_INVALID_TABLE_ID
;
}
}
...
@@ -1980,36 +2015,39 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -1980,36 +2015,39 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
mnodeMsg
->
pTable
;
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
mnodeMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
mPrint
(
"table:%s, drop table rsp received, thandle:%p result:%s"
,
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
,
tstrerror
(
rpcMsg
->
code
));
mPrint
(
"app:%p:%p, table:%s, drop table rsp received, thandle:%p result:%s"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
,
tstrerror
(
rpcMsg
->
code
));
if
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"table:%s, failed to drop in dnode, reason:%s"
,
pTable
->
info
.
tableId
,
tstrerror
(
rpcMsg
->
code
));
mError
(
"app:%p:%p, table:%s, failed to drop in dnode, reason:%s"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
tstrerror
(
rpcMsg
->
code
));
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
return
;
return
;
}
}
if
(
mnodeMsg
->
pVgroup
==
NULL
)
mnodeMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
mnodeMsg
->
pVgroup
==
NULL
)
mnodeMsg
->
pVgroup
=
mnodeGetVgroup
(
pTable
->
vgId
);
if
(
mnodeMsg
->
pVgroup
==
NULL
)
{
if
(
mnodeMsg
->
pVgroup
==
NULL
)
{
mError
(
"
table:%s, failed to get vgroup"
,
pTable
->
info
.
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to get vgroup"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_VGROUP_NOT_EXIST
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_VGROUP_NOT_EXIST
);
return
;
return
;
}
}
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsChildTableSdb
,
.
table
=
tsChildTableSdb
,
.
pObj
=
pTable
.
pObj
=
pTable
};
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"
table:%s, update ctables sdb error"
,
pTable
->
info
.
tableId
);
mError
(
"
app:%p:%p, table:%s, update ctables sdb error"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_SDB_ERROR
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_MND_SDB_ERROR
);
return
;
return
;
}
}
if
(
mnodeMsg
->
pVgroup
->
numOfTables
<=
0
)
{
if
(
mnodeMsg
->
pVgroup
->
numOfTables
<=
0
)
{
mPrint
(
"vgId:%d, all tables is dropped, drop vgroup"
,
mnodeMsg
->
pVgroup
->
vgId
);
mPrint
(
"app:%p:%p, vgId:%d, all tables is dropped, drop vgroup"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
mnodeMsg
->
pVgroup
->
vgId
);
mnodeDropVgroup
(
mnodeMsg
->
pVgroup
,
NULL
);
mnodeDropVgroup
(
mnodeMsg
->
pVgroup
,
NULL
);
}
}
...
@@ -2028,11 +2066,11 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2028,11 +2066,11 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
mnodeMsg
->
pTable
;
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
mnodeMsg
->
pTable
;
assert
(
pTable
);
assert
(
pTable
);
if
(
rpcMsg
->
code
!=
TSDB_CODE_SUCCESS
&&
rpcMsg
->
code
==
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
if
(
!
(
rpcMsg
->
code
==
TSDB_CODE_SUCCESS
||
rpcMsg
->
code
!=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
)
{
if
(
mnodeMsg
->
retry
++
<
10
)
{
if
(
mnodeMsg
->
retry
++
<
10
)
{
mTrace
(
"app:%p:%p, table:%s, create table rsp received, need retry, times:%d result:%s thandle:%p"
,
mTrace
(
"app:%p:%p, table:%s, create table rsp received, need retry, times:%d result:%s thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
retry
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
rpcMsg
.
handle
);
mnodeMsg
->
rpcMsg
.
handle
);
dnodeDelayReprocessMnodeWriteMsg
(
mnodeMsg
);
dnodeDelayReprocessMnodeWriteMsg
(
mnodeMsg
);
...
@@ -2061,7 +2099,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
...
@@ -2061,7 +2099,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
mTrace
(
"app:%p:%p, table:%s, created in dnode, thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
mTrace
(
"app:%p:%p, table:%s, created in dnode, thandle:%p"
,
mnodeMsg
->
rpcMsg
.
ahandle
,
mnodeMsg
,
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
);
pTable
->
info
.
tableId
,
mnodeMsg
->
rpcMsg
.
handle
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
rpcMsg
->
code
);
dnodeSendRpcMnodeWriteRsp
(
mnodeMsg
,
TSDB_CODE_SUCCESS
);
}
}
}
}
}
}
...
@@ -2251,22 +2289,24 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
...
@@ -2251,22 +2289,24 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
static
int32_t
mnodeProcessAlterTableMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessAlterTableMsg
(
SMnodeMsg
*
pMsg
)
{
SCMAlterTableMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
SCMAlterTableMsg
*
pAlter
=
pMsg
->
rpcMsg
.
pCont
;
mTrace
(
"table:%s, alter table msg is received from thandle:%p"
,
pAlter
->
tableId
,
pMsg
->
rpcMsg
.
handle
);
mTrace
(
"app:%p:%p, table:%s, alter table msg is received from thandle:%p"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
,
pMsg
->
rpcMsg
.
handle
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pAlter
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
)
pMsg
->
pDb
=
mnodeGetDbByTableId
(
pAlter
->
tableId
);
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
if
(
pMsg
->
pDb
==
NULL
||
pMsg
->
pDb
->
status
!=
TSDB_DB_STATUS_READY
)
{
mError
(
"
table:%s, failed to alter table, db not selected"
,
pAlter
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to alter table, db not selected"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
);
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
return
TSDB_CODE_MND_DB_NOT_SELECTED
;
}
}
if
(
mnodeCheckIsMonitorDB
(
pMsg
->
pDb
->
name
,
tsMonitorDbName
))
{
if
(
mnodeCheckIsMonitorDB
(
pMsg
->
pDb
->
name
,
tsMonitorDbName
))
{
mError
(
"
table:%s, failed to alter table, its log db"
,
pAlter
->
tableId
);
mError
(
"
app:%p:%p, table:%s, failed to alter table, its log db"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
);
return
TSDB_CODE_MND_MONITOR_DB_FORBIDDEN
;
return
TSDB_CODE_MND_MONITOR_DB_FORBIDDEN
;
}
}
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pAlter
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
pMsg
->
pTable
=
mnodeGetTable
(
pAlter
->
tableId
);
if
(
pMsg
->
pTable
==
NULL
)
{
if
(
pMsg
->
pTable
==
NULL
)
{
mError
(
"table:%s, failed to alter table, table not exist"
,
pMsg
->
pTable
->
tableId
);
mError
(
"app:%p:%p, table:%s, failed to alter table, table not exist"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pMsg
->
pTable
->
tableId
);
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
return
TSDB_CODE_MND_INVALID_TABLE_NAME
;
}
}
...
@@ -2275,7 +2315,8 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -2275,7 +2315,8 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
pAlter
->
tagValLen
=
htonl
(
pAlter
->
tagValLen
);
pAlter
->
tagValLen
=
htonl
(
pAlter
->
tagValLen
);
if
(
pAlter
->
numOfCols
>
2
)
{
if
(
pAlter
->
numOfCols
>
2
)
{
mError
(
"table:%s, error numOfCols:%d in alter table"
,
pAlter
->
tableId
,
pAlter
->
numOfCols
);
mError
(
"app:%p:%p, table:%s, error numOfCols:%d in alter table"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
,
pAlter
->
numOfCols
);
return
TSDB_CODE_MND_APP_ERROR
;
return
TSDB_CODE_MND_APP_ERROR
;
}
}
...
@@ -2286,7 +2327,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -2286,7 +2327,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
int32_t
code
=
TSDB_CODE_COM_OPS_NOT_SUPPORT
;
int32_t
code
=
TSDB_CODE_COM_OPS_NOT_SUPPORT
;
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
if
(
pMsg
->
pTable
->
type
==
TSDB_SUPER_TABLE
)
{
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
SSuperTableObj
*
pTable
=
(
SSuperTableObj
*
)
pMsg
->
pTable
;
mTrace
(
"
table:%s, start to alter stable"
,
pAlter
->
tableId
);
mTrace
(
"
app:%p:%p, table:%s, start to alter stable"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
);
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_ADD_TAG_COLUMN
)
{
code
=
mnodeAddSuperTableTag
(
pMsg
,
pTable
,
pAlter
->
schema
,
1
);
code
=
mnodeAddSuperTableTag
(
pMsg
,
pTable
,
pAlter
->
schema
,
1
);
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
)
{
}
else
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_DROP_TAG_COLUMN
)
{
...
@@ -2300,7 +2341,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
...
@@ -2300,7 +2341,7 @@ static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg) {
}
else
{
}
else
{
}
}
}
else
{
}
else
{
mTrace
(
"
table:%s, start to alter ctable"
,
pAlter
->
tableId
);
mTrace
(
"
app:%p:%p, table:%s, start to alter ctable"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
pAlter
->
tableId
);
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
SChildTableObj
*
pTable
=
(
SChildTableObj
*
)
pMsg
->
pTable
;
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
if
(
pAlter
->
type
==
TSDB_ALTER_TABLE_UPDATE_TAG_VAL
)
{
char
*
tagVal
=
(
char
*
)(
pAlter
->
schema
+
pAlter
->
numOfCols
);
char
*
tagVal
=
(
char
*
)(
pAlter
->
schema
+
pAlter
->
numOfCols
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录