Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
25ec924c
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看板
提交
25ec924c
编写于
11月 29, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code
上级
c519e51d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
133 addition
and
91 deletion
+133
-91
include/common/tmsg.h
include/common/tmsg.h
+2
-3
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+5
-6
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+125
-81
未找到文件。
include/common/tmsg.h
浏览文件 @
25ec924c
...
...
@@ -3223,9 +3223,8 @@ typedef struct {
int32_t
tEncodeSSubmitReq2
(
SEncoder
*
pCoder
,
const
SSubmitReq2
*
pReq
);
int32_t
tDecodeSSubmitReq2
(
SDecoder
*
pCoder
,
SSubmitReq2
*
pReq
);
void
tDestroySSubmitTbData
(
SSubmitTbData
*
pTbData
);
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
);
void
tDestroySSubmitTbData
(
SSubmitTbData
*
pTbData
);
void
tDestroySSubmitReq2
(
SSubmitReq2
*
pReq
);
typedef
struct
{
int32_t
code
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
25ec924c
...
...
@@ -160,7 +160,7 @@ int32_t tsdbRollbackCommit(STsdb* pTsdb);
int32_t
tsdbDoRetention
(
STsdb
*
pTsdb
,
int64_t
now
);
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
SSubmitBlkRsp
*
pRsp
);
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
int32_t
*
affectedRows
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
int32_t
tsdbSetKeepCfg
(
STsdb
*
pTsdb
,
STsdbCfg
*
pCfg
);
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
25ec924c
...
...
@@ -29,7 +29,7 @@
static
void
tbDataMovePosTo
(
STbData
*
pTbData
,
SMemSkipListNode
**
pos
,
TSDBKEY
*
pKey
,
int32_t
flags
);
static
int32_t
tsdbGetOrCreateTbData
(
SMemTable
*
pMemTable
,
tb_uid_t
suid
,
tb_uid_t
uid
,
STbData
**
ppTbData
);
static
int32_t
tsdbInsertTableDataImpl
(
SMemTable
*
pMemTable
,
STbData
*
pTbData
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
SSubmitBlkRsp
*
pRsp
);
SSubmitTbData
*
pSubmitTbData
,
int32_t
*
affectedRows
);
int32_t
tsdbMemTableCreate
(
STsdb
*
pTsdb
,
SMemTable
**
ppMemTable
)
{
int32_t
code
=
0
;
...
...
@@ -95,7 +95,7 @@ STbData *tsdbGetTbDataFromMemTable(SMemTable *pMemTable, tb_uid_t suid, tb_uid_t
return
pTbData
;
}
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
SSubmitBlkRsp
*
pRsp
)
{
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
int32_t
*
affectedRows
)
{
int32_t
code
=
0
;
SMemTable
*
pMemTable
=
pTsdb
->
mem
;
STbData
*
pTbData
=
NULL
;
...
...
@@ -133,7 +133,7 @@ int32_t tsdbInsertTableData(STsdb *pTsdb, int64_t version, SSubmitTbData *pSubmi
}
// do insert impl
code
=
tsdbInsertTableDataImpl
(
pMemTable
,
pTbData
,
version
,
pSubmitTbData
,
pRsp
);
code
=
tsdbInsertTableDataImpl
(
pMemTable
,
pTbData
,
version
,
pSubmitTbData
,
affectedRows
);
if
(
code
)
{
goto
_err
;
}
...
...
@@ -539,7 +539,7 @@ _exit:
}
static
int32_t
tsdbInsertTableDataImpl
(
SMemTable
*
pMemTable
,
STbData
*
pTbData
,
int64_t
version
,
SSubmitTbData
*
pSubmitTbData
,
SSubmitBlkRsp
*
pRsp
)
{
SSubmitTbData
*
pSubmitTbData
,
int32_t
*
affectedRows
)
{
int32_t
code
=
0
;
SRow
**
rows
=
(
SRow
**
)
TARRAY_DATA
(
pSubmitTbData
->
aRowP
);
...
...
@@ -608,8 +608,7 @@ static int32_t tsdbInsertTableDataImpl(SMemTable *pMemTable, STbData *pTbData, i
pMemTable
->
maxKey
=
TMAX
(
pMemTable
->
maxKey
,
pTbData
->
maxKey
);
pMemTable
->
nRow
+=
nRow
;
if
(
pRsp
)
pRsp
->
numOfRows
=
nRow
;
if
(
pRsp
)
pRsp
->
affectedRows
=
nRow
;
if
(
affectedRows
)
*
affectedRows
=
nRow
;
return
code
;
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
25ec924c
...
...
@@ -851,8 +851,12 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
int32_t
code
=
0
;
SSubmitReq2
*
pSubmitReq
=
&
(
SSubmitReq2
){
0
};
SSubmitRsp2
*
pSubmitRsp
=
NULL
;
SSubmitRsp2
*
pSubmitRsp
=
&
(
SSubmitRsp2
){
0
}
;
SArray
*
newTbUids
=
NULL
;
int32_t
ret
;
SEncoder
ec
=
{
0
};
pRsp
->
code
=
TSDB_CODE_SUCCESS
;
// decode
SDecoder
dc
=
{
0
};
...
...
@@ -864,7 +868,7 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
tDecoderClear
(
&
dc
);
// check
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pSubmitReq
->
aSubmitTbData
,
i
);
if
(
pSubmitTbData
->
pCreateTbReq
)
{
...
...
@@ -895,42 +899,91 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
}
// loop to handle
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
);
++
i
)
{
SSubmitTbData
*
pSubmitTbData
=
taosArrayGet
(
pSubmitReq
->
aSubmitTbData
,
i
);
// create table
if
(
pSubmitTbData
->
pCreateTbReq
)
{
if
(
metaCreateTable
(
pVnode
->
pMeta
,
version
,
pSubmitTbData
->
pCreateTbReq
,
NULL
/* todo */
)
<
0
)
{
// TODO
}
else
{
// TODO
// check (TODO: move check to create table)
code
=
grantCheck
(
TSDB_GRANT_TIMESERIES
);
if
(
code
)
goto
_exit
;
code
=
grantCheck
(
TSDB_GRANT_TABLE
);
if
(
code
)
goto
_exit
;
// alloc if need
if
(
pSubmitRsp
->
aCreateTbRsp
==
NULL
&&
(
pSubmitRsp
->
aCreateTbRsp
=
taosArrayInit
(
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
),
sizeof
(
SVCreateTbRsp
)))
==
NULL
)
{
code
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_exit
;
}
SVCreateTbRsp
*
pCreateTbRsp
=
taosArrayReserve
(
pSubmitRsp
->
aCreateTbRsp
,
1
);
// create table
if
(
metaCreateTable
(
pVnode
->
pMeta
,
version
,
pSubmitTbData
->
pCreateTbReq
,
&
pCreateTbRsp
->
pMeta
)
==
0
)
{
// create table success
if
(
newTbUids
==
NULL
&&
(
newTbUids
=
taosArrayInit
(
TARRAY_SIZE
(
pSubmitReq
->
aSubmitTbData
),
sizeof
(
int64_t
)))
==
NULL
)
{
code
=
TSDB_CODE_TDB_OUT_OF_MEMORY
;
goto
_exit
;
}
taosArrayPush
(
newTbUids
,
&
pSubmitTbData
->
uid
);
if
(
pCreateTbRsp
->
pMeta
)
{
// TODO
}
}
else
{
// create table failed
if
(
terrno
!=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
code
=
terrno
;
goto
_exit
;
}
}
}
// insert data
tsdbInsertTableData
(
pVnode
->
pTsdb
,
version
,
pSubmitTbData
,
NULL
/* todo */
);
// TODO: handle result
int32_t
affectedRows
;
code
=
tsdbInsertTableData
(
pVnode
->
pTsdb
,
version
,
pSubmitTbData
,
&
affectedRows
);
if
(
code
)
goto
_exit
;
pSubmitRsp
->
affectedRows
+=
affectedRows
;
}
_exit:
if
(
code
)
{
}
else
{
// update table uid list
if
(
taosArrayGetSize
(
newTbUids
)
>
0
)
{
vDebug
(
"vgId:%d, add %d table into query table list in handling submit"
,
TD_VID
(
pVnode
),
(
int32_t
)
taosArrayGetSize
(
newTbUids
));
tqUpdateTbUidList
(
pVnode
->
pTq
,
newTbUids
,
true
);
}
_exit:
// message
pRsp
->
code
=
code
;
tEncodeSize
(
tEncodeSSubmitRsp2
,
pSubmitRsp
,
pRsp
->
contLen
,
ret
);
pRsp
->
pCont
=
rpcMallocCont
(
pRsp
->
contLen
);
tEncoderInit
(
&
ec
,
pRsp
->
pCont
,
pRsp
->
contLen
);
tEncodeSSubmitRsp2
(
&
ec
,
pSubmitRsp
);
tEncoderClear
(
&
ec
);
// clear
taosArrayDestroy
(
newTbUids
);
tDestroySSubmitReq2
(
pSubmitReq
);
tDestroySSubmitRsp2
(
pSubmitRsp
);
return
code
;
#else
SSubmitReq
*
pSubmitReq
=
(
SSubmitReq
*
)
pReq
;
SSubmitRsp
submitRsp
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SVCreateTbReq
createTbReq
=
{
0
};
SDecoder
decoder
=
{
0
};
int32_t
nRows
=
0
;
int32_t
tsize
,
ret
;
SEncoder
encoder
=
{
0
};
SArray
*
newTbUids
=
NULL
;
SVStatis
statis
=
{
0
};
bool
tbCreated
=
false
;
SSubmitReq
*
pSubmitReq
=
(
SSubmitReq
*
)
pReq
;
SSubmitRsp
submitRsp
=
{
0
};
int32_t
nRows
=
0
;
int32_t
tsize
,
ret
;
SEncoder
encoder
=
{
0
};
SArray
*
newTbUids
=
NULL
;
SVStatis
statis
=
{
0
};
bool
tbCreated
=
false
;
terrno
=
TSDB_CODE_SUCCESS
;
pRsp
->
code
=
0
;
...
...
@@ -942,12 +995,6 @@ _exit:
goto
_exit
;
}
// handle the request
if
(
tInitSubmitMsgIter
(
pSubmitReq
,
&
msgIter
)
<
0
)
{
pRsp
->
code
=
TSDB_CODE_INVALID_MSG
;
goto
_exit
;
}
submitRsp
.
pArray
=
taosArrayInit
(
msgIter
.
numOfBlocks
,
sizeof
(
SSubmitBlkRsp
));
newTbUids
=
taosArrayInit
(
msgIter
.
numOfBlocks
,
sizeof
(
int64_t
));
if
(
!
submitRsp
.
pArray
||
!
newTbUids
)
{
...
...
@@ -964,42 +1011,42 @@ _exit:
// create table for auto create table mode
if
(
msgIter
.
schemaLen
>
0
)
{
tDecoderInit
(
&
decoder
,
pBlock
->
data
,
msgIter
.
schemaLen
);
if
(
tDecodeSVCreateTbReq
(
&
decoder
,
&
createTbReq
)
<
0
)
{
pRsp
->
code
=
TSDB_CODE_INVALID_MSG
;
tDecoderClear
(
&
decoder
);
taosArrayDestroy
(
createTbReq
.
ctb
.
tagName
);
goto
_exit
;
}
if
((
terrno
=
grantCheck
(
TSDB_GRANT_TIMESERIES
))
<
0
)
{
pRsp
->
code
=
terrno
;
tDecoderClear
(
&
decoder
);
taosArrayDestroy
(
createTbReq
.
ctb
.
tagName
);
goto
_exit
;
}
if
((
terrno
=
grantCheck
(
TSDB_GRANT_TABLE
))
<
0
)
{
pRsp
->
code
=
terrno
;
tDecoderClear
(
&
decoder
);
taosArrayDestroy
(
createTbReq
.
ctb
.
tagName
);
goto
_exit
;
}
//
tDecoderInit(&decoder, pBlock->data, msgIter.schemaLen);
//
if (tDecodeSVCreateTbReq(&decoder, &createTbReq) < 0) {
//
pRsp->code = TSDB_CODE_INVALID_MSG;
//
tDecoderClear(&decoder);
//
taosArrayDestroy(createTbReq.ctb.tagName);
//
goto _exit;
//
}
//
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
//
pRsp->code = terrno;
//
tDecoderClear(&decoder);
//
taosArrayDestroy(createTbReq.ctb.tagName);
//
goto _exit;
//
}
//
if ((terrno = grantCheck(TSDB_GRANT_TABLE)) < 0) {
//
pRsp->code = terrno;
//
tDecoderClear(&decoder);
//
taosArrayDestroy(createTbReq.ctb.tagName);
//
goto _exit;
//
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
version
,
&
createTbReq
,
&
submitBlkRsp
.
pMeta
)
<
0
)
{
if
(
terrno
!=
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
)
{
submitBlkRsp
.
code
=
terrno
;
pRsp
->
code
=
terrno
;
tDecoderClear
(
&
decoder
);
taosArrayDestroy
(
createTbReq
.
ctb
.
tagName
);
goto
_exit
;
}
//
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
//
submitBlkRsp.code = terrno;
//
pRsp->code = terrno;
//
tDecoderClear(&decoder);
//
taosArrayDestroy(createTbReq.ctb.tagName);
//
goto _exit;
//
}
}
else
{
if
(
NULL
!=
submitBlkRsp
.
pMeta
)
{
vnodeUpdateMetaRsp
(
pVnode
,
submitBlkRsp
.
pMeta
);
}
taosArrayPush
(
newTbUids
,
&
createTbReq
.
uid
);
//
taosArrayPush(newTbUids, &createTbReq.uid);
submitBlkRsp
.
uid
=
createTbReq
.
uid
;
submitBlkRsp
.
tblFName
=
taosMemoryMalloc
(
strlen
(
pVnode
->
config
.
dbname
)
+
strlen
(
createTbReq
.
name
)
+
2
);
...
...
@@ -1007,18 +1054,15 @@ _exit:
tbCreated
=
true
;
}
msgIter
.
uid
=
createTbReq
.
uid
;
if
(
createTbReq
.
type
==
TSDB_CHILD_TABLE
)
{
msgIter
.
suid
=
createTbReq
.
ctb
.
suid
;
}
else
{
msgIter
.
suid
=
0
;
}
//
msgIter.uid = createTbReq.uid;
//
if (createTbReq.type == TSDB_CHILD_TABLE) {
//
msgIter.suid = createTbReq.ctb.suid;
//
} else {
//
msgIter.suid = 0;
//
}
#ifdef TD_DEBUG_PRINT_ROW
vnodeDebugPrintSingleSubmitMsg
(
pVnode
->
pMeta
,
pBlock
,
&
msgIter
,
"real uid"
);
#endif
tDecoderClear
(
&
decoder
);
taosArrayDestroy
(
createTbReq
.
ctb
.
tagName
);
// tDecoderClear(&decoder);
// taosArrayDestroy(createTbReq.ctb.tagName);
}
if
(
tsdbInsertTableData
(
pVnode
->
pTsdb
,
version
,
&
msgIter
,
pBlock
,
&
submitBlkRsp
)
<
0
)
{
...
...
@@ -1032,21 +1076,21 @@ _exit:
}
}
if
(
taosArrayGetSize
(
newTbUids
)
>
0
)
{
vDebug
(
"vgId:%d, add %d table into query table list in handling submit"
,
TD_VID
(
pVnode
),
(
int32_t
)
taosArrayGetSize
(
newTbUids
));
}
//
if (taosArrayGetSize(newTbUids) > 0) {
//
vDebug("vgId:%d, add %d table into query table list in handling submit", TD_VID(pVnode),
//
(int32_t)taosArrayGetSize(newTbUids));
//
}
tqUpdateTbUidList
(
pVnode
->
pTq
,
newTbUids
,
true
);
//
tqUpdateTbUidList(pVnode->pTq, newTbUids, true);
_exit:
taosArrayDestroy
(
newTbUids
);
tEncodeSize
(
tEncodeSSubmitRsp
,
&
submitRsp
,
tsize
,
ret
);
pRsp
->
pCont
=
rpcMallocCont
(
tsize
);
pRsp
->
contLen
=
tsize
;
tEncoderInit
(
&
encoder
,
pRsp
->
pCont
,
tsize
);
tEncodeSSubmitRsp
(
&
encoder
,
&
submitRsp
);
tEncoderClear
(
&
encoder
);
//
tEncodeSize(tEncodeSSubmitRsp, &submitRsp, tsize, ret);
//
pRsp->pCont = rpcMallocCont(tsize);
//
pRsp->contLen = tsize;
//
tEncoderInit(&encoder, pRsp->pCont, tsize);
//
tEncodeSSubmitRsp(&encoder, &submitRsp);
//
tEncoderClear(&encoder);
taosArrayDestroyEx
(
submitRsp
.
pArray
,
tFreeSSubmitBlkRsp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录