Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
1970a31b
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
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看板
未验证
提交
1970a31b
编写于
6月 10, 2021
作者:
C
codedump
提交者:
GitHub
6月 10, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6409 from taosdata/feature/TD-3963
[TD-3963]alter db rpc return when vnode response
上级
9c51645d
899c2130
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
122 addition
and
38 deletion
+122
-38
src/dnode/src/dnodeVMgmt.c
src/dnode/src/dnodeVMgmt.c
+0
-1
src/mnode/inc/mnodeDb.h
src/mnode/inc/mnodeDb.h
+1
-0
src/mnode/inc/mnodeVgroup.h
src/mnode/inc/mnodeVgroup.h
+1
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+34
-8
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+30
-12
tests/pytest/alter/alter_keep.py
tests/pytest/alter/alter_keep.py
+53
-14
tests/pytest/stream/table_1.py
tests/pytest/stream/table_1.py
+1
-1
tests/pytest/tag_lite/unsignedInt.py
tests/pytest/tag_lite/unsignedInt.py
+2
-1
未找到文件。
src/dnode/src/dnodeVMgmt.c
浏览文件 @
1970a31b
...
...
@@ -154,7 +154,6 @@ static SCreateVnodeMsg* dnodeParseVnodeMsg(SRpcMsg *rpcMsg) {
static
int32_t
dnodeProcessCreateVnodeMsg
(
SRpcMsg
*
rpcMsg
)
{
SCreateVnodeMsg
*
pCreate
=
dnodeParseVnodeMsg
(
rpcMsg
);
void
*
pVnode
=
vnodeAcquire
(
pCreate
->
cfg
.
vgId
);
if
(
pVnode
!=
NULL
)
{
dDebug
(
"vgId:%d, already exist, return success"
,
pCreate
->
cfg
.
vgId
);
...
...
src/mnode/inc/mnodeDb.h
浏览文件 @
1970a31b
...
...
@@ -40,6 +40,7 @@ void mnodeIncDbRef(SDbObj *pDb);
void
mnodeDecDbRef
(
SDbObj
*
pDb
);
bool
mnodeCheckIsMonitorDB
(
char
*
db
,
char
*
monitordb
);
void
mnodeDropAllDbs
(
SAcctObj
*
pAcct
);
int
mnodeInsertAlterDbRow
(
SDbObj
*
pDb
,
void
*
pMsg
);
int32_t
mnodeCompactDbs
();
...
...
src/mnode/inc/mnodeVgroup.h
浏览文件 @
1970a31b
...
...
@@ -49,7 +49,7 @@ int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable, bool needCh
void
mnodeRemoveTableFromVgroup
(
SVgObj
*
pVgroup
,
SCTableObj
*
pTable
);
void
mnodeSendDropVnodeMsg
(
int32_t
vgId
,
SRpcEpSet
*
epSet
,
void
*
ahandle
);
void
mnodeSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
);
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
,
SMnodeMsg
*
pMsg
);
void
mnodeSendSyncVgroupMsg
(
SVgObj
*
pVgroup
);
SRpcEpSet
mnodeGetEpSetFromVgroup
(
SVgObj
*
pVgroup
);
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
1970a31b
...
...
@@ -24,12 +24,14 @@
#include "tdataformat.h"
#include "tp.h"
#include "mnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
#include "mnodeAcct.h"
#include "mnodeDb.h"
#include "mnodeDnode.h"
#include "mnodeMnode.h"
#include "mnodePeer.h"
#include "mnodeProfile.h"
#include "mnodeWrite.h"
#include "mnodeSdb.h"
...
...
@@ -1097,17 +1099,18 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
return
newCfg
;
}
static
int32_t
mnodeAlterDbCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
code
;
static
int32_t
mnodeAlterDbFp
(
SMnodeMsg
*
pMsg
)
{
SDbObj
*
pDb
=
pMsg
->
pDb
;
void
*
pIter
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
while
(
1
)
{
pMsg
->
expected
=
0
;
while
(
1
)
{
pIter
=
mnodeGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDb
)
{
mnodeSendAlterVgroupMsg
(
pVgroup
);
pMsg
->
expected
+=
pVgroup
->
numOfVnodes
;
mnodeSendAlterVgroupMsg
(
pVgroup
,
pMsg
);
}
mnodeDecVgroupRef
(
pVgroup
);
}
...
...
@@ -1115,9 +1118,32 @@ static int32_t mnodeAlterDbCb(SMnodeMsg *pMsg, int32_t code) {
mDebug
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mLInfo
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
bnNotify
();
// in case there is no vnode for this db currently(no table in db,etc.)
if
(
pMsg
->
expected
==
0
)
{
SSdbRow
row
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
};
return
TSDB_CODE_SUCCESS
;
return
sdbUpdateRow
(
&
row
);
}
//bnNotify();
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
int
mnodeInsertAlterDbRow
(
SDbObj
*
pDb
,
void
*
pMsg
)
{
SSdbRow
desc
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
};
return
sdbUpdateRow
(
&
desc
);
}
static
int32_t
mnodeAlterDb
(
SDbObj
*
pDb
,
SAlterDbMsg
*
pAlter
,
void
*
pMsg
)
{
...
...
@@ -1141,14 +1167,14 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SAlterDbMsg *pAlter, void *pMsg) {
.
pTable
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
.
fpR
sp
=
mnodeAlterDbCb
.
fpR
eq
=
mnodeAlterDbFp
};
code
=
sdbUpdateRow
(
&
row
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"db:%s, failed to alter, reason:%s"
,
pDb
->
name
,
tstrerror
(
code
));
}
}
}
return
code
;
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
1970a31b
...
...
@@ -60,7 +60,6 @@ static int32_t mnodeGetVgroupMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p
static
int32_t
mnodeRetrieveVgroups
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mnodeProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mnodeProcessAlterVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mnodeProcessSyncVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
void
mnodeProcessDropVnodeRsp
(
SRpcMsg
*
rpcMsg
);
static
int32_t
mnodeProcessVnodeCfgMsg
(
SMnodeMsg
*
pMsg
)
;
static
void
mnodeSendDropVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
);
...
...
@@ -237,7 +236,6 @@ int32_t mnodeInitVgroups() {
mnodeAddShowFreeIterHandle
(
TSDB_MGMT_TABLE_VGROUP
,
mnodeCancelGetNextVgroup
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_CREATE_VNODE_RSP
,
mnodeProcessCreateVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_VNODE_RSP
,
mnodeProcessAlterVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_ALTER_VNODE_RSP
,
mnodeProcessSyncVnodeRsp
);
mnodeAddPeerRspHandle
(
TSDB_MSG_TYPE_MD_DROP_VNODE_RSP
,
mnodeProcessDropVnodeRsp
);
mnodeAddPeerMsgHandle
(
TSDB_MSG_TYPE_DM_CONFIG_VNODE
,
mnodeProcessVnodeCfgMsg
);
...
...
@@ -271,7 +269,7 @@ void mnodeUpdateVgroup(SVgObj *pVgroup) {
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
mError
(
"vgId:%d, failed to update vgroup"
,
pVgroup
->
vgId
);
}
mnodeSendAlterVgroupMsg
(
pVgroup
);
mnodeSendAlterVgroupMsg
(
pVgroup
,
NULL
);
}
/*
...
...
@@ -350,7 +348,7 @@ void mnodeUpdateVgroupStatus(SVgObj *pVgroup, SDnodeObj *pDnode, SVnodeLoad *pVl
mError
(
"dnode:%d, vgId:%d, vnode cfgVersion:%d:%d repica:%d not match with mnode cfgVersion:%d:%d replica:%d"
,
pDnode
->
dnodeId
,
pVload
->
vgId
,
pVload
->
dbCfgVersion
,
pVload
->
vgCfgVersion
,
pVload
->
replica
,
pVgroup
->
pDb
->
dbCfgVersion
,
pVgroup
->
vgCfgVersion
,
pVgroup
->
numOfVnodes
);
mnodeSendAlterVgroupMsg
(
pVgroup
);
mnodeSendAlterVgroupMsg
(
pVgroup
,
NULL
);
}
}
...
...
@@ -946,10 +944,10 @@ SRpcEpSet mnodeGetEpSetFromIp(char *ep) {
return
epSet
;
}
static
void
mnodeSendAlterVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcEpSet
*
epSet
)
{
static
void
mnodeSendAlterVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcEpSet
*
epSet
,
SMnodeMsg
*
pMsg
)
{
SAlterVnodeMsg
*
pAlter
=
mnodeBuildVnodeMsg
(
pVgroup
);
SRpcMsg
rpcMsg
=
{
.
ahandle
=
NULL
,
.
ahandle
=
pMsg
,
.
pCont
=
pAlter
,
.
contLen
=
pAlter
?
sizeof
(
SAlterVnodeMsg
)
:
0
,
.
code
=
0
,
...
...
@@ -958,14 +956,18 @@ static void mnodeSendAlterVnodeMsg(SVgObj *pVgroup, SRpcEpSet *epSet) {
dnodeSendMsgToDnode
(
epSet
,
&
rpcMsg
);
}
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
)
{
void
mnodeSendAlterVgroupMsg
(
SVgObj
*
pVgroup
,
SMnodeMsg
*
pMsg
)
{
mDebug
(
"vgId:%d, send alter all vnodes msg, numOfVnodes:%d db:%s"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
,
pVgroup
->
dbName
);
if
(
pMsg
)
{
pMsg
->
pVgroup
=
pVgroup
;
mnodeIncVgroupRef
(
pVgroup
);
}
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcEpSet
epSet
=
mnodeGetEpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
pDnode
->
dnodeEp
);
mDebug
(
"vgId:%d, index:%d, send alter vnode msg to dnode %s"
,
pVgroup
->
vgId
,
i
,
pVgroup
->
vnodeGid
[
i
].
pDnode
->
dnodeEp
);
mnodeSendAlterVnodeMsg
(
pVgroup
,
&
epSet
);
mnodeSendAlterVnodeMsg
(
pVgroup
,
&
epSet
,
pMsg
);
}
}
...
...
@@ -1026,11 +1028,27 @@ void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle) {
}
static
void
mnodeProcessAlterVnodeRsp
(
SRpcMsg
*
rpcMsg
)
{
mDebug
(
"alter vnode rsp
received"
);
}
mDebug
(
"alter vnode rsp
is received, handle:%p"
,
rpcMsg
->
ahandle
);
if
(
rpcMsg
->
ahandle
==
NULL
)
return
;
static
void
mnodeProcessSyncVnodeRsp
(
SRpcMsg
*
rpcMsg
)
{
mDebug
(
"sync vnode rsp received"
);
SMnodeMsg
*
mnodeMsg
=
rpcMsg
->
ahandle
;
mnodeMsg
->
received
++
;
if
(
rpcMsg
->
code
==
TSDB_CODE_SUCCESS
)
{
mnodeMsg
->
code
=
rpcMsg
->
code
;
mnodeMsg
->
successed
++
;
}
SVgObj
*
pVgroup
=
mnodeMsg
->
pVgroup
;
mDebug
(
"vgId:%d, alter vnode rsp received, result:%s received:%d successed:%d expected:%d, thandle:%p ahandle:%p"
,
pVgroup
->
vgId
,
tstrerror
(
rpcMsg
->
code
),
mnodeMsg
->
received
,
mnodeMsg
->
successed
,
mnodeMsg
->
expected
,
mnodeMsg
->
rpcMsg
.
handle
,
rpcMsg
->
ahandle
);
if
(
mnodeMsg
->
received
!=
mnodeMsg
->
expected
)
return
;
int32_t
code
=
mnodeInsertAlterDbRow
(
pVgroup
->
pDb
,
mnodeMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
&&
code
!=
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
{
dnodeSendRpcMWriteRsp
(
mnodeMsg
,
code
);
}
}
static
void
mnodeProcessCreateVnodeRsp
(
SRpcMsg
*
rpcMsg
)
{
...
...
tests/pytest/alter/alter_keep.py
浏览文件 @
1970a31b
...
...
@@ -126,25 +126,64 @@ class TDTestCase:
##TODO: need to wait for TD-4445 to implement the following
## tests
# tdSql.prepare()
# tdSql.execute('create table tb (ts timestamp, speed int)')
# tdSql.execute('alter database db keep 10,10,10')
# tdSql.execute('insert into tb values (now, 10)')
# tdSql.execute('insert into tb values (now + 10m, 10)')
# tdSql.query('select * from tb')
# tdSql.checkRows(2)
# tdSql.execute('alter database db keep 40,40,40')
## preset the keep
tdSql
.
prepare
()
tdSql
.
execute
(
'create table tb (ts timestamp, speed int)'
)
tdSql
.
execute
(
'alter database db keep 10,10,10'
)
tdSql
.
execute
(
'insert into tb values (now, 10)'
)
tdSql
.
execute
(
'insert into tb values (now + 10m, 10)'
)
tdSql
.
query
(
'select * from tb'
)
tdSql
.
checkRows
(
2
)
#after alter from small to large, check if the alter if functioning
#test if change through test.py is consistent with change from taos client
#test case for TD-4459 and TD-4445
tdSql
.
execute
(
'alter database db keep 40,40,40'
)
tdSql
.
query
(
'show databases'
)
tdSql
.
checkData
(
0
,
7
,
'40,40,40'
)
tdSql
.
error
(
'insert into tb values (now-60d, 10)'
)
tdSql
.
execute
(
'insert into tb values (now-30d, 10)'
)
tdSql
.
query
(
'select * from tb'
)
tdSql
.
checkRows
(
3
)
rowNum
=
3
for
i
in
range
(
30
):
rowNum
+=
1
tdSql
.
execute
(
'alter database db keep 20,20,20'
)
tdSql
.
execute
(
'alter database db keep 40,40,40'
)
tdSql
.
query
(
'show databases'
)
tdSql
.
checkData
(
0
,
7
,
'40,40,40'
)
tdSql
.
error
(
'insert into tb values (now-60d, 10)'
)
tdSql
.
execute
(
'insert into tb values (now-30d, 10)'
)
tdSql
.
query
(
'select * from tb'
)
tdSql
.
checkRows
(
rowNum
)
tdSql
.
execute
(
'alter database db keep 10,10,10'
)
tdSql
.
query
(
'show databases'
)
tdSql
.
checkData
(
0
,
7
,
'10,10,10'
)
# if uncomment these three lines, timestamp out of range error will appear
# tdSql.execute('alter database db keep 15,15,15')
# tdSql.query('show databases')
# tdSql.checkData(0,7,'40,40,40')
# tdSql.error('insert into tb values (now-60d, 10)')
# tdSql.execute('insert into tb values (now-30d, 10)')
# tdSql.query('select * from tb')
# tdSql.checkRows(3)
# tdSql.checkData(0,7,'15,15,15')
# the following line should generate an error, but the insert was a success
# the time now-15d is out of range of now -10d
tdSql
.
error
(
'insert into tb values (now-15d, 10)'
)
tdSql
.
query
(
'select * from tb'
)
tdSql
.
checkRows
(
rowNum
)
# tdSql.execute('alter database db keep 20,20,20')
# tdSql.query('show databases')
# tdSql.checkData(0,7,'20,20,20')
# tdSql.error('insert into tb values (now-30d, 10)')
# tdSql.query('show databases')
# tdSql.checkData(0,7,'20,20,20')
# tdSql.query('select * from tb')
# tdSql.checkRows(
2
)
# tdSql.checkRows(
rowNum
)
def
stop
(
self
):
...
...
tests/pytest/stream/table_1.py
浏览文件 @
1970a31b
...
...
@@ -51,7 +51,7 @@ class TDTestCase:
tdSql
.
execute
(
"insert into tb%d values (now - %dm, %d, %d)"
%
(
i
,
1440
-
j
,
j
,
j
))
time
.
sleep
(
0.
1
)
time
.
sleep
(
1
)
self
.
createFuncStream
(
"count(*)"
,
"c1"
,
rowNum
)
self
.
createFuncStream
(
"count(tbcol)"
,
"c2"
,
rowNum
)
...
...
tests/pytest/tag_lite/unsignedInt.py
浏览文件 @
1970a31b
...
...
@@ -4,7 +4,7 @@ import sys
from
util.log
import
*
from
util.cases
import
*
from
util.sql
import
*
import
time
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
...
...
@@ -112,6 +112,7 @@ class TDTestCase:
# TSIM: endw
# TSIM:
# TSIM: print =============== step2
time
.
sleep
(
1
)
tdLog
.
info
(
'=============== step2'
)
# TSIM: sleep 100
# TSIM: sql select * from $tb
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录