Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
88519c19
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看板
提交
88519c19
编写于
6月 17, 2020
作者:
L
liu0x54
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/taosdata/TDengine
into develop
上级
2ea72023
96cc0d38
变更
70
展开全部
隐藏空白更改
内联
并排
Showing
70 changed file
with
1702 addition
and
731 deletion
+1702
-731
src/client/src/tscSQLParser.c
src/client/src/tscSQLParser.c
+6
-3
src/client/src/tscSecondaryMerge.c
src/client/src/tscSecondaryMerge.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/client/src/tscStream.c
src/client/src/tscStream.c
+1
-1
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+20
-1
src/dnode/src/dnodeMWrite.c
src/dnode/src/dnodeMWrite.c
+17
-6
src/inc/taos.h
src/inc/taos.h
+1
-1
src/inc/taoserror.h
src/inc/taoserror.h
+6
-2
src/mnode/inc/mnodeDnode.h
src/mnode/inc/mnodeDnode.h
+1
-1
src/mnode/inc/mnodeInt.h
src/mnode/inc/mnodeInt.h
+4
-4
src/mnode/inc/mnodeSdb.h
src/mnode/inc/mnodeSdb.h
+6
-1
src/mnode/inc/mnodeUser.h
src/mnode/inc/mnodeUser.h
+2
-1
src/mnode/src/mnodeAcct.c
src/mnode/src/mnodeAcct.c
+3
-1
src/mnode/src/mnodeDb.c
src/mnode/src/mnodeDb.c
+48
-44
src/mnode/src/mnodeDnode.c
src/mnode/src/mnodeDnode.c
+20
-34
src/mnode/src/mnodeSdb.c
src/mnode/src/mnodeSdb.c
+308
-74
src/mnode/src/mnodeTable.c
src/mnode/src/mnodeTable.c
+360
-210
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+43
-36
src/mnode/src/mnodeVgroup.c
src/mnode/src/mnodeVgroup.c
+36
-16
src/mnode/src/mnodeWrite.c
src/mnode/src/mnodeWrite.c
+10
-6
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+6
-4
src/query/src/tvariant.c
src/query/src/tvariant.c
+1
-1
src/rpc/src/rpcMain.c
src/rpc/src/rpcMain.c
+32
-25
src/rpc/src/rpcTcp.c
src/rpc/src/rpcTcp.c
+3
-3
src/tsdb/src/tsdbMeta.c
src/tsdb/src/tsdbMeta.c
+4
-0
src/util/src/tmem.c
src/util/src/tmem.c
+1
-1
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+6
-6
tests/script/general/parser/alter.sim
tests/script/general/parser/alter.sim
+7
-7
tests/script/general/parser/stream.sim
tests/script/general/parser/stream.sim
+16
-28
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+7
-5
tests/script/tmp/prepare.sim
tests/script/tmp/prepare.sim
+4
-4
tests/script/unique/arbitrator/check_cluster_cfg_para.sim
tests/script/unique/arbitrator/check_cluster_cfg_para.sim
+24
-15
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
+12
-0
tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim
...script/unique/arbitrator/dn3_mn1_full_createTableFail.sim
+2
-1
tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
...s/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
+2
-0
tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
...script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
+2
-1
tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
...e/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
+6
-9
tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
...t/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
+41
-18
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
+64
-6
tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
...ipt/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
+8
-2
tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
+17
-14
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
+34
-19
tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
...t/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
+76
-27
tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
...pt/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
+20
-4
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
+26
-3
tests/script/unique/arbitrator/dn3_mn2_killDnode.sim
tests/script/unique/arbitrator/dn3_mn2_killDnode.sim
+2
-1
tests/script/unique/arbitrator/insert_duplicationTs.sim
tests/script/unique/arbitrator/insert_duplicationTs.sim
+13
-2
tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim
.../unique/arbitrator/offline_replica2_alterTable_online.sim
+11
-0
tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim
...pt/unique/arbitrator/offline_replica2_alterTag_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica2_createTable_online.sim
...unique/arbitrator/offline_replica2_createTable_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim
...ript/unique/arbitrator/offline_replica2_dropDb_online.sim
+10
-0
tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim
...t/unique/arbitrator/offline_replica2_dropTable_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim
.../unique/arbitrator/offline_replica3_alterTable_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim
...pt/unique/arbitrator/offline_replica3_alterTag_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica3_createTable_online.sim
...unique/arbitrator/offline_replica3_createTable_online.sim
+15
-0
tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim
...ript/unique/arbitrator/offline_replica3_dropDb_online.sim
+10
-0
tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim
...t/unique/arbitrator/offline_replica3_dropTable_online.sim
+15
-0
tests/script/unique/arbitrator/replica_changeWithArbitrator.sim
...script/unique/arbitrator/replica_changeWithArbitrator.sim
+31
-11
tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim
...script/unique/arbitrator/sync_replica2_alterTable_add.sim
+10
-0
tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim
...cript/unique/arbitrator/sync_replica2_alterTable_drop.sim
+11
-1
tests/script/unique/arbitrator/sync_replica2_dropDb.sim
tests/script/unique/arbitrator/sync_replica2_dropDb.sim
+10
-0
tests/script/unique/arbitrator/sync_replica2_dropTable.sim
tests/script/unique/arbitrator/sync_replica2_dropTable.sim
+10
-0
tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim
...script/unique/arbitrator/sync_replica3_alterTable_add.sim
+13
-3
tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim
...cript/unique/arbitrator/sync_replica3_alterTable_drop.sim
+10
-0
tests/script/unique/arbitrator/sync_replica3_dropDb.sim
tests/script/unique/arbitrator/sync_replica3_dropDb.sim
+10
-0
tests/script/unique/arbitrator/sync_replica3_dropTable.sim
tests/script/unique/arbitrator/sync_replica3_dropTable.sim
+16
-6
tests/script/unique/arbitrator/testSuite.sim
tests/script/unique/arbitrator/testSuite.sim
+3
-3
tests/script/unique/dnode/balance3.sim
tests/script/unique/dnode/balance3.sim
+0
-1
tests/test/c/insertPerRow.c
tests/test/c/insertPerRow.c
+75
-43
tests/test/c/insertPerTable.c
tests/test/c/insertPerTable.c
+37
-13
未找到文件。
src/client/src/tscSQLParser.c
浏览文件 @
88519c19
...
@@ -6082,11 +6082,14 @@ int32_t exprTreeFromSqlExpr(tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray*
...
@@ -6082,11 +6082,14 @@ int32_t exprTreeFromSqlExpr(tExprNode **pExpr, const tSQLExpr* pSqlExpr, SArray*
}
}
}
}
if
((
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_EQUAL
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_NOT_EQUAL
)
{
if
((
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_EQUAL
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_NOT_EQUAL
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
nodeType
==
TSQL_NODE_VALUE
)
{
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
if
(
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BOOL
)
{
||
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BINARY
return
TSDB_CODE_TSC_INVALID_SQL
;
||
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
{
}
if
((
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_BINARY
||
pRight
->
pVal
->
nType
==
TSDB_DATA_TYPE_NCHAR
)
&&
(
*
pExpr
)
->
_node
.
optr
!=
TSDB_RELATION_LIKE
)
{
return
TSDB_CODE_TSC_INVALID_SQL
;
return
TSDB_CODE_TSC_INVALID_SQL
;
}
}
}
}
...
...
src/client/src/tscSecondaryMerge.c
浏览文件 @
88519c19
...
@@ -353,7 +353,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
...
@@ -353,7 +353,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
pRes
->
numOfGroups
=
0
;
pRes
->
numOfGroups
=
0
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
pCmd
->
clauseIndex
,
0
);
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
;
STableComInfo
tinfo
=
tscGetTableInfo
(
pTableMetaInfo
->
pTableMeta
);
TSKEY
stime
=
MIN
(
pQueryInfo
->
window
.
skey
,
pQueryInfo
->
window
.
ekey
);
TSKEY
stime
=
MIN
(
pQueryInfo
->
window
.
skey
,
pQueryInfo
->
window
.
ekey
);
int64_t
revisedSTime
=
int64_t
revisedSTime
=
...
...
src/client/src/tscServer.c
浏览文件 @
88519c19
...
@@ -1473,7 +1473,7 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
...
@@ -1473,7 +1473,7 @@ int tscBuildTableMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg
+=
len
;
pMsg
+=
len
;
}
}
pCmd
->
payloadLen
=
pMsg
-
(
char
*
)
pInfoMsg
;
;
pCmd
->
payloadLen
=
pMsg
-
(
char
*
)
pInfoMsg
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_TABLE_META
;
pCmd
->
msgType
=
TSDB_MSG_TYPE_CM_TABLE_META
;
tfree
(
tmpData
);
tfree
(
tmpData
);
...
...
src/client/src/tscStream.c
浏览文件 @
88519c19
...
@@ -499,7 +499,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
...
@@ -499,7 +499,7 @@ TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sqlstr, void (*fp)(void *p
if
(
pSql
->
sqlstr
==
NULL
)
{
if
(
pSql
->
sqlstr
==
NULL
)
{
tscError
(
"%p failed to malloc sql string buffer"
,
pSql
);
tscError
(
"%p failed to malloc sql string buffer"
,
pSql
);
tscFreeSqlObj
(
pSql
);
tscFreeSqlObj
(
pSql
);
return
NULL
;
;
return
NULL
;
}
}
strtolower
(
pSql
->
sqlstr
,
sqlstr
);
strtolower
(
pSql
->
sqlstr
,
sqlstr
);
...
...
src/cq/src/cqMain.c
浏览文件 @
88519c19
...
@@ -256,11 +256,30 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
...
@@ -256,11 +256,30 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
SDataRow
trow
=
(
SDataRow
)
pBlk
->
data
;
SDataRow
trow
=
(
SDataRow
)
pBlk
->
data
;
tdInitDataRow
(
trow
,
pSchema
);
tdInitDataRow
(
trow
,
pSchema
);
union
{
char
buf
[
sizeof
(
int64_t
)];
tstr
str
;
}
nullVal
;
for
(
int32_t
i
=
0
;
i
<
pSchema
->
numOfCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSchema
->
numOfCols
;
i
++
)
{
STColumn
*
c
=
pSchema
->
columns
+
i
;
STColumn
*
c
=
pSchema
->
columns
+
i
;
char
*
val
=
(
char
*
)
row
[
i
];
char
*
val
=
(
char
*
)
row
[
i
];
if
(
IS_VAR_DATA_TYPE
(
c
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
c
->
type
))
{
val
-=
sizeof
(
VarDataLenT
);
if
(
val
==
NULL
)
{
val
=
nullVal
.
buf
;
if
(
c
->
type
==
TSDB_DATA_TYPE_BINARY
)
{
setNull
(
nullVal
.
str
.
data
,
TSDB_DATA_TYPE_BINARY
,
1
);
nullVal
.
str
.
len
=
1
;
}
else
{
setNull
(
nullVal
.
str
.
data
,
TSDB_DATA_TYPE_NCHAR
,
4
);
nullVal
.
str
.
len
=
4
;
}
}
else
{
val
-=
sizeof
(
VarDataLenT
);
}
}
else
if
(
val
==
NULL
)
{
val
=
nullVal
.
buf
;
setNull
(
val
,
c
->
type
,
c
->
bytes
);
}
}
tdAppendColVal
(
trow
,
val
,
c
->
type
,
c
->
bytes
,
c
->
offset
);
tdAppendColVal
(
trow
,
val
,
c
->
type
,
c
->
bytes
,
c
->
offset
);
}
}
...
...
src/dnode/src/dnodeMWrite.c
浏览文件 @
88519c19
...
@@ -118,6 +118,8 @@ void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
...
@@ -118,6 +118,8 @@ void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
SMnodeMsg
*
pWrite
=
(
SMnodeMsg
*
)
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
SMnodeMsg
*
pWrite
=
(
SMnodeMsg
*
)
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
mnodeCreateMsg
(
pWrite
,
pMsg
);
mnodeCreateMsg
(
pWrite
,
pMsg
);
dTrace
(
"app:%p:%p, msg:%s is put into mwrite queue"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
]);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
}
}
...
@@ -128,6 +130,7 @@ static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
...
@@ -128,6 +130,7 @@ static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
void
dnodeSendRpcMnodeWriteRsp
(
void
*
pRaw
,
int32_t
code
)
{
void
dnodeSendRpcMnodeWriteRsp
(
void
*
pRaw
,
int32_t
code
)
{
SMnodeMsg
*
pWrite
=
pRaw
;
SMnodeMsg
*
pWrite
=
pRaw
;
if
(
pWrite
==
NULL
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_IN_PROGRESS
)
return
;
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
if
(
code
==
TSDB_CODE_MND_ACTION_NEED_REPROCESSED
)
{
dnodeReprocessMnodeWriteMsg
(
pWrite
);
dnodeReprocessMnodeWriteMsg
(
pWrite
);
...
@@ -146,19 +149,21 @@ void dnodeSendRpcMnodeWriteRsp(void *pRaw, int32_t code) {
...
@@ -146,19 +149,21 @@ void dnodeSendRpcMnodeWriteRsp(void *pRaw, int32_t code) {
}
}
static
void
*
dnodeProcessMnodeWriteQueue
(
void
*
param
)
{
static
void
*
dnodeProcessMnodeWriteQueue
(
void
*
param
)
{
SMnodeMsg
*
pWrite
Msg
;
SMnodeMsg
*
pWrite
;
int32_t
type
;
int32_t
type
;
void
*
unUsed
;
void
*
unUsed
;
while
(
1
)
{
while
(
1
)
{
if
(
taosReadQitemFromQset
(
tsMWriteQset
,
&
type
,
(
void
**
)
&
pWrite
Msg
,
&
unUsed
)
==
0
)
{
if
(
taosReadQitemFromQset
(
tsMWriteQset
,
&
type
,
(
void
**
)
&
pWrite
,
&
unUsed
)
==
0
)
{
dTrace
(
"dnodeProcessMnodeWriteQueue: got no message from qset, exiting..."
);
dTrace
(
"dnodeProcessMnodeWriteQueue: got no message from qset, exiting..."
);
break
;
break
;
}
}
dTrace
(
"%p, msg:%s will be processed in mwrite queue"
,
pWriteMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pWriteMsg
->
rpcMsg
.
msgType
]);
dTrace
(
"app:%p:%p, msg:%s will be processed in mwrite queue"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
int32_t
code
=
mnodeProcessWrite
(
pWriteMsg
);
taosMsg
[
pWrite
->
rpcMsg
.
msgType
]);
dnodeSendRpcMnodeWriteRsp
(
pWriteMsg
,
code
);
int32_t
code
=
mnodeProcessWrite
(
pWrite
);
dnodeSendRpcMnodeWriteRsp
(
pWrite
,
code
);
}
}
return
NULL
;
return
NULL
;
...
@@ -168,9 +173,15 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
...
@@ -168,9 +173,15 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
SMnodeMsg
*
pWrite
=
pMsg
;
SMnodeMsg
*
pWrite
=
pMsg
;
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
if
(
!
mnodeIsRunning
()
||
tsMWriteQueue
==
NULL
)
{
dTrace
(
"app:%p:%p, msg:%s is redirected for mnode not running, retry times:%d"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
pWrite
->
retry
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeSendRedirectMsg
(
pMsg
,
true
);
dnodeFreeMnodeWriteMsg
(
pWrite
);
dnodeFreeMnodeWriteMsg
(
pWrite
);
}
else
{
}
else
{
dTrace
(
"app:%p:%p, msg:%s is reput into mwrite queue, retry times:%d"
,
pWrite
->
rpcMsg
.
ahandle
,
pWrite
,
taosMsg
[
pWrite
->
rpcMsg
.
msgType
],
pWrite
->
retry
);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
taosWriteQitem
(
tsMWriteQueue
,
TAOS_QTYPE_RPC
,
pWrite
);
}
}
}
}
...
...
src/inc/taos.h
浏览文件 @
88519c19
...
@@ -55,7 +55,7 @@ typedef enum {
...
@@ -55,7 +55,7 @@ typedef enum {
typedef
struct
taosField
{
typedef
struct
taosField
{
char
name
[
65
];
char
name
[
65
];
uint8_t
type
;
uint8_t
type
;
short
bytes
;
uint16_t
bytes
;
}
TAOS_FIELD
;
}
TAOS_FIELD
;
#ifdef _TD_GO_DLL_
#ifdef _TD_GO_DLL_
...
...
src/inc/taoserror.h
浏览文件 @
88519c19
...
@@ -113,8 +113,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, 0, 0x030C, "mnode inva
...
@@ -113,8 +113,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, 0, 0x030C, "mnode inva
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STREAM_ID
,
0
,
0x030D
,
"mnode invalid stream id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_STREAM_ID
,
0
,
0x030D
,
"mnode invalid stream id"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_CONN_ID
,
0
,
0x030E
,
"mnode invalid connection"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_INVALID_CONN_ID
,
0
,
0x030E
,
"mnode invalid connection"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE
,
0
,
0x0320
,
"mnode object already there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE
,
0
,
0x0320
,
"[sdb] object already there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_ERROR
,
0
,
0x0321
,
"mnode sdb error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_ERROR
,
0
,
0x0321
,
"[sdb] app error"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
,
0
,
0x0322
,
"[sdb] invalid table type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
,
0
,
0x0323
,
"[sdb] object not there"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_INVAID_META_ROW
,
0
,
0x0324
,
"[sdb] invalid meta row"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_SDB_INVAID_KEY_TYPE
,
0
,
0x0325
,
"[sdb] invalid key type"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_ALREADY_EXIST
,
0
,
0x0330
,
"mnode dnode already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_ALREADY_EXIST
,
0
,
0x0330
,
"mnode dnode already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_NOT_EXIST
,
0
,
0x0331
,
"mnode dnode not exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MND_DNODE_NOT_EXIST
,
0
,
0x0331
,
"mnode dnode not exist"
)
...
...
src/mnode/inc/mnodeDnode.h
浏览文件 @
88519c19
...
@@ -47,7 +47,7 @@ void mnodeDecDnodeRef(SDnodeObj *pDnode);
...
@@ -47,7 +47,7 @@ void mnodeDecDnodeRef(SDnodeObj *pDnode);
void
*
mnodeGetDnode
(
int32_t
dnodeId
);
void
*
mnodeGetDnode
(
int32_t
dnodeId
);
void
*
mnodeGetDnodeByEp
(
char
*
ep
);
void
*
mnodeGetDnodeByEp
(
char
*
ep
);
void
mnodeUpdateDnode
(
SDnodeObj
*
pDnode
);
void
mnodeUpdateDnode
(
SDnodeObj
*
pDnode
);
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
);
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
,
void
*
pMsg
);
extern
int32_t
tsAccessSquence
;
extern
int32_t
tsAccessSquence
;
...
...
src/mnode/inc/mnodeInt.h
浏览文件 @
88519c19
...
@@ -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/inc/mnodeSdb.h
浏览文件 @
88519c19
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
struct
SMnodeMsg
;
typedef
enum
{
typedef
enum
{
SDB_TABLE_DNODE
=
0
,
SDB_TABLE_DNODE
=
0
,
SDB_TABLE_MNODE
=
1
,
SDB_TABLE_MNODE
=
1
,
...
@@ -48,8 +50,11 @@ typedef struct {
...
@@ -48,8 +50,11 @@ typedef struct {
ESdbOper
type
;
ESdbOper
type
;
void
*
table
;
void
*
table
;
void
*
pObj
;
void
*
pObj
;
int32_t
rowSize
;
void
*
rowData
;
void
*
rowData
;
int32_t
rowSize
;
int32_t
retCode
;
// for callback in sdb queue
int32_t
(
*
cb
)(
struct
SMnodeMsg
*
pMsg
,
int32_t
code
);
struct
SMnodeMsg
*
pMsg
;
}
SSdbOper
;
}
SSdbOper
;
typedef
struct
{
typedef
struct
{
...
...
src/mnode/inc/mnodeUser.h
浏览文件 @
88519c19
...
@@ -28,7 +28,8 @@ void * mnodeGetNextUser(void *pIter, SUserObj **pUser);
...
@@ -28,7 +28,8 @@ void * mnodeGetNextUser(void *pIter, SUserObj **pUser);
void
mnodeIncUserRef
(
SUserObj
*
pUser
);
void
mnodeIncUserRef
(
SUserObj
*
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
);
void
mnodeDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mnodeGetUserFromConn
(
void
*
pConn
);
SUserObj
*
mnodeGetUserFromConn
(
void
*
pConn
);
int32_t
mnodeCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
);
char
*
mnodeGetUserFromMsg
(
void
*
pMnodeMsg
);
int32_t
mnodeCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
,
void
*
pMsg
);
void
mnodeDropAllUsers
(
SAcctObj
*
pAcct
);
void
mnodeDropAllUsers
(
SAcctObj
*
pAcct
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/mnode/src/mnodeAcct.c
浏览文件 @
88519c19
...
@@ -78,7 +78,9 @@ static int32_t mnodeAcctActionDecode(SSdbOper *pOper) {
...
@@ -78,7 +78,9 @@ static int32_t mnodeAcctActionDecode(SSdbOper *pOper) {
}
}
static
int32_t
mnodeAcctActionRestored
()
{
static
int32_t
mnodeAcctActionRestored
()
{
if
(
dnodeIsFirstDeploy
())
{
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsAcctSdb
);
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
mPrint
(
"dnode first deploy, create root acct"
);
int32_t
code
=
mnodeCreateRootAcct
();
int32_t
code
=
mnodeCreateRootAcct
();
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"failed to create root account, reason:%s"
,
tstrerror
(
code
));
mError
(
"failed to create root account, reason:%s"
,
tstrerror
(
code
));
...
...
src/mnode/src/mnodeDb.c
浏览文件 @
88519c19
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
static
void
*
tsDbSdb
=
NULL
;
static
void
*
tsDbSdb
=
NULL
;
static
int32_t
tsDbUpdateSize
;
static
int32_t
tsDbUpdateSize
;
static
int32_t
mnodeCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
);
static
int32_t
mnodeCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
,
void
*
pMsg
);
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
newMsg
);
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
newMsg
);
static
int32_t
mnodeSetDbDropping
(
SDbObj
*
pDb
);
static
int32_t
mnodeSetDbDropping
(
SDbObj
*
pDb
);
static
int32_t
mnodeGetDbMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mnodeGetDbMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
...
@@ -311,7 +311,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
...
@@ -311,7 +311,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
if
(
pCfg
->
replications
<
0
)
pCfg
->
replications
=
tsReplications
;
if
(
pCfg
->
replications
<
0
)
pCfg
->
replications
=
tsReplications
;
}
}
static
int32_t
mnodeCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
)
{
static
int32_t
mnodeCreateDb
(
SAcctObj
*
pAcct
,
SCMCreateDbMsg
*
pCreate
,
void
*
pMsg
)
{
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_DB
);
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_DB
);
if
(
code
!=
0
)
return
code
;
if
(
code
!=
0
)
return
code
;
...
@@ -364,12 +364,15 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
...
@@ -364,12 +364,15 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCMCreateDbMsg *pCreate) {
.
table
=
tsDbSdb
,
.
table
=
tsDbSdb
,
.
pObj
=
pDb
,
.
pObj
=
pDb
,
.
rowSize
=
sizeof
(
SDbObj
),
.
rowSize
=
sizeof
(
SDbObj
),
.
pMsg
=
pMsg
};
};
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pDb
);
tfree
(
pDb
);
code
=
TSDB_CODE_MND_SDB_ERROR
;
}
else
{
mLPrint
(
"db:%s, is created by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
...
@@ -771,12 +774,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
...
@@ -771,12 +774,7 @@ static int32_t mnodeProcessCreateDbMsg(SMnodeMsg *pMsg) {
}
else
if
(
!
pMsg
->
pUser
->
writeAuth
)
{
}
else
if
(
!
pMsg
->
pUser
->
writeAuth
)
{
code
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
TSDB_CODE_MND_NO_RIGHTS
;
}
else
{
}
else
{
code
=
mnodeCreateDb
(
pMsg
->
pUser
->
pAcct
,
pCreate
);
code
=
mnodeCreateDb
(
pMsg
->
pUser
->
pAcct
,
pCreate
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"db:%s, is created by %s"
,
pCreate
->
db
,
pMsg
->
pUser
->
user
);
}
else
{
mError
(
"db:%s, failed to create, reason:%s"
,
pCreate
->
db
,
tstrerror
(
code
));
}
}
}
return
code
;
return
code
;
...
@@ -893,7 +891,31 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
...
@@ -893,7 +891,31 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
return
newCfg
;
return
newCfg
;
}
}
static
int32_t
mnodeAlterDb
(
SDbObj
*
pDb
,
SCMAlterDbMsg
*
pAlter
)
{
static
int32_t
mnodeAlterDbCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
code
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
mnodeGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
if
(
pVgroup
->
pDb
==
pDb
)
{
mnodeSendCreateVgroupMsg
(
pVgroup
,
NULL
);
}
mnodeDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
mTrace
(
"db:%s, all vgroups is altered"
,
pDb
->
name
);
mLPrint
(
"db:%s, is alterd by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
balanceNotify
();
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
mnodeAlterDb
(
SDbObj
*
pDb
,
SCMAlterDbMsg
*
pAlter
,
void
*
pMsg
)
{
SDbCfg
newCfg
=
mnodeGetAlterDbOption
(
pDb
,
pAlter
);
SDbCfg
newCfg
=
mnodeGetAlterDbOption
(
pDb
,
pAlter
);
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
if
(
terrno
!=
TSDB_CODE_SUCCESS
)
{
return
terrno
;
return
terrno
;
...
@@ -904,38 +926,24 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
...
@@ -904,38 +926,24 @@ static int32_t mnodeAlterDb(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
return
code
;
return
code
;
}
}
int32_t
oldReplica
=
pDb
->
cfg
.
replications
;
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
if
(
memcmp
(
&
newCfg
,
&
pDb
->
cfg
,
sizeof
(
SDbCfg
))
!=
0
)
{
pDb
->
cfg
=
newCfg
;
pDb
->
cfg
=
newCfg
;
pDb
->
cfgVersion
++
;
pDb
->
cfgVersion
++
;
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDbSdb
,
.
table
=
tsDbSdb
,
.
pObj
=
pDb
.
pObj
=
pDb
,
.
pMsg
=
pMsg
,
.
cb
=
mnodeAlterDbCb
};
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
!
=
TSDB_CODE_SUCCESS
)
{
if
(
code
=
=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_MND_SDB_ERROR
;
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
}
}
void
*
pIter
=
NULL
;
return
code
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
mnodeGetNextVgroup
(
pIter
,
&
pVgroup
);
if
(
pVgroup
==
NULL
)
break
;
mnodeSendCreateVgroupMsg
(
pVgroup
,
NULL
);
mnodeDecVgroupRef
(
pVgroup
);
}
sdbFreeIter
(
pIter
);
if
(
oldReplica
!=
pDb
->
cfg
.
replications
)
{
balanceNotify
();
}
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessAlterDbMsg
(
SMnodeMsg
*
pMsg
)
{
...
@@ -948,14 +956,7 @@ static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
...
@@ -948,14 +956,7 @@ static int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_INVALID_DB
;
return
TSDB_CODE_MND_INVALID_DB
;
}
}
int32_t
code
=
mnodeAlterDb
(
pMsg
->
pDb
,
pAlter
);
return
mnodeAlterDb
(
pMsg
->
pDb
,
pAlter
,
pMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"db:%s, failed to alter, invalid db option"
,
pAlter
->
db
);
return
code
;
}
mTrace
(
"db:%s, all vgroups is altered"
,
pMsg
->
pDb
->
name
);
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeDropDb
(
SMnodeMsg
*
pMsg
)
{
...
@@ -963,13 +964,16 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
...
@@ -963,13 +964,16 @@ static int32_t mnodeDropDb(SMnodeMsg *pMsg) {
mPrint
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
mPrint
(
"db:%s, drop db from sdb"
,
pDb
->
name
);
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDbSdb
,
.
table
=
tsDbSdb
,
.
pObj
=
pDb
.
pObj
=
pDb
,
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
0
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
mLPrint
(
"db:%s, is dropped by %s"
,
pDb
->
name
,
mnodeGetUserFromMsg
(
pMsg
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
...
...
src/mnode/src/mnodeDnode.c
浏览文件 @
88519c19
...
@@ -44,7 +44,7 @@ static int32_t tsDnodeUpdateSize = 0;
...
@@ -44,7 +44,7 @@ static int32_t tsDnodeUpdateSize = 0;
extern
void
*
tsMnodeSdb
;
extern
void
*
tsMnodeSdb
;
extern
void
*
tsVgroupSdb
;
extern
void
*
tsVgroupSdb
;
static
int32_t
mnodeCreateDnode
(
char
*
ep
);
static
int32_t
mnodeCreateDnode
(
char
*
ep
,
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCreateDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessDropDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCfgDnodeMsg
(
SMnodeMsg
*
pMsg
);
static
int32_t
mnodeProcessCfgDnodeMsg
(
SMnodeMsg
*
pMsg
);
...
@@ -117,7 +117,8 @@ static int32_t mnodeDnodeActionDecode(SSdbOper *pOper) {
...
@@ -117,7 +117,8 @@ static int32_t mnodeDnodeActionDecode(SSdbOper *pOper) {
static
int32_t
mnodeDnodeActionRestored
()
{
static
int32_t
mnodeDnodeActionRestored
()
{
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsDnodeSdb
);
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsDnodeSdb
);
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
mnodeCreateDnode
(
tsLocalEp
);
mPrint
(
"dnode first deploy, create dnode:%s"
,
tsLocalEp
);
mnodeCreateDnode
(
tsLocalEp
,
NULL
);
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
tsLocalEp
);
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
tsLocalEp
);
mnodeAddMnode
(
pDnode
->
dnodeId
);
mnodeAddMnode
(
pDnode
->
dnodeId
);
mnodeDecDnodeRef
(
pDnode
);
mnodeDecDnodeRef
(
pDnode
);
...
@@ -391,7 +392,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
...
@@ -391,7 +392,7 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
mnodeCreateDnode
(
char
*
ep
)
{
static
int32_t
mnodeCreateDnode
(
char
*
ep
,
SMnodeMsg
*
pMsg
)
{
int32_t
grantCode
=
grantCheck
(
TSDB_GRANT_DNODE
);
int32_t
grantCode
=
grantCheck
(
TSDB_GRANT_DNODE
);
if
(
grantCode
!=
TSDB_CODE_SUCCESS
)
{
if
(
grantCode
!=
TSDB_CODE_SUCCESS
)
{
return
grantCode
;
return
grantCode
;
...
@@ -415,7 +416,8 @@ static int32_t mnodeCreateDnode(char *ep) {
...
@@ -415,7 +416,8 @@ static int32_t mnodeCreateDnode(char *ep) {
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDnodeSdb
,
.
table
=
tsDnodeSdb
,
.
pObj
=
pDnode
,
.
pObj
=
pDnode
,
.
rowSize
=
sizeof
(
SDnodeObj
)
.
rowSize
=
sizeof
(
SDnodeObj
),
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbInsertRow
(
&
oper
);
int32_t
code
=
sdbInsertRow
(
&
oper
);
...
@@ -423,30 +425,32 @@ static int32_t mnodeCreateDnode(char *ep) {
...
@@ -423,30 +425,32 @@ static int32_t mnodeCreateDnode(char *ep) {
int
dnodeId
=
pDnode
->
dnodeId
;
int
dnodeId
=
pDnode
->
dnodeId
;
tfree
(
pDnode
);
tfree
(
pDnode
);
mError
(
"failed to create dnode:%d, result:%s"
,
dnodeId
,
tstrerror
(
code
));
mError
(
"failed to create dnode:%d, result:%s"
,
dnodeId
,
tstrerror
(
code
));
return
TSDB_CODE_MND_SDB_ERROR
;
}
else
{
mPrint
(
"dnode:%d is created, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
mPrint
(
"dnode:%d is created, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
return
code
;
return
code
;
}
}
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
)
{
int32_t
mnodeDropDnode
(
SDnodeObj
*
pDnode
,
void
*
pMsg
)
{
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsDnodeSdb
,
.
table
=
tsDnodeSdb
,
.
pObj
=
pDnode
.
pObj
=
pDnode
,
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
mLPrint
(
"dnode:%d, is dropped from cluster, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
mLPrint
(
"dnode:%d, is dropped from cluster, result:%s"
,
pDnode
->
dnodeId
,
tstrerror
(
code
));
return
code
;
return
code
;
}
}
static
int32_t
mnodeDropDnodeByEp
(
char
*
ep
)
{
static
int32_t
mnodeDropDnodeByEp
(
char
*
ep
,
SMnodeMsg
*
pMsg
)
{
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
ep
);
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
ep
);
if
(
pDnode
==
NULL
)
{
if
(
pDnode
==
NULL
)
{
mError
(
"dnode:%s, is not exist"
,
ep
);
mError
(
"dnode:%s, is not exist"
,
ep
);
...
@@ -461,7 +465,7 @@ static int32_t mnodeDropDnodeByEp(char *ep) {
...
@@ -461,7 +465,7 @@ static int32_t mnodeDropDnodeByEp(char *ep) {
mPrint
(
"dnode:%d, start to drop it"
,
pDnode
->
dnodeId
);
mPrint
(
"dnode:%d, start to drop it"
,
pDnode
->
dnodeId
);
#ifndef _SYNC
#ifndef _SYNC
return
mnodeDropDnode
(
pDnode
);
return
mnodeDropDnode
(
pDnode
,
pMsg
);
#else
#else
return
balanceDropDnode
(
pDnode
);
return
balanceDropDnode
(
pDnode
);
#endif
#endif
...
@@ -473,17 +477,7 @@ static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -473,17 +477,7 @@ static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
return
TSDB_CODE_MND_NO_RIGHTS
;
return
TSDB_CODE_MND_NO_RIGHTS
;
}
else
{
}
else
{
int32_t
code
=
mnodeCreateDnode
(
pCreate
->
ep
);
return
mnodeCreateDnode
(
pCreate
->
ep
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
SDnodeObj
*
pDnode
=
mnodeGetDnodeByEp
(
pCreate
->
ep
);
mLPrint
(
"dnode:%d, %s is created by %s"
,
pDnode
->
dnodeId
,
pCreate
->
ep
,
pMsg
->
pUser
->
user
);
mnodeDecDnodeRef
(
pDnode
);
}
else
{
mError
(
"failed to create dnode:%s, reason:%s"
,
pCreate
->
ep
,
tstrerror
(
code
));
}
return
code
;
}
}
}
}
...
@@ -493,15 +487,7 @@ static int32_t mnodeProcessDropDnodeMsg(SMnodeMsg *pMsg) {
...
@@ -493,15 +487,7 @@ static int32_t mnodeProcessDropDnodeMsg(SMnodeMsg *pMsg) {
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
if
(
strcmp
(
pMsg
->
pUser
->
user
,
"root"
)
!=
0
)
{
return
TSDB_CODE_MND_NO_RIGHTS
;
return
TSDB_CODE_MND_NO_RIGHTS
;
}
else
{
}
else
{
int32_t
code
=
mnodeDropDnodeByEp
(
pDrop
->
ep
);
return
mnodeDropDnodeByEp
(
pDrop
->
ep
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"dnode:%s is dropped by %s"
,
pDrop
->
ep
,
pMsg
->
pUser
->
user
);
}
else
{
mError
(
"failed to drop dnode:%s, reason:%s"
,
pDrop
->
ep
,
tstrerror
(
code
));
}
return
code
;
}
}
}
}
...
...
src/mnode/src/mnodeSdb.c
浏览文件 @
88519c19
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include "tsync.h"
#include "tsync.h"
#include "tglobal.h"
#include "tglobal.h"
#include "dnode.h"
#include "dnode.h"
#include "mnode.h"
#include "mnodeDef.h"
#include "mnodeDef.h"
#include "mnodeInt.h"
#include "mnodeInt.h"
#include "mnodeMnode.h"
#include "mnodeMnode.h"
...
@@ -31,6 +32,7 @@
...
@@ -31,6 +32,7 @@
#include "mnodeSdb.h"
#include "mnodeSdb.h"
#define SDB_TABLE_LEN 12
#define SDB_TABLE_LEN 12
#define SDB_SYNC_HACK 16
typedef
enum
{
typedef
enum
{
SDB_ACTION_INSERT
,
SDB_ACTION_INSERT
,
...
@@ -83,8 +85,29 @@ typedef struct {
...
@@ -83,8 +85,29 @@ typedef struct {
void
*
row
;
void
*
row
;
}
SSdbRow
;
}
SSdbRow
;
typedef
struct
{
pthread_t
thread
;
int32_t
workerId
;
}
SSdbWriteWorker
;
typedef
struct
{
int32_t
num
;
SSdbWriteWorker
*
writeWorker
;
}
SSdbWriteWorkerPool
;
static
SSdbObject
tsSdbObj
=
{
0
};
static
SSdbObject
tsSdbObj
=
{
0
};
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int
type
);
static
taos_qset
tsSdbWriteQset
;
static
taos_qall
tsSdbWriteQall
;
static
taos_queue
tsSdbWriteQueue
;
static
SSdbWriteWorkerPool
tsSdbPool
;
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int
type
);
static
int
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int
type
);
static
void
*
sdbWorkerFp
(
void
*
param
);
static
int32_t
sdbInitWriteWorker
();
static
void
sdbCleanupWriteWorker
();
static
int32_t
sdbAllocWriteQueue
();
static
void
sdbFreeWritequeue
();
int32_t
sdbGetId
(
void
*
handle
)
{
int32_t
sdbGetId
(
void
*
handle
)
{
return
((
SSdbTable
*
)
handle
)
->
autoIndex
;
return
((
SSdbTable
*
)
handle
)
->
autoIndex
;
...
@@ -302,7 +325,7 @@ void sdbUpdateSync() {
...
@@ -302,7 +325,7 @@ void sdbUpdateSync() {
syncInfo
.
ahandle
=
NULL
;
syncInfo
.
ahandle
=
NULL
;
syncInfo
.
getWalInfo
=
sdbGetWalInfo
;
syncInfo
.
getWalInfo
=
sdbGetWalInfo
;
syncInfo
.
getFileInfo
=
sdbGetFileInfo
;
syncInfo
.
getFileInfo
=
sdbGetFileInfo
;
syncInfo
.
writeToCache
=
sdbWrite
;
syncInfo
.
writeToCache
=
sdbWrite
ToQueue
;
syncInfo
.
confirmForward
=
sdbConfirmForward
;
syncInfo
.
confirmForward
=
sdbConfirmForward
;
syncInfo
.
notifyRole
=
sdbNotifyRole
;
syncInfo
.
notifyRole
=
sdbNotifyRole
;
tsSdbObj
.
cfg
=
syncCfg
;
tsSdbObj
.
cfg
=
syncCfg
;
...
@@ -319,10 +342,14 @@ int32_t sdbInit() {
...
@@ -319,10 +342,14 @@ int32_t sdbInit() {
pthread_mutex_init
(
&
tsSdbObj
.
mutex
,
NULL
);
pthread_mutex_init
(
&
tsSdbObj
.
mutex
,
NULL
);
sem_init
(
&
tsSdbObj
.
sem
,
0
,
0
);
sem_init
(
&
tsSdbObj
.
sem
,
0
,
0
);
if
(
sdbInitWriteWorker
()
!=
0
)
{
return
-
1
;
}
if
(
sdbInitWal
()
!=
0
)
{
if
(
sdbInitWal
()
!=
0
)
{
return
-
1
;
return
-
1
;
}
}
sdbRestoreTables
();
sdbRestoreTables
();
if
(
mnodeGetMnodesNum
()
==
1
)
{
if
(
mnodeGetMnodesNum
()
==
1
)
{
...
@@ -340,6 +367,8 @@ void sdbCleanUp() {
...
@@ -340,6 +367,8 @@ void sdbCleanUp() {
tsSdbObj
.
status
=
SDB_STATUS_CLOSING
;
tsSdbObj
.
status
=
SDB_STATUS_CLOSING
;
sdbCleanupWriteWorker
();
if
(
tsSdbObj
.
sync
)
{
if
(
tsSdbObj
.
sync
)
{
syncStop
(
tsSdbObj
.
sync
);
syncStop
(
tsSdbObj
.
sync
);
tsSdbObj
.
sync
=
NULL
;
tsSdbObj
.
sync
=
NULL
;
...
@@ -475,7 +504,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
...
@@ -475,7 +504,7 @@ static int32_t sdbDeleteHash(SSdbTable *pTable, SSdbOper *pOper) {
pTable
->
numOfRows
--
;
pTable
->
numOfRows
--
;
pthread_mutex_unlock
(
&
pTable
->
mutex
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
sdbTrace
(
"table:%s, delete record:%s from hash, numOfRows:%"
PRId64
"version:%"
PRIu64
,
pTable
->
tableName
,
sdbTrace
(
"table:%s, delete record:%s from hash, numOfRows:%"
PRId64
"
version:%"
PRIu64
,
pTable
->
tableName
,
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
),
pTable
->
numOfRows
,
sdbGetVersion
());
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
),
pTable
->
numOfRows
,
sdbGetVersion
());
int8_t
*
updateEnd
=
pOper
->
pObj
+
pTable
->
refCountPos
-
1
;
int8_t
*
updateEnd
=
pOper
->
pObj
+
pTable
->
refCountPos
-
1
;
...
@@ -494,9 +523,10 @@ static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbOper *pOper) {
...
@@ -494,9 +523,10 @@ static int32_t sdbUpdateHash(SSdbTable *pTable, SSdbOper *pOper) {
}
}
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int
type
)
{
static
int
sdbWrite
(
void
*
param
,
void
*
data
,
int
type
)
{
SSdbOper
*
pOper
=
param
;
SWalHead
*
pHead
=
data
;
SWalHead
*
pHead
=
data
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
tableId
=
pHead
->
msgType
/
10
;
int32_t
action
=
pHead
->
msgType
%
10
;
int32_t
action
=
pHead
->
msgType
%
10
;
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
SSdbTable
*
pTable
=
sdbGetTableFromId
(
tableId
);
assert
(
pTable
!=
NULL
);
assert
(
pTable
!=
NULL
);
...
@@ -531,21 +561,22 @@ static int sdbWrite(void *param, void *data, int type) {
...
@@ -531,21 +561,22 @@ static int sdbWrite(void *param, void *data, int type) {
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
return
code
;
return
code
;
}
}
walFsync
(
tsSdbObj
.
wal
);
code
=
sdbForwardToPeer
(
pHead
);
code
=
sdbForwardToPeer
(
pHead
);
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
pthread_mutex_unlock
(
&
tsSdbObj
.
mutex
);
// from app, oper is created
// from app, oper is created
if
(
p
aram
!=
NULL
)
{
if
(
p
Oper
!=
NULL
)
{
//sdbTrace("request from app is disposed, version:%" PRIu64 " code
:%s", pHead->version, tstrerror(code));
sdbTrace
(
"record from app is disposed, version:%"
PRIu64
" result
:%s"
,
pHead
->
version
,
tstrerror
(
code
));
return
code
;
return
code
;
}
}
// from wal or forward msg, oper not created, should add into hash
// from wal or forward msg, oper not created, should add into hash
if
(
tsSdbObj
.
sync
!=
NULL
)
{
if
(
tsSdbObj
.
sync
!=
NULL
)
{
sdbTrace
(
"
forward request is received, version:%"
PRIu64
" result:%s, confirm it"
,
pHead
->
version
,
tstrerror
(
code
)
);
sdbTrace
(
"
record from wal forward is disposed, version:%"
PRIu64
" confirm it"
,
pHead
->
version
);
syncConfirmForward
(
tsSdbObj
.
sync
,
pHead
->
version
,
code
);
syncConfirmForward
(
tsSdbObj
.
sync
,
pHead
->
version
,
code
);
}
else
{
sdbTrace
(
"record from wal restore is disposed, version:%"
PRIu64
,
pHead
->
version
);
}
}
if
(
action
==
SDB_ACTION_INSERT
)
{
if
(
action
==
SDB_ACTION_INSERT
)
{
...
@@ -568,7 +599,7 @@ static int sdbWrite(void *param, void *data, int type) {
...
@@ -568,7 +599,7 @@ static int sdbWrite(void *param, void *data, int type) {
int32_t
sdbInsertRow
(
SSdbOper
*
pOper
)
{
int32_t
sdbInsertRow
(
SSdbOper
*
pOper
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
-
1
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
if
(
sdbGetRowFromObj
(
pTable
,
pOper
->
pObj
))
{
if
(
sdbGetRowFromObj
(
pTable
,
pOper
->
pObj
))
{
sdbError
(
"table:%s, failed to insert record:%s, already exist"
,
pTable
->
tableName
,
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
));
sdbError
(
"table:%s, failed to insert record:%s, already exist"
,
pTable
->
tableName
,
sdbGetKeyStrFromObj
(
pTable
,
pOper
->
pObj
));
...
@@ -587,98 +618,146 @@ int32_t sdbInsertRow(SSdbOper *pOper) {
...
@@ -587,98 +618,146 @@ int32_t sdbInsertRow(SSdbOper *pOper) {
pthread_mutex_unlock
(
&
pTable
->
mutex
);
pthread_mutex_unlock
(
&
pTable
->
mutex
);
}
}
if
(
pOper
->
type
==
SDB_OPER_GLOBAL
)
{
int32_t
code
=
sdbInsertHash
(
pTable
,
pOper
);
int32_t
size
=
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SWalHead
*
pHead
=
taosAllocateQitem
(
size
);
sdbError
(
"table:%s, failed to insert into hash"
,
pTable
->
tableName
);
pHead
->
version
=
0
;
return
code
;
pHead
->
len
=
pOper
->
rowSize
;
}
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_INSERT
;
// just insert data into memory
if
(
pOper
->
type
!=
SDB_OPER_GLOBAL
)
{
return
TSDB_CODE_SUCCESS
;
}
pOper
->
rowData
=
pHead
->
cont
;
int32_t
size
=
sizeof
(
SSdbOper
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
(
*
pTable
->
encodeFp
)(
pOper
);
SSdbOper
*
pNewOper
=
taosAllocateQitem
(
size
);
pHead
->
len
=
pOper
->
rowSize
;
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSdbOper
)
+
SDB_SYNC_HACK
;
pHead
->
version
=
0
;
pHead
->
len
=
pOper
->
rowSize
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_INSERT
;
int32_t
code
=
sdbWrite
(
pOper
,
pHead
,
pHead
->
msgType
);
pOper
->
rowData
=
pHead
->
cont
;
taosFreeQitem
(
pHead
);
(
*
pTable
->
encodeFp
)(
pOper
);
if
(
code
<
0
)
return
code
;
pHead
->
len
=
pOper
->
rowSize
;
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, insert action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
}
return
sdbInsertHash
(
pTable
,
pOper
);
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
sdbDeleteRow
(
SSdbOper
*
pOper
)
{
int32_t
sdbDeleteRow
(
SSdbOper
*
pOper
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
-
1
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
sdbTrace
(
"table:%s, record is not there, delete failed"
,
pTable
->
tableName
);
sdbTrace
(
"table:%s, record is not there, delete failed"
,
pTable
->
tableName
);
return
-
1
;
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
}
void
*
pMetaRow
=
pMeta
->
row
;
void
*
pMetaRow
=
pMeta
->
row
;
assert
(
pMetaRow
!=
NULL
);
if
(
pMetaRow
==
NULL
)
{
sdbError
(
"table:%s, record meta is null"
,
pTable
->
tableName
);
if
(
pOper
->
type
==
SDB_OPER_GLOBAL
)
{
return
TSDB_CODE_MND_SDB_INVAID_META_ROW
;
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
}
int32_t
keySize
=
0
;
switch
(
pTable
->
keyType
)
{
int32_t
code
=
sdbDeleteHash
(
pTable
,
pOper
);
case
SDB_KEY_STRING
:
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
case
SDB_KEY_VAR_STRING
:
sdbError
(
"table:%s, failed to delete from hash"
,
pTable
->
tableName
);
keySize
=
strlen
((
char
*
)
key
)
+
1
;
return
code
;
break
;
}
case
SDB_KEY_INT
:
case
SDB_KEY_AUTO
:
keySize
=
sizeof
(
uint32_t
);
break
;
default:
return
-
1
;
}
int32_t
size
=
sizeof
(
SWalHead
)
+
keySize
;
// just delete data from memory
SWalHead
*
pHead
=
taosAllocateQitem
(
size
);
if
(
pOper
->
type
!=
SDB_OPER_GLOBAL
)
{
pHead
->
version
=
0
;
return
TSDB_CODE_SUCCESS
;
pHead
->
len
=
keySize
;
}
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_DELETE
;
memcpy
(
pHead
->
cont
,
key
,
keySize
);
int32_t
code
=
sdbWrite
(
pOper
,
pHead
,
pHead
->
msgType
);
void
*
key
=
sdbGetObjKey
(
pTable
,
pOper
->
pObj
);
taosFreeQitem
(
pHead
);
int32_t
keySize
=
0
;
if
(
code
<
0
)
return
code
;
switch
(
pTable
->
keyType
)
{
case
SDB_KEY_STRING
:
case
SDB_KEY_VAR_STRING
:
keySize
=
strlen
((
char
*
)
key
)
+
1
;
break
;
case
SDB_KEY_INT
:
case
SDB_KEY_AUTO
:
keySize
=
sizeof
(
uint32_t
);
break
;
default:
return
TSDB_CODE_MND_SDB_INVAID_KEY_TYPE
;
}
}
return
sdbDeleteHash
(
pTable
,
pOper
);
int32_t
size
=
sizeof
(
SSdbOper
)
+
sizeof
(
SWalHead
)
+
keySize
+
SDB_SYNC_HACK
;
SSdbOper
*
pNewOper
=
taosAllocateQitem
(
size
);
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSdbOper
)
+
SDB_SYNC_HACK
;
pHead
->
version
=
0
;
pHead
->
len
=
keySize
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_DELETE
;
memcpy
(
pHead
->
cont
,
key
,
keySize
);
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, delete action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
sdbUpdateRow
(
SSdbOper
*
pOper
)
{
int32_t
sdbUpdateRow
(
SSdbOper
*
pOper
)
{
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
SSdbTable
*
pTable
=
(
SSdbTable
*
)
pOper
->
table
;
if
(
pTable
==
NULL
)
return
-
1
;
if
(
pTable
==
NULL
)
return
TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE
;
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
SSdbRow
*
pMeta
=
sdbGetRowMetaFromObj
(
pTable
,
pOper
->
pObj
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
sdbTrace
(
"table:%s, record is not there,
dele
te failed"
,
pTable
->
tableName
);
sdbTrace
(
"table:%s, record is not there,
upda
te failed"
,
pTable
->
tableName
);
return
-
1
;
return
TSDB_CODE_MND_SDB_OBJ_NOT_THERE
;
}
}
void
*
pMetaRow
=
pMeta
->
row
;
void
*
pMetaRow
=
pMeta
->
row
;
assert
(
pMetaRow
!=
NULL
);
if
(
pMetaRow
==
NULL
)
{
sdbError
(
"table:%s, record meta is null"
,
pTable
->
tableName
);
return
TSDB_CODE_MND_SDB_INVAID_META_ROW
;
}
i
f
(
pOper
->
type
==
SDB_OPER_GLOBAL
)
{
i
nt32_t
code
=
sdbUpdateHash
(
pTable
,
pOper
);
int32_t
size
=
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
SWalHead
*
pHead
=
taosAllocateQitem
(
siz
e
);
sdbError
(
"table:%s, failed to update hash"
,
pTable
->
tableNam
e
);
pHead
->
version
=
0
;
return
code
;
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_UPDATE
;
}
pOper
->
rowData
=
pHead
->
cont
;
// just update data in memory
(
*
pTable
->
encodeFp
)(
pOper
);
if
(
pOper
->
type
!=
SDB_OPER_GLOBAL
)
{
pHead
->
len
=
pOper
->
rowSize
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
sdbWrite
(
pOper
,
pHead
,
pHead
->
msgType
);
int32_t
size
=
sizeof
(
SSdbOper
)
+
sizeof
(
SWalHead
)
+
pTable
->
maxRowSize
+
SDB_SYNC_HACK
;
taosFreeQitem
(
pHead
);
SSdbOper
*
pNewOper
=
taosAllocateQitem
(
size
);
if
(
code
<
0
)
return
code
;
}
SWalHead
*
pHead
=
(
void
*
)
pNewOper
+
sizeof
(
SSdbOper
)
+
SDB_SYNC_HACK
;
pHead
->
version
=
0
;
return
sdbUpdateHash
(
pTable
,
pOper
);
pHead
->
msgType
=
pTable
->
tableId
*
10
+
SDB_ACTION_UPDATE
;
pOper
->
rowData
=
pHead
->
cont
;
(
*
pTable
->
encodeFp
)(
pOper
);
pHead
->
len
=
pOper
->
rowSize
;
memcpy
(
pNewOper
,
pOper
,
sizeof
(
SSdbOper
));
if
(
pNewOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, update action is add to sdb queue"
,
pNewOper
->
pMsg
->
rpcMsg
.
ahandle
,
pNewOper
->
pMsg
);
}
taosWriteQitem
(
tsSdbWriteQueue
,
TAOS_QTYPE_RPC
,
pNewOper
);
return
TSDB_CODE_SUCCESS
;
}
}
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
)
{
void
*
sdbFetchRow
(
void
*
handle
,
void
*
pNode
,
void
**
ppRow
)
{
...
@@ -775,3 +854,158 @@ void sdbCloseTable(void *handle) {
...
@@ -775,3 +854,158 @@ void sdbCloseTable(void *handle) {
free
(
pTable
);
free
(
pTable
);
}
}
int32_t
sdbInitWriteWorker
()
{
tsSdbPool
.
num
=
1
;
tsSdbPool
.
writeWorker
=
(
SSdbWriteWorker
*
)
calloc
(
sizeof
(
SSdbWriteWorker
),
tsSdbPool
.
num
);
if
(
tsSdbPool
.
writeWorker
==
NULL
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SSdbWriteWorker
*
pWorker
=
tsSdbPool
.
writeWorker
+
i
;
pWorker
->
workerId
=
i
;
}
sdbAllocWriteQueue
();
mPrint
(
"sdb write is opened"
);
return
0
;
}
void
sdbCleanupWriteWorker
()
{
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SSdbWriteWorker
*
pWorker
=
tsSdbPool
.
writeWorker
+
i
;
if
(
pWorker
->
thread
)
{
taosQsetThreadResume
(
tsSdbWriteQset
);
}
}
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SSdbWriteWorker
*
pWorker
=
tsSdbPool
.
writeWorker
+
i
;
if
(
pWorker
->
thread
)
{
pthread_join
(
pWorker
->
thread
,
NULL
);
}
}
sdbFreeWritequeue
();
mPrint
(
"sdb write is closed"
);
}
int32_t
sdbAllocWriteQueue
()
{
tsSdbWriteQueue
=
taosOpenQueue
();
if
(
tsSdbWriteQueue
==
NULL
)
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
tsSdbWriteQset
=
taosOpenQset
();
if
(
tsSdbWriteQset
==
NULL
)
{
taosCloseQueue
(
tsSdbWriteQueue
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
taosAddIntoQset
(
tsSdbWriteQset
,
tsSdbWriteQueue
,
NULL
);
tsSdbWriteQall
=
taosAllocateQall
();
if
(
tsSdbWriteQall
==
NULL
)
{
taosCloseQset
(
tsSdbWriteQset
);
taosCloseQueue
(
tsSdbWriteQueue
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
tsSdbPool
.
num
;
++
i
)
{
SSdbWriteWorker
*
pWorker
=
tsSdbPool
.
writeWorker
+
i
;
pWorker
->
workerId
=
i
;
pthread_attr_t
thAttr
;
pthread_attr_init
(
&
thAttr
);
pthread_attr_setdetachstate
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pthread_create
(
&
pWorker
->
thread
,
&
thAttr
,
sdbWorkerFp
,
pWorker
)
!=
0
)
{
mError
(
"failed to create thread to process sdb write queue, reason:%s"
,
strerror
(
errno
));
taosFreeQall
(
tsSdbWriteQall
);
taosCloseQset
(
tsSdbWriteQset
);
taosCloseQueue
(
tsSdbWriteQueue
);
return
TSDB_CODE_MND_OUT_OF_MEMORY
;
}
pthread_attr_destroy
(
&
thAttr
);
mTrace
(
"sdb write worker:%d is launched, total:%d"
,
pWorker
->
workerId
,
tsSdbPool
.
num
);
}
mTrace
(
"sdb write queue:%p is allocated"
,
tsSdbWriteQueue
);
return
TSDB_CODE_SUCCESS
;
}
void
sdbFreeWritequeue
()
{
taosCloseQset
(
tsSdbWriteQueue
);
taosFreeQall
(
tsSdbWriteQall
);
taosCloseQset
(
tsSdbWriteQset
);
tsSdbWriteQall
=
NULL
;
tsSdbWriteQset
=
NULL
;
tsSdbWriteQueue
=
NULL
;
}
int
sdbWriteToQueue
(
void
*
param
,
void
*
data
,
int
type
)
{
SWalHead
*
pHead
=
data
;
int
size
=
sizeof
(
SWalHead
)
+
pHead
->
len
;
SWalHead
*
pWal
=
(
SWalHead
*
)
taosAllocateQitem
(
size
);
memcpy
(
pWal
,
pHead
,
size
);
taosWriteQitem
(
tsSdbWriteQueue
,
type
,
pWal
);
return
0
;
}
static
void
*
sdbWorkerFp
(
void
*
param
)
{
SWalHead
*
pHead
;
SSdbOper
*
pOper
;
int32_t
type
;
int32_t
numOfMsgs
;
void
*
item
;
void
*
unUsed
;
while
(
1
)
{
numOfMsgs
=
taosReadAllQitemsFromQset
(
tsSdbWriteQset
,
tsSdbWriteQall
,
&
unUsed
);
if
(
numOfMsgs
==
0
)
{
sdbTrace
(
"sdbWorkerFp: got no message from qset, exiting..."
);
break
;
}
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
tsSdbWriteQall
,
&
type
,
&
item
);
if
(
type
==
TAOS_QTYPE_RPC
)
{
pOper
=
(
SSdbOper
*
)
item
;
pHead
=
(
void
*
)
pOper
+
sizeof
(
SSdbOper
)
+
SDB_SYNC_HACK
;
}
else
{
pHead
=
(
SWalHead
*
)
item
;
pOper
=
NULL
;
}
if
(
pOper
!=
NULL
&&
pOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, will be processed in sdb queue"
,
pOper
->
pMsg
->
rpcMsg
.
ahandle
,
pOper
->
pMsg
);
}
int32_t
code
=
sdbWrite
(
pOper
,
pHead
,
type
);
if
(
pOper
)
pOper
->
retCode
=
code
;
}
walFsync
(
tsSdbObj
.
wal
);
// browse all items, and process them one by one
taosResetQitems
(
tsSdbWriteQall
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
tsSdbWriteQall
,
&
type
,
&
item
);
if
(
type
==
TAOS_QTYPE_RPC
)
{
pOper
=
(
SSdbOper
*
)
item
;
if
(
pOper
!=
NULL
&&
pOper
->
cb
!=
NULL
)
{
pOper
->
retCode
=
(
*
pOper
->
cb
)(
pOper
->
pMsg
,
pOper
->
retCode
);
}
if
(
pOper
!=
NULL
&&
pOper
->
pMsg
!=
NULL
)
{
sdbTrace
(
"app:%p:%p, msg is processed, result:%s"
,
pOper
->
pMsg
->
rpcMsg
.
ahandle
,
pOper
->
pMsg
,
tstrerror
(
pOper
->
retCode
));
}
dnodeSendRpcMnodeWriteRsp
(
pOper
->
pMsg
,
pOper
->
retCode
);
}
taosFreeQitem
(
item
);
}
}
return
NULL
;
}
src/mnode/src/mnodeTable.c
浏览文件 @
88519c19
此差异已折叠。
点击以展开。
src/mnode/src/mnodeUser.c
浏览文件 @
88519c19
...
@@ -102,11 +102,13 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
...
@@ -102,11 +102,13 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
}
}
static
int32_t
mnodeUserActionRestored
()
{
static
int32_t
mnodeUserActionRestored
()
{
if
(
dnodeIsFirstDeploy
())
{
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsUserSdb
);
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
mPrint
(
"dnode first deploy, create root user"
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
"root"
);
SAcctObj
*
pAcct
=
mnodeGetAcct
(
"root"
);
mnodeCreateUser
(
pAcct
,
"root"
,
"taosdata"
);
mnodeCreateUser
(
pAcct
,
"root"
,
"taosdata"
,
NULL
);
mnodeCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
);
mnodeCreateUser
(
pAcct
,
"monitor"
,
tsInternalPass
,
NULL
);
mnodeCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
);
mnodeCreateUser
(
pAcct
,
"_root"
,
tsInternalPass
,
NULL
);
mnodeDecAcctRef
(
pAcct
);
mnodeDecAcctRef
(
pAcct
);
}
}
...
@@ -170,22 +172,24 @@ void mnodeDecUserRef(SUserObj *pUser) {
...
@@ -170,22 +172,24 @@ void mnodeDecUserRef(SUserObj *pUser) {
return
sdbDecRef
(
tsUserSdb
,
pUser
);
return
sdbDecRef
(
tsUserSdb
,
pUser
);
}
}
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
)
{
static
int32_t
mnodeUpdateUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsUserSdb
,
.
table
=
tsUserSdb
,
.
pObj
=
pUser
.
pObj
=
pUser
,
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbUpdateRow
(
&
oper
);
int32_t
code
=
sdbUpdateRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
mLPrint
(
"user:%s, is altered by %s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
int32_t
mnodeCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int32_t
mnodeCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
,
void
*
pMsg
)
{
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_USER
);
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_USER
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
...
@@ -223,31 +227,36 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass) {
...
@@ -223,31 +227,36 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass) {
}
}
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsUserSdb
,
.
table
=
tsUserSdb
,
.
pObj
=
pUser
,
.
pObj
=
pUser
,
.
rowSize
=
sizeof
(
SUserObj
)
.
rowSize
=
sizeof
(
SUserObj
),
.
pMsg
=
pMsg
};
};
code
=
sdbInsertRow
(
&
oper
);
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pUser
);
tfree
(
pUser
);
code
=
TSDB_CODE_MND_SDB_ERROR
;
}
else
{
mLPrint
(
"user:%s, is created by %s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
}
}
static
int32_t
mnodeDropUser
(
SUserObj
*
pUser
)
{
static
int32_t
mnodeDropUser
(
SUserObj
*
pUser
,
void
*
pMsg
)
{
SSdbOper
oper
=
{
SSdbOper
oper
=
{
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsUserSdb
,
.
table
=
tsUserSdb
,
.
pObj
=
pUser
.
pObj
=
pUser
,
.
pMsg
=
pMsg
};
};
int32_t
code
=
sdbDeleteRow
(
&
oper
);
int32_t
code
=
sdbDeleteRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
==
TSDB_CODE_SUCCESS
)
{
code
=
TSDB_CODE_MND_SDB_ERROR
;
mLPrint
(
"user:%s, is dropped by %s"
,
pUser
->
user
,
mnodeGetUserFromMsg
(
pMsg
));
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
return
code
;
return
code
;
...
@@ -357,22 +366,25 @@ SUserObj *mnodeGetUserFromConn(void *pConn) {
...
@@ -357,22 +366,25 @@ SUserObj *mnodeGetUserFromConn(void *pConn) {
}
}
}
}
char
*
mnodeGetUserFromMsg
(
void
*
pMsg
)
{
SMnodeMsg
*
pMnodeMsg
=
pMsg
;
if
(
pMnodeMsg
!=
NULL
&&
pMnodeMsg
->
pUser
!=
NULL
)
{
return
pMnodeMsg
->
pUser
->
user
;
}
else
{
return
"system"
;
}
}
static
int32_t
mnodeProcessCreateUserMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessCreateUserMsg
(
SMnodeMsg
*
pMsg
)
{
int32_t
code
;
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
SUserObj
*
pOperUser
=
pMsg
->
pUser
;
if
(
pOperUser
->
superAuth
)
{
if
(
pOperUser
->
superAuth
)
{
SCMCreateUserMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
SCMCreateUserMsg
*
pCreate
=
pMsg
->
rpcMsg
.
pCont
;
code
=
mnodeCreateUser
(
pOperUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
);
return
mnodeCreateUser
(
pOperUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s, is created by %s"
,
pCreate
->
user
,
pOperUser
->
user
);
}
}
else
{
}
else
{
mError
(
"user:%s, no rights to create user"
,
pOperUser
->
user
);
mError
(
"user:%s, no rights to create user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_MND_NO_RIGHTS
;
return
TSDB_CODE_MND_NO_RIGHTS
;
}
}
return
code
;
}
}
static
int32_t
mnodeProcessAlterUserMsg
(
SMnodeMsg
*
pMsg
)
{
static
int32_t
mnodeProcessAlterUserMsg
(
SMnodeMsg
*
pMsg
)
{
...
@@ -409,8 +421,7 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) {
...
@@ -409,8 +421,7 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) {
if
(
hasRight
)
{
if
(
hasRight
)
{
memset
(
pUser
->
pass
,
0
,
sizeof
(
pUser
->
pass
));
memset
(
pUser
->
pass
,
0
,
sizeof
(
pUser
->
pass
));
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
code
=
mnodeUpdateUser
(
pUser
);
code
=
mnodeUpdateUser
(
pUser
,
pMsg
);
mLPrint
(
"user:%s, password is altered by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
}
else
{
mError
(
"user:%s, no rights to alter user"
,
pOperUser
->
user
);
mError
(
"user:%s, no rights to alter user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
TSDB_CODE_MND_NO_RIGHTS
;
...
@@ -450,8 +461,7 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) {
...
@@ -450,8 +461,7 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) {
pUser
->
writeAuth
=
1
;
pUser
->
writeAuth
=
1
;
}
}
code
=
mnodeUpdateUser
(
pUser
);
code
=
mnodeUpdateUser
(
pUser
,
pMsg
);
mLPrint
(
"user:%s, privilege is altered by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
}
else
{
mError
(
"user:%s, no rights to alter user"
,
pOperUser
->
user
);
mError
(
"user:%s, no rights to alter user"
,
pOperUser
->
user
);
code
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
TSDB_CODE_MND_NO_RIGHTS
;
...
@@ -497,10 +507,7 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg) {
...
@@ -497,10 +507,7 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg) {
}
}
if
(
hasRight
)
{
if
(
hasRight
)
{
code
=
mnodeDropUser
(
pUser
);
code
=
mnodeDropUser
(
pUser
,
pMsg
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s, is dropped by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
}
else
{
}
else
{
code
=
TSDB_CODE_MND_NO_RIGHTS
;
code
=
TSDB_CODE_MND_NO_RIGHTS
;
}
}
...
...
src/mnode/src/mnodeVgroup.c
浏览文件 @
88519c19
...
@@ -149,7 +149,7 @@ static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) {
...
@@ -149,7 +149,7 @@ static int32_t mnodeVgroupActionUpdate(SSdbOper *pOper) {
}
}
}
}
memcpy
(
pVgroup
,
pNew
,
pOper
->
rowSize
);
memcpy
(
pVgroup
,
pNew
,
sizeof
(
SVgObj
)
);
free
(
pNew
);
free
(
pNew
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
...
@@ -299,6 +299,27 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) {
...
@@ -299,6 +299,27 @@ void *mnodeGetNextVgroup(void *pIter, SVgObj **pVgroup) {
return
sdbFetchRow
(
tsVgroupSdb
,
pIter
,
(
void
**
)
pVgroup
);
return
sdbFetchRow
(
tsVgroupSdb
,
pIter
,
(
void
**
)
pVgroup
);
}
}
static
int32_t
mnodeCreateVgroupCb
(
SMnodeMsg
*
pMsg
,
int32_t
code
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pMsg
->
pVgroup
=
NULL
;
return
code
;
}
SVgObj
*
pVgroup
=
pMsg
->
pVgroup
;
SDbObj
*
pDb
=
pMsg
->
pDb
;
mPrint
(
"vgId:%d, is created in mnode, db:%s replica:%d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
mPrint
(
"vgId:%d, index:%d, dnode:%d"
,
pVgroup
->
vgId
,
i
,
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
}
mnodeIncVgroupRef
(
pVgroup
);
pMsg
->
expected
=
pVgroup
->
numOfVnodes
;
mnodeSendCreateVgroupMsg
(
pVgroup
,
pMsg
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
int32_t
mnodeCreateVgroup
(
SMnodeMsg
*
pMsg
,
SDbObj
*
pDb
)
{
int32_t
mnodeCreateVgroup
(
SMnodeMsg
*
pMsg
,
SDbObj
*
pDb
)
{
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
SVgObj
*
pVgroup
=
(
SVgObj
*
)
calloc
(
1
,
sizeof
(
SVgObj
));
strcpy
(
pVgroup
->
dbName
,
pDb
->
name
);
strcpy
(
pVgroup
->
dbName
,
pDb
->
name
);
...
@@ -314,26 +335,22 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) {
...
@@ -314,26 +335,22 @@ int32_t mnodeCreateVgroup(SMnodeMsg *pMsg, SDbObj *pDb) {
.
type
=
SDB_OPER_GLOBAL
,
.
type
=
SDB_OPER_GLOBAL
,
.
table
=
tsVgroupSdb
,
.
table
=
tsVgroupSdb
,
.
pObj
=
pVgroup
,
.
pObj
=
pVgroup
,
.
rowSize
=
sizeof
(
SVgObj
)
.
rowSize
=
sizeof
(
SVgObj
),
.
pMsg
=
pMsg
,
.
cb
=
mnodeCreateVgroupCb
};
};
pMsg
->
pVgroup
=
pVgroup
;
int32_t
code
=
sdbInsertRow
(
&
oper
);
int32_t
code
=
sdbInsertRow
(
&
oper
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pMsg
->
pVgroup
=
NULL
;
tfree
(
pVgroup
);
tfree
(
pVgroup
);
return
TSDB_CODE_MND_SDB_ERROR
;
}
else
{
}
if
(
pMsg
!=
NULL
)
code
=
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
mPrint
(
"vgId:%d, is created in mnode, db:%s replica:%d"
,
pVgroup
->
vgId
,
pDb
->
name
,
pVgroup
->
numOfVnodes
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
mPrint
(
"vgId:%d, index:%d, dnode:%d"
,
pVgroup
->
vgId
,
i
,
pVgroup
->
vnodeGid
[
i
].
dnodeId
);
}
}
mnodeIncVgroupRef
(
pVgroup
);
return
code
;
pMsg
->
pVgroup
=
pVgroup
;
pMsg
->
expected
=
pVgroup
->
numOfVnodes
;
mnodeSendCreateVgroupMsg
(
pVgroup
,
pMsg
);
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
}
void
mnodeDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
void
mnodeDropVgroup
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
...
@@ -596,7 +613,6 @@ SRpcIpSet mnodeGetIpSetFromIp(char *ep) {
...
@@ -596,7 +613,6 @@ SRpcIpSet mnodeGetIpSetFromIp(char *ep) {
}
}
void
mnodeSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
void
mnodeSendCreateVnodeMsg
(
SVgObj
*
pVgroup
,
SRpcIpSet
*
ipSet
,
void
*
ahandle
)
{
mTrace
(
"vgId:%d, send create vnode:%d msg, ahandle:%p db:%s"
,
pVgroup
->
vgId
,
pVgroup
->
vgId
,
ahandle
,
pVgroup
->
dbName
);
SMDCreateVnodeMsg
*
pCreate
=
mnodeBuildCreateVnodeMsg
(
pVgroup
);
SMDCreateVnodeMsg
*
pCreate
=
mnodeBuildCreateVnodeMsg
(
pVgroup
);
SRpcMsg
rpcMsg
=
{
SRpcMsg
rpcMsg
=
{
.
handle
=
ahandle
,
.
handle
=
ahandle
,
...
@@ -609,9 +625,12 @@ void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
...
@@ -609,9 +625,12 @@ void mnodeSendCreateVnodeMsg(SVgObj *pVgroup, SRpcIpSet *ipSet, void *ahandle) {
}
}
void
mnodeSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
void
mnodeSendCreateVgroupMsg
(
SVgObj
*
pVgroup
,
void
*
ahandle
)
{
mTrace
(
"vgId:%d, send create all vnodes msg, ahandle:%p"
,
pVgroup
->
vgId
,
ahandle
);
mTrace
(
"vgId:%d, send create all vnodes msg, numOfVnodes:%d db:%s"
,
pVgroup
->
vgId
,
pVgroup
->
numOfVnodes
,
pVgroup
->
dbName
);
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
numOfVnodes
;
++
i
)
{
SRpcIpSet
ipSet
=
mnodeGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
pDnode
->
dnodeEp
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromIp
(
pVgroup
->
vnodeGid
[
i
].
pDnode
->
dnodeEp
);
mTrace
(
"vgId:%d, index:%d, send create vnode msg to dnode %s, ahandle:%p"
,
pVgroup
->
vgId
,
i
,
pVgroup
->
vnodeGid
[
i
].
pDnode
->
dnodeEp
,
ahandle
);
mnodeSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
ahandle
);
mnodeSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
ahandle
);
}
}
}
}
...
@@ -729,6 +748,7 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
...
@@ -729,6 +748,7 @@ static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
}
}
mnodeDecVgroupRef
(
pVgroup
);
mnodeDecVgroupRef
(
pVgroup
);
mTrace
(
"vgId:%d, send create vnode msg to dnode %s for vnode cfg msg"
,
pVgroup
->
vgId
,
pDnode
->
dnodeEp
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromIp
(
pDnode
->
dnodeEp
);
SRpcIpSet
ipSet
=
mnodeGetIpSetFromIp
(
pDnode
->
dnodeEp
);
mnodeSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
NULL
);
mnodeSendCreateVnodeMsg
(
pVgroup
,
&
ipSet
,
NULL
);
...
...
src/mnode/src/mnodeWrite.c
浏览文件 @
88519c19
...
@@ -43,7 +43,7 @@ void mnodeAddWriteMsgHandle(uint8_t msgType, int32_t (*fp)(SMnodeMsg *mnodeMsg))
...
@@ -43,7 +43,7 @@ void mnodeAddWriteMsgHandle(uint8_t msgType, int32_t (*fp)(SMnodeMsg *mnodeMsg))
int32_t
mnodeProcessWrite
(
SMnodeMsg
*
pMsg
)
{
int32_t
mnodeProcessWrite
(
SMnodeMsg
*
pMsg
)
{
if
(
pMsg
->
rpcMsg
.
pCont
==
NULL
)
{
if
(
pMsg
->
rpcMsg
.
pCont
==
NULL
)
{
mError
(
"
%p, msg:%s in mwrite queue, content is null"
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
mError
(
"
app:%p:%p, msg:%s content is null"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
return
TSDB_CODE_MND_INVALID_MSG_LEN
;
return
TSDB_CODE_MND_INVALID_MSG_LEN
;
}
}
...
@@ -54,27 +54,31 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
...
@@ -54,27 +54,31 @@ int32_t mnodeProcessWrite(SMnodeMsg *pMsg) {
rpcRsp
->
rsp
=
ipSet
;
rpcRsp
->
rsp
=
ipSet
;
rpcRsp
->
len
=
sizeof
(
SRpcIpSet
);
rpcRsp
->
len
=
sizeof
(
SRpcIpSet
);
mTrace
(
"%p, msg:%s in mwrite queue, will be redireced inUse:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
ipSet
->
inUse
);
mTrace
(
"app:%p:%p, msg:%s will be redireced inUse:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
ipSet
->
inUse
);
for
(
int32_t
i
=
0
;
i
<
ipSet
->
numOfIps
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
ipSet
->
numOfIps
;
++
i
)
{
mTrace
(
"mnode index:%d ip:%s:%d"
,
i
,
ipSet
->
fqdn
[
i
],
htons
(
ipSet
->
port
[
i
]));
mTrace
(
"app:%p:%p, mnode index:%d ip:%s:%d"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
i
,
ipSet
->
fqdn
[
i
],
htons
(
ipSet
->
port
[
i
]));
}
}
return
TSDB_CODE_RPC_REDIRECT
;
return
TSDB_CODE_RPC_REDIRECT
;
}
}
if
(
tsMnodeProcessWriteMsgFp
[
pMsg
->
rpcMsg
.
msgType
]
==
NULL
)
{
if
(
tsMnodeProcessWriteMsgFp
[
pMsg
->
rpcMsg
.
msgType
]
==
NULL
)
{
mError
(
"
%p, msg:%s in mwrite queue, not processed"
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
mError
(
"
app:%p:%p, msg:%s not processed"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
return
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
return
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
}
}
int32_t
code
=
mnodeInitMsg
(
pMsg
);
int32_t
code
=
mnodeInitMsg
(
pMsg
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
mError
(
"%p, msg:%s in mwrite queue, not processed reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
tstrerror
(
code
));
mError
(
"app:%p:%p, msg:%s not processed, reason:%s"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
],
tstrerror
(
code
));
return
code
;
return
code
;
}
}
if
(
!
pMsg
->
pUser
->
writeAuth
)
{
if
(
!
pMsg
->
pUser
->
writeAuth
)
{
mError
(
"%p, msg:%s in mwrite queue, not processed, no write auth"
,
pMsg
->
rpcMsg
.
ahandle
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
mError
(
"app:%p:%p, msg:%s not processed, no write auth"
,
pMsg
->
rpcMsg
.
ahandle
,
pMsg
,
taosMsg
[
pMsg
->
rpcMsg
.
msgType
]);
return
TSDB_CODE_MND_NO_RIGHTS
;
return
TSDB_CODE_MND_NO_RIGHTS
;
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
88519c19
...
@@ -3335,7 +3335,7 @@ void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *
...
@@ -3335,7 +3335,7 @@ void setWindowResOutputBufInitCtx(SQueryRuntimeEnv *pRuntimeEnv, SWindowResult *
int32_t
setAdditionalInfo
(
SQInfo
*
pQInfo
,
STableId
*
pTableId
,
STableQueryInfo
*
pTableQueryInfo
)
{
int32_t
setAdditionalInfo
(
SQInfo
*
pQInfo
,
STableId
*
pTableId
,
STableQueryInfo
*
pTableQueryInfo
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
assert
(
pTableQueryInfo
->
lastKey
>=
TSKEY_INITIAL_VAL
);
//
assert(pTableQueryInfo->lastKey >= TSKEY_INITIAL_VAL);
setTagVal
(
pRuntimeEnv
,
pTableId
,
pQInfo
->
tsdb
);
setTagVal
(
pRuntimeEnv
,
pTableId
,
pQInfo
->
tsdb
);
...
@@ -4230,7 +4230,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4230,7 +4230,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
SArray
*
group
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
pQInfo
->
groupIndex
);
SArray
*
group
=
taosArrayGetP
(
pQInfo
->
groupInfo
.
pGroupList
,
pQInfo
->
groupIndex
);
qTrace
(
"QInfo:%p last_row query on group:%d, total group:%d, current group:%d"
,
pQInfo
,
pQInfo
->
groupIndex
,
qTrace
(
"QInfo:%p last_row query on group:%d, total group:%d, current group:%d"
,
pQInfo
,
pQInfo
->
groupIndex
,
numOfGroups
);
numOfGroups
,
group
);
STsdbQueryCond
cond
=
{
STsdbQueryCond
cond
=
{
.
twindow
=
pQuery
->
window
,
.
twindow
=
pQuery
->
window
,
...
@@ -4264,10 +4264,10 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
...
@@ -4264,10 +4264,10 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
s
,
0
),
pQInfo
->
tsdb
);
setTagVal
(
pRuntimeEnv
,
(
STableId
*
)
taosArrayGet
(
s
,
0
),
pQInfo
->
tsdb
);
taosArrayDestroy
(
s
);
if
(
isFirstLastRowQuery
(
pQuery
))
{
if
(
isFirstLastRowQuery
(
pQuery
))
{
assert
(
taosArrayGetSize
(
s
)
==
1
);
assert
(
taosArrayGetSize
(
s
)
==
1
);
}
}
taosArrayDestroy
(
s
);
// here we simply set the first table as current table
// here we simply set the first table as current table
pQuery
->
current
=
((
SGroupItem
*
)
taosArrayGet
(
group
,
0
))
->
info
;
pQuery
->
current
=
((
SGroupItem
*
)
taosArrayGet
(
group
,
0
))
->
info
;
...
@@ -5380,6 +5380,7 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
...
@@ -5380,6 +5380,7 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
if
((
lower
==
TSDB_RELATION_GREATER_EQUAL
||
lower
==
TSDB_RELATION_GREATER
)
&&
if
((
lower
==
TSDB_RELATION_GREATER_EQUAL
||
lower
==
TSDB_RELATION_GREATER
)
&&
(
upper
==
TSDB_RELATION_LESS_EQUAL
||
upper
==
TSDB_RELATION_LESS
))
{
(
upper
==
TSDB_RELATION_LESS_EQUAL
||
upper
==
TSDB_RELATION_LESS
))
{
assert
(
rangeFilterArray
!=
NULL
);
if
(
lower
==
TSDB_RELATION_GREATER_EQUAL
)
{
if
(
lower
==
TSDB_RELATION_GREATER_EQUAL
)
{
if
(
upper
==
TSDB_RELATION_LESS_EQUAL
)
{
if
(
upper
==
TSDB_RELATION_LESS_EQUAL
)
{
pSingleColFilter
->
fp
=
rangeFilterArray
[
4
];
pSingleColFilter
->
fp
=
rangeFilterArray
[
4
];
...
@@ -5394,11 +5395,12 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
...
@@ -5394,11 +5395,12 @@ static int32_t createFilterInfo(void *pQInfo, SQuery *pQuery) {
}
}
}
}
}
else
{
// set callback filter function
}
else
{
// set callback filter function
assert
(
filterArray
!=
NULL
);
if
(
lower
!=
TSDB_RELATION_INVALID
)
{
if
(
lower
!=
TSDB_RELATION_INVALID
)
{
pSingleColFilter
->
fp
=
filterArray
[
lower
];
pSingleColFilter
->
fp
=
filterArray
[
lower
];
if
(
upper
!=
TSDB_RELATION_INVALID
)
{
if
(
upper
!=
TSDB_RELATION_INVALID
)
{
qError
(
"pQInfo:%p failed to get filter function, invalid filter condition"
,
pQInfo
,
type
);
qError
(
"pQInfo:%p failed to get filter function, invalid filter condition
: %d
"
,
pQInfo
,
type
);
return
TSDB_CODE_QRY_INVALID_MSG
;
return
TSDB_CODE_QRY_INVALID_MSG
;
}
}
}
else
{
}
else
{
...
...
src/query/src/tvariant.c
浏览文件 @
88519c19
...
@@ -887,7 +887,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) {
...
@@ -887,7 +887,7 @@ int32_t tVariantTypeSetType(tVariant *pVariant, char type) {
free
(
pVariant
->
pz
);
free
(
pVariant
->
pz
);
pVariant
->
dKey
=
v
;
pVariant
->
dKey
=
v
;
}
else
if
(
pVariant
->
nType
>=
TSDB_DATA_TYPE_BOOL
&&
pVariant
->
nType
<=
TSDB_DATA_TYPE_BIGINT
)
{
}
else
if
(
pVariant
->
nType
>=
TSDB_DATA_TYPE_BOOL
&&
pVariant
->
nType
<=
TSDB_DATA_TYPE_BIGINT
)
{
pVariant
->
dKey
=
pVariant
->
i64Key
;
pVariant
->
dKey
=
(
double
)(
pVariant
->
i64Key
)
;
}
}
pVariant
->
nType
=
TSDB_DATA_TYPE_DOUBLE
;
pVariant
->
nType
=
TSDB_DATA_TYPE_DOUBLE
;
...
...
src/rpc/src/rpcMain.c
浏览文件 @
88519c19
...
@@ -489,17 +489,22 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pMsg, SRpcMsg
...
@@ -489,17 +489,22 @@ void rpcSendRecv(void *shandle, SRpcIpSet *pIpSet, const SRpcMsg *pMsg, SRpcMsg
// this API is used by server app to keep an APP context in case connection is broken
// this API is used by server app to keep an APP context in case connection is broken
int
rpcReportProgress
(
void
*
handle
,
char
*
pCont
,
int
contLen
)
{
int
rpcReportProgress
(
void
*
handle
,
char
*
pCont
,
int
contLen
)
{
SRpcConn
*
pConn
=
(
SRpcConn
*
)
handle
;
SRpcConn
*
pConn
=
(
SRpcConn
*
)
handle
;
int
code
=
0
;
rpcLockConn
(
pConn
);
if
(
pConn
->
user
[
0
])
{
if
(
pConn
->
user
[
0
])
{
// pReqMsg and reqMsgLen is re-used to store the context from app server
// pReqMsg and reqMsgLen is re-used to store the context from app server
pConn
->
pReqMsg
=
pCont
;
pConn
->
pReqMsg
=
pCont
;
pConn
->
reqMsgLen
=
contLen
;
pConn
->
reqMsgLen
=
contLen
;
return
0
;
}
else
{
}
tTrace
(
"%s, rpc connection is already released"
,
pConn
->
info
);
rpcFreeCont
(
pCont
);
code
=
-
1
;
}
tTrace
(
"%s, rpc connection is already released"
,
pConn
->
info
);
rpcUnlockConn
(
pConn
);
rpcFreeCont
(
pCont
);
return
code
;
return
-
1
;
}
}
/* todo: cancel process may have race condition, pContext may have been released
/* todo: cancel process may have race condition, pContext may have been released
...
@@ -555,18 +560,10 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
...
@@ -555,18 +560,10 @@ static SRpcConn *rpcOpenConn(SRpcInfo *pRpc, char *peerFqdn, uint16_t peerPort,
return
pConn
;
return
pConn
;
}
}
static
void
rpcCloseConn
(
void
*
thandle
)
{
static
void
rpcReleaseConn
(
SRpcConn
*
pConn
)
{
SRpcConn
*
pConn
=
(
SRpcConn
*
)
thandle
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
if
(
pConn
->
user
[
0
]
==
0
)
return
;
if
(
pConn
->
user
[
0
]
==
0
)
return
;
rpcLockConn
(
pConn
);
if
(
pConn
->
user
[
0
]
==
0
)
{
rpcUnlockConn
(
pConn
);
return
;
}
pConn
->
user
[
0
]
=
0
;
pConn
->
user
[
0
]
=
0
;
if
(
taosCloseConn
[
pConn
->
connType
])
(
*
taosCloseConn
[
pConn
->
connType
])(
pConn
->
chandle
);
if
(
taosCloseConn
[
pConn
->
connType
])
(
*
taosCloseConn
[
pConn
->
connType
])(
pConn
->
chandle
);
...
@@ -591,7 +588,16 @@ static void rpcCloseConn(void *thandle) {
...
@@ -591,7 +588,16 @@ static void rpcCloseConn(void *thandle) {
taosFreeId
(
pRpc
->
idPool
,
pConn
->
sid
);
taosFreeId
(
pRpc
->
idPool
,
pConn
->
sid
);
pConn
->
pContext
=
NULL
;
pConn
->
pContext
=
NULL
;
tTrace
(
"%s, rpc connection is closed"
,
pConn
->
info
);
tTrace
(
"%s, rpc connection is released"
,
pConn
->
info
);
}
static
void
rpcCloseConn
(
void
*
thandle
)
{
SRpcConn
*
pConn
=
(
SRpcConn
*
)
thandle
;
rpcLockConn
(
pConn
);
if
(
pConn
->
user
[
0
])
rpcReleaseConn
(
pConn
);
rpcUnlockConn
(
pConn
);
rpcUnlockConn
(
pConn
);
}
}
...
@@ -911,8 +917,8 @@ static void rpcProcessBrokenLink(SRpcConn *pConn) {
...
@@ -911,8 +917,8 @@ static void rpcProcessBrokenLink(SRpcConn *pConn) {
if
(
pConn
->
inType
)
rpcReportBrokenLinkToServer
(
pConn
);
if
(
pConn
->
inType
)
rpcReportBrokenLinkToServer
(
pConn
);
rpcReleaseConn
(
pConn
);
rpcUnlockConn
(
pConn
);
rpcUnlockConn
(
pConn
);
rpcCloseConn
(
pConn
);
}
}
static
void
*
rpcProcessMsgFromPeer
(
SRecvInfo
*
pRecv
)
{
static
void
*
rpcProcessMsgFromPeer
(
SRecvInfo
*
pRecv
)
{
...
@@ -1217,7 +1223,6 @@ static void rpcProcessConnError(void *param, void *id) {
...
@@ -1217,7 +1223,6 @@ static void rpcProcessConnError(void *param, void *id) {
static
void
rpcProcessRetryTimer
(
void
*
param
,
void
*
tmrId
)
{
static
void
rpcProcessRetryTimer
(
void
*
param
,
void
*
tmrId
)
{
SRpcConn
*
pConn
=
(
SRpcConn
*
)
param
;
SRpcConn
*
pConn
=
(
SRpcConn
*
)
param
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
SRpcInfo
*
pRpc
=
pConn
->
pRpc
;
int
reportDisc
=
0
;
rpcLockConn
(
pConn
);
rpcLockConn
(
pConn
);
...
@@ -1233,31 +1238,33 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) {
...
@@ -1233,31 +1238,33 @@ static void rpcProcessRetryTimer(void *param, void *tmrId) {
}
else
{
}
else
{
// close the connection
// close the connection
tTrace
(
"%s, failed to send msg:%s to %s:%hu"
,
pConn
->
info
,
taosMsg
[
pConn
->
outType
],
pConn
->
peerFqdn
,
pConn
->
peerPort
);
tTrace
(
"%s, failed to send msg:%s to %s:%hu"
,
pConn
->
info
,
taosMsg
[
pConn
->
outType
],
pConn
->
peerFqdn
,
pConn
->
peerPort
);
reportDisc
=
1
;
if
(
pConn
->
pContext
)
{
pConn
->
pContext
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
taosTmrStart
(
rpcProcessConnError
,
0
,
pConn
->
pContext
,
pRpc
->
tmrCtrl
);
rpcReleaseConn
(
pConn
);
}
}
}
}
else
{
}
else
{
tTrace
(
"%s, retry timer not processed"
,
pConn
->
info
);
tTrace
(
"%s, retry timer not processed"
,
pConn
->
info
);
}
}
rpcUnlockConn
(
pConn
);
rpcUnlockConn
(
pConn
);
if
(
reportDisc
&&
pConn
->
pContext
)
{
pConn
->
pContext
->
code
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
rpcProcessConnError
(
pConn
->
pContext
,
NULL
);
rpcCloseConn
(
pConn
);
}
}
}
static
void
rpcProcessIdleTimer
(
void
*
param
,
void
*
tmrId
)
{
static
void
rpcProcessIdleTimer
(
void
*
param
,
void
*
tmrId
)
{
SRpcConn
*
pConn
=
(
SRpcConn
*
)
param
;
SRpcConn
*
pConn
=
(
SRpcConn
*
)
param
;
rpcLockConn
(
pConn
);
if
(
pConn
->
user
[
0
])
{
if
(
pConn
->
user
[
0
])
{
tTrace
(
"%s, close the connection since no activity"
,
pConn
->
info
);
tTrace
(
"%s, close the connection since no activity"
,
pConn
->
info
);
if
(
pConn
->
inType
)
rpcReportBrokenLinkToServer
(
pConn
);
if
(
pConn
->
inType
)
rpcReportBrokenLinkToServer
(
pConn
);
rpc
Clo
seConn
(
pConn
);
rpc
Relea
seConn
(
pConn
);
}
else
{
}
else
{
tTrace
(
"%s, idle timer:%p not processed"
,
pConn
->
info
,
tmrId
);
tTrace
(
"%s, idle timer:%p not processed"
,
pConn
->
info
,
tmrId
);
}
}
rpcUnlockConn
(
pConn
);
}
}
static
void
rpcProcessProgressTimer
(
void
*
param
,
void
*
tmrId
)
{
static
void
rpcProcessProgressTimer
(
void
*
param
,
void
*
tmrId
)
{
...
...
src/rpc/src/rpcTcp.c
浏览文件 @
88519c19
...
@@ -117,7 +117,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
...
@@ -117,7 +117,7 @@ void *taosInitTcpServer(uint32_t ip, uint16_t port, char *label, int numOfThread
code
=
pthread_mutex_init
(
&
(
pThreadObj
->
mutex
),
NULL
);
code
=
pthread_mutex_init
(
&
(
pThreadObj
->
mutex
),
NULL
);
if
(
code
<
0
)
{
if
(
code
<
0
)
{
tError
(
"%s failed to init TCP process data mutex(%s)"
,
label
,
strerror
(
errno
));
tError
(
"%s failed to init TCP process data mutex(%s)"
,
label
,
strerror
(
errno
));
break
;
;
break
;
}
}
pThreadObj
->
pollFd
=
epoll_create
(
10
);
// size does not matter
pThreadObj
->
pollFd
=
epoll_create
(
10
);
// size does not matter
...
@@ -367,7 +367,7 @@ static void taosReportBrokenLink(SFdObj *pFdObj) {
...
@@ -367,7 +367,7 @@ static void taosReportBrokenLink(SFdObj *pFdObj) {
recvInfo
.
ip
=
0
;
recvInfo
.
ip
=
0
;
recvInfo
.
port
=
0
;
recvInfo
.
port
=
0
;
recvInfo
.
shandle
=
pThreadObj
->
shandle
;
recvInfo
.
shandle
=
pThreadObj
->
shandle
;
recvInfo
.
thandle
=
pFdObj
->
thandle
;
;
recvInfo
.
thandle
=
pFdObj
->
thandle
;
recvInfo
.
chandle
=
NULL
;
recvInfo
.
chandle
=
NULL
;
recvInfo
.
connType
=
RPC_CONN_TCP
;
recvInfo
.
connType
=
RPC_CONN_TCP
;
(
*
(
pThreadObj
->
processData
))(
&
recvInfo
);
(
*
(
pThreadObj
->
processData
))(
&
recvInfo
);
...
@@ -414,7 +414,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
...
@@ -414,7 +414,7 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) {
pInfo
->
ip
=
pFdObj
->
ip
;
pInfo
->
ip
=
pFdObj
->
ip
;
pInfo
->
port
=
pFdObj
->
port
;
pInfo
->
port
=
pFdObj
->
port
;
pInfo
->
shandle
=
pThreadObj
->
shandle
;
pInfo
->
shandle
=
pThreadObj
->
shandle
;
pInfo
->
thandle
=
pFdObj
->
thandle
;
;
pInfo
->
thandle
=
pFdObj
->
thandle
;
pInfo
->
chandle
=
pFdObj
;
pInfo
->
chandle
=
pFdObj
;
pInfo
->
connType
=
RPC_CONN_TCP
;
pInfo
->
connType
=
RPC_CONN_TCP
;
...
...
src/tsdb/src/tsdbMeta.c
浏览文件 @
88519c19
...
@@ -600,6 +600,10 @@ int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
...
@@ -600,6 +600,10 @@ int tsdbDropTable(TsdbRepoT *repo, STableId tableId) {
return
-
1
;
return
-
1
;
}
}
if
(
pTable
->
cqhandle
!=
NULL
)
{
pRepo
->
appH
.
cqDropFunc
(
pTable
->
cqhandle
);
}
tsdbTrace
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
varDataVal
(
pTable
->
name
),
tsdbTrace
(
"vgId:%d, table %s is dropped! tid:%d, uid:%"
PRId64
,
pRepo
->
config
.
tsdbId
,
varDataVal
(
pTable
->
name
),
tableId
.
tid
,
tableId
.
uid
);
tableId
.
tid
,
tableId
.
uid
);
if
(
tsdbRemoveTableFromMeta
(
pMeta
,
pTable
,
true
)
<
0
)
return
-
1
;
if
(
tsdbRemoveTableFromMeta
(
pMeta
,
pTable
,
true
)
<
0
)
return
-
1
;
...
...
src/util/src/tmem.c
浏览文件 @
88519c19
...
@@ -29,7 +29,7 @@ static FILE* fpAllocLog = NULL;
...
@@ -29,7 +29,7 @@ static FILE* fpAllocLog = NULL;
// memory allocator which fails randomly
// memory allocator which fails randomly
extern
int32_t
taosGetTimestampSec
();
extern
int32_t
taosGetTimestampSec
();
static
int32_t
startTime
=
INT32_MAX
;
;
static
int32_t
startTime
=
INT32_MAX
;
static
bool
random_alloc_fail
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
static
bool
random_alloc_fail
(
size_t
size
,
const
char
*
file
,
uint32_t
line
)
{
if
(
taosGetTimestampSec
()
<
startTime
)
{
if
(
taosGetTimestampSec
()
<
startTime
)
{
...
...
src/vnode/src/vnodeMain.c
浏览文件 @
88519c19
...
@@ -119,7 +119,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
...
@@ -119,7 +119,7 @@ int32_t vnodeCreate(SMDCreateVnodeMsg *pVnodeCfg) {
tsdbCfg
.
minRowsPerFileBlock
=
pVnodeCfg
->
cfg
.
minRowsPerFileBlock
;
tsdbCfg
.
minRowsPerFileBlock
=
pVnodeCfg
->
cfg
.
minRowsPerFileBlock
;
tsdbCfg
.
maxRowsPerFileBlock
=
pVnodeCfg
->
cfg
.
maxRowsPerFileBlock
;
tsdbCfg
.
maxRowsPerFileBlock
=
pVnodeCfg
->
cfg
.
maxRowsPerFileBlock
;
tsdbCfg
.
precision
=
pVnodeCfg
->
cfg
.
precision
;
tsdbCfg
.
precision
=
pVnodeCfg
->
cfg
.
precision
;
tsdbCfg
.
compression
=
pVnodeCfg
->
cfg
.
compression
;
;
tsdbCfg
.
compression
=
pVnodeCfg
->
cfg
.
compression
;
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsdbDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
sprintf
(
tsdbDir
,
"%s/vnode%d/tsdb"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
sprintf
(
tsdbDir
,
"%s/vnode%d/tsdb"
,
tsVnodeDir
,
pVnodeCfg
->
cfg
.
vgId
);
...
@@ -325,6 +325,11 @@ void vnodeRelease(void *pVnodeRaw) {
...
@@ -325,6 +325,11 @@ void vnodeRelease(void *pVnodeRaw) {
tsdbCloseRepo
(
pVnode
->
tsdb
,
1
);
tsdbCloseRepo
(
pVnode
->
tsdb
,
1
);
pVnode
->
tsdb
=
NULL
;
pVnode
->
tsdb
=
NULL
;
// stop continuous query
if
(
pVnode
->
cq
)
cqClose
(
pVnode
->
cq
);
pVnode
->
cq
=
NULL
;
if
(
pVnode
->
wal
)
if
(
pVnode
->
wal
)
walClose
(
pVnode
->
wal
);
walClose
(
pVnode
->
wal
);
pVnode
->
wal
=
NULL
;
pVnode
->
wal
=
NULL
;
...
@@ -436,11 +441,6 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
...
@@ -436,11 +441,6 @@ static void vnodeCleanUp(SVnodeObj *pVnode) {
pVnode
->
sync
=
NULL
;
pVnode
->
sync
=
NULL
;
}
}
// stop continuous query
if
(
pVnode
->
cq
)
cqClose
(
pVnode
->
cq
);
pVnode
->
cq
=
NULL
;
// release local resources only after cutting off outside connections
// release local resources only after cutting off outside connections
vnodeRelease
(
pVnode
);
vnodeRelease
(
pVnode
);
}
}
...
...
tests/script/general/parser/alter.sim
浏览文件 @
88519c19
...
@@ -137,7 +137,7 @@ sleep 6000
...
@@ -137,7 +137,7 @@ sleep 6000
sql insert into tb1 values (now, 2, 'taos')
sql insert into tb1 values (now, 2, 'taos')
sleep 3000
sleep 3000
sql select * from strm
sql select * from strm
if $rows !=
1
then
if $rows !=
2
then
return -1
return -1
endi
endi
if $data04 != 1 then
if $data04 != 1 then
...
@@ -148,7 +148,7 @@ sleep 6000
...
@@ -148,7 +148,7 @@ sleep 6000
sql insert into tb1 values (now, 3, 'taos', 3);
sql insert into tb1 values (now, 3, 'taos', 3);
sleep 3000
sleep 3000
sql select * from strm
sql select * from strm
if $rows !=
1
then
if $rows !=
3
then
return -1
return -1
endi
endi
if $data04 != 1 then
if $data04 != 1 then
...
@@ -188,9 +188,9 @@ sql create table tb using mt tags(1)
...
@@ -188,9 +188,9 @@ sql create table tb using mt tags(1)
sleep 3000
sleep 3000
sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1)
sql insert into tb values ('2018-11-01 16:30:00.000', 1, 'insert', 1)
sql alter table mt drop column c3
sql alter table mt drop column c3
# the below query should be deleted after bug fix
sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert')
sql insert into tb values ('2018-11-01 16:29:59.000', 1, 'insert')
sql
_error
import into tb values ('2018-11-01 16:29:59.000', 1, 'import')
sql import into tb values ('2018-11-01 16:29:59.000', 1, 'import')
sql select * from tb order by ts desc
sql select * from tb order by ts desc
if $data01 != 1 then
if $data01 != 1 then
return -1
return -1
...
@@ -203,13 +203,13 @@ sql select * from tb order by ts desc
...
@@ -203,13 +203,13 @@ sql select * from tb order by ts desc
if $data03 != NULL then
if $data03 != NULL then
return -1
return -1
endi
endi
# the query below should be deleted after bug fix
sql reset query cache
sql reset query cache
sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql insert into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql
_error
import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:29:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3)
sql import into tb values ('2018-11-01 16:39:58.000', 2, 'import', 3)
sql select * from tb order by ts desc
sql select * from tb order by ts desc
if $rows !=
2
then
if $rows !=
4
then
return -1
return -1
endi
endi
if $data03 != 3 then
if $data03 != 3 then
...
...
tests/script/general/parser/stream.sim
浏览文件 @
88519c19
...
@@ -51,19 +51,20 @@ sql drop table strm
...
@@ -51,19 +51,20 @@ sql drop table strm
## [TBASE304]
## [TBASE304]
print ====== TBASE-304
print ====== TBASE-304
sleep 10000
sleep 10000
print create mt
# we cannot reset query cache in server side, as a workaround,
sql create table mt (ts timestamp, c1 int) tags(t1 int, t2 int)
# set super table name to mt304, need to change back to mt later
print create mt304
sql create table mt304 (ts timestamp, c1 int) tags(t1 int, t2 int)
print create tb1
print create tb1
sql create table tb1 using mt tags(1, 1)
sql create table tb1 using mt
304
tags(1, 1)
print create tb2
print create tb2
sql create table tb2 using mt tags(1, -1)
sql create table tb2 using mt
304
tags(1, -1)
print create strm
print create strm
sql create table strm as select count(*), avg(c1) from mt where t2 >= 0 interval(4s) sliding(2s)
sql create table strm as select count(*), avg(c1) from mt
304
where t2 >= 0 interval(4s) sliding(2s)
sql insert into tb1 values (now,1)
sql insert into tb1 values (now,1)
sql insert into tb2 values (now,2)
sql insert into tb2 values (now,2)
sleep
2
0000
sleep
10
0000
sql select * from strm;
sql select * from strm;
sleep 1000
if $rows != 2 then
if $rows != 2 then
print ==== expect rows = 2, actually returned rows = $rows
print ==== expect rows = 2, actually returned rows = $rows
return -1
return -1
...
@@ -75,11 +76,11 @@ print data02 = $data02
...
@@ -75,11 +76,11 @@ print data02 = $data02
if $data02 != 1.000000000 then
if $data02 != 1.000000000 then
return -1
return -1
endi
endi
sql alter table mt drop tag t2;
sql alter table mt
304
drop tag t2;
sql insert into tb2 values (now,2);
sql insert into tb2 values (now,2);
sql insert into tb1 values (now,1);
sql insert into tb1 values (now,1);
sql select * from strm;
sql select * from strm;
sql alter table mt add tag t2 int;
sql alter table mt
304
add tag t2 int;
sleep 10000
sleep 10000
sql select * from strm
sql select * from strm
...
@@ -98,7 +99,7 @@ sleep 4000
...
@@ -98,7 +99,7 @@ sleep 4000
sql insert into tb2 values (now, 2, 'tb2')
sql insert into tb2 values (now, 2, 'tb2')
sleep 4000
sleep 4000
sql insert into tb3 values (now, 0, 'tb3')
sql insert into tb3 values (now, 0, 'tb3')
sleep 6000
sleep 6000
0
sql describe strm
sql describe strm
if $rows == 0 then
if $rows == 0 then
...
@@ -134,11 +135,9 @@ endi
...
@@ -134,11 +135,9 @@ endi
## The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. But the current refreshing frequency is every 10 min
## The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. But the current refreshing frequency is every 10 min
## commented out the case below to save running time
## commented out the case below to save running time
sql create table tb4 using stb tags('a4')
sql create table tb4 using stb tags('a4')
sleep 6000
sql insert into tb4 values(now, 4, 'tb4')
sql insert into tb4 values(now, 4, 'tb4')
sleep
1
0000
sleep
6
0000
sql select * from strm order by ts desc
sql select * from strm order by ts desc
sleep 1000
print ======== data0: $data00 $data01 $data02 $data03
print ======== data0: $data00 $data01 $data02 $data03
#print ======== data1: $data10 $data11 $data12 $data13
#print ======== data1: $data10 $data11 $data12 $data13
#print ======== data2: $data20 $data21 $data22 $data23
#print ======== data2: $data20 $data21 $data22 $data23
...
@@ -160,7 +159,7 @@ sleep 3000 # waiting for new tag valid
...
@@ -160,7 +159,7 @@ sleep 3000 # waiting for new tag valid
sql insert into tb1 values (now, 1, 'tb1_a1')
sql insert into tb1 values (now, 1, 'tb1_a1')
sleep 4000
sleep 4000
sql insert into tb4 values (now, -4, 'tb4_b4')
sql insert into tb4 values (now, -4, 'tb4_b4')
sleep 10000
sleep 10000
0
sql select * from strm order by ts desc
sql select * from strm order by ts desc
sleep 1000
sleep 1000
print ======== data0: $data00 $data01 $data02 $data03
print ======== data0: $data00 $data01 $data02 $data03
...
@@ -191,9 +190,9 @@ sql create table tb3 using stb tags(3, 'tb3')
...
@@ -191,9 +190,9 @@ sql create table tb3 using stb tags(3, 'tb3')
sql create table tb4 using stb tags(4, 'tb4')
sql create table tb4 using stb tags(4, 'tb4')
sql create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb where ts < now + 30s interval(4s) sliding(2s)
sql create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb where ts < now + 30s interval(4s) sliding(2s)
sleep 1000
0
sleep 1000
sql insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true)
sql insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true)
sleep
5
000
sleep
20
000
sql select * from strm0 order by ts desc
sql select * from strm0 order by ts desc
sleep 1000
sleep 1000
if $rows != 2 then
if $rows != 2 then
...
@@ -202,7 +201,7 @@ if $rows != 2 then
...
@@ -202,7 +201,7 @@ if $rows != 2 then
endi
endi
sql insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true)
sql insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true)
sleep
5
000
sleep
30
000
sql select * from strm0 order by ts desc
sql select * from strm0 order by ts desc
sleep 1000
sleep 1000
if $rows != 4 then
if $rows != 4 then
...
@@ -210,15 +209,4 @@ if $rows != 4 then
...
@@ -210,15 +209,4 @@ if $rows != 4 then
return -1
return -1
endi
endi
sql drop database if exists strm_db_0
sql show databases
if $rows != 0 then
return -1
endi
sql create database $db
sql use $db
sql create table stb (ts timestamp, c1 int) tags(t1 int)
sql create table tb1 using stb tags(1)
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/script/jenkins/basic.txt
浏览文件 @
88519c19
...
@@ -323,19 +323,20 @@ cd ../../../debug; make
...
@@ -323,19 +323,20 @@ cd ../../../debug; make
./test.sh -f unique/vnode/replica3_repeat.sim
./test.sh -f unique/vnode/replica3_repeat.sim
./test.sh -f unique/vnode/replica3_vgroup.sim
./test.sh -f unique/vnode/replica3_vgroup.sim
./test.sh -f unique/arbitrator/
dn2_mn1_cache_file_sync
.sim
./test.sh -f unique/arbitrator/
check_cluster_cfg_para
.sim
#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync_second.sim
./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim # TODO: check file number using sim ?
./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim
./test.sh -f unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
./test.sh -f unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim # fail
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim
./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim # fail
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
#./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim # unsupport
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim
./test.sh -f unique/arbitrator/insert_duplicationTs.sim
./test.sh -f unique/arbitrator/insert_duplicationTs.sim
...
@@ -349,7 +350,7 @@ cd ../../../debug; make
...
@@ -349,7 +350,7 @@ cd ../../../debug; make
./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim
./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim
./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim
#./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim # fail
./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim
...
@@ -358,3 +359,4 @@ cd ../../../debug; make
...
@@ -358,3 +359,4 @@ cd ../../../debug; make
./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim
./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim
./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim
./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim
tests/script/tmp/prepare.sim
浏览文件 @
88519c19
...
@@ -20,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
...
@@ -20,10 +20,10 @@ system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v
4
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v
20
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v
4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v
20
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v
4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v
20
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v
4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v
20
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode1 -c http -v 1
system sh/cfg.sh -n dnode2 -c http -v 1
system sh/cfg.sh -n dnode2 -c http -v 1
...
...
tests/script/unique/arbitrator/check_cluster_cfg_para.sim
浏览文件 @
88519c19
...
@@ -7,84 +7,83 @@ system sh/deploy.sh -n dnode5 -i 5
...
@@ -7,84 +7,83 @@ system sh/deploy.sh -n dnode5 -i 5
system sh/deploy.sh -n dnode6 -i 6
system sh/deploy.sh -n dnode6 -i 6
system sh/deploy.sh -n dnode7 -i 7
system sh/deploy.sh -n dnode7 -i 7
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode1 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode1 -c statusInterval -v 3
system sh/cfg.sh -n dnode1 -c statusInterval -v 3
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode1 -c timezone -v ""
#system sh/cfg.sh -n dnode1 -c timezone -v ""
#system sh/cfg.sh -n dnode1 -c locale -v ""
#system sh/cfg.sh -n dnode1 -c locale -v ""
#system sh/cfg.sh -n dnode1 -c charset -v ""
#system sh/cfg.sh -n dnode1 -c charset -v ""
system sh/cfg.sh -n dnode1 -c balanceInterval -v
10
system sh/cfg.sh -n dnode1 -c balanceInterval -v
3
######## dnode 2 the same with dnode1
######## dnode 2 the same with dnode1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode2 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode2 -c statusInterval -v 3
system sh/cfg.sh -n dnode2 -c statusInterval -v 3
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode2 -c timezone -v ""
#system sh/cfg.sh -n dnode2 -c timezone -v ""
#system sh/cfg.sh -n dnode2 -c locale -v ""
#system sh/cfg.sh -n dnode2 -c locale -v ""
#system sh/cfg.sh -n dnode2 -c charset -v ""
#system sh/cfg.sh -n dnode2 -c charset -v ""
system sh/cfg.sh -n dnode2 -c balanceInterval -v
10
system sh/cfg.sh -n dnode2 -c balanceInterval -v
3
######## dnode 3 one para no same with dnode1
######## dnode 3 one para no same with dnode1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode3 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode3 -c statusInterval -v 3
system sh/cfg.sh -n dnode3 -c statusInterval -v 3
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode3 -c timezone -v ""
#system sh/cfg.sh -n dnode3 -c timezone -v ""
#system sh/cfg.sh -n dnode3 -c locale -v ""
#system sh/cfg.sh -n dnode3 -c locale -v ""
#system sh/cfg.sh -n dnode3 -c charset -v ""
#system sh/cfg.sh -n dnode3 -c charset -v ""
system sh/cfg.sh -n dnode3 -c balanceInterval -v
10
system sh/cfg.sh -n dnode3 -c balanceInterval -v
3
######## dnode 4 one para no same with dnode1
######## dnode 4 one para no same with dnode1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 5
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 5
system sh/cfg.sh -n dnode4 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode4 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode4 -c statusInterval -v 3
system sh/cfg.sh -n dnode4 -c statusInterval -v 3
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode4 -c timezone -v ""
#system sh/cfg.sh -n dnode4 -c timezone -v ""
#system sh/cfg.sh -n dnode4 -c locale -v ""
#system sh/cfg.sh -n dnode4 -c locale -v ""
#system sh/cfg.sh -n dnode4 -c charset -v ""
#system sh/cfg.sh -n dnode4 -c charset -v ""
system sh/cfg.sh -n dnode4 -c balanceInterval -v
10
system sh/cfg.sh -n dnode4 -c balanceInterval -v
3
######## dnode 5 one para no same with dnode1
######## dnode 5 one para no same with dnode1
system sh/cfg.sh -n dnode5 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode5 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode5 -c offlineThreshold -v
16
system sh/cfg.sh -n dnode5 -c offlineThreshold -v
7
system sh/cfg.sh -n dnode5 -c statusInterval -v 3
system sh/cfg.sh -n dnode5 -c statusInterval -v 3
system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode5 -c timezone -v ""
#system sh/cfg.sh -n dnode5 -c timezone -v ""
#system sh/cfg.sh -n dnode5 -c locale -v ""
#system sh/cfg.sh -n dnode5 -c locale -v ""
#system sh/cfg.sh -n dnode5 -c charset -v ""
#system sh/cfg.sh -n dnode5 -c charset -v ""
system sh/cfg.sh -n dnode5 -c balanceInterval -v
10
system sh/cfg.sh -n dnode5 -c balanceInterval -v
3
######## dnode 6 one para no same with dnode1
######## dnode 6 one para no same with dnode1
system sh/cfg.sh -n dnode6 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode6 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode6 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode6 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode6 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode6 -c statusInterval -v 2
system sh/cfg.sh -n dnode6 -c statusInterval -v 2
system sh/cfg.sh -n dnode6 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode6 -c arbitrator -v $arbitrator
#system sh/cfg.sh -n dnode6 -c timezone -v ""
#system sh/cfg.sh -n dnode6 -c timezone -v ""
#system sh/cfg.sh -n dnode6 -c locale -v ""
#system sh/cfg.sh -n dnode6 -c locale -v ""
#system sh/cfg.sh -n dnode6 -c charset -v ""
#system sh/cfg.sh -n dnode6 -c charset -v ""
system sh/cfg.sh -n dnode6 -c balanceInterval -v
10
system sh/cfg.sh -n dnode6 -c balanceInterval -v
3
######## dnode 7 one para no same with dnode1
######## dnode 7 one para no same with dnode1
system sh/cfg.sh -n dnode7 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode7 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode7 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode7 -c offlineThreshold -v
15
system sh/cfg.sh -n dnode7 -c offlineThreshold -v
8
system sh/cfg.sh -n dnode7 -c statusInterval -v 3
system sh/cfg.sh -n dnode7 -c statusInterval -v 3
system sh/cfg.sh -n dnode7 -c arbitrator -v "plum-VirtualBox:8001"
system sh/cfg.sh -n dnode7 -c arbitrator -v "plum-VirtualBox:8001"
#system sh/cfg.sh -n dnode7 -c timezone -v ""
#system sh/cfg.sh -n dnode7 -c timezone -v ""
#system sh/cfg.sh -n dnode7 -c locale -v ""
#system sh/cfg.sh -n dnode7 -c locale -v ""
#system sh/cfg.sh -n dnode7 -c charset -v ""
#system sh/cfg.sh -n dnode7 -c charset -v ""
system sh/cfg.sh -n dnode7 -c balanceInterval -v
10
system sh/cfg.sh -n dnode7 -c balanceInterval -v
3
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -109,7 +108,12 @@ sql create dnode $hostname6
...
@@ -109,7 +108,12 @@ sql create dnode $hostname6
sql create dnode $hostname7
sql create dnode $hostname7
sleep 10000
sleep 10000
$loopCnt = 0
wait_dnode_created:
wait_dnode_created:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 7 then
if $rows != 7 then
sleep 2000
sleep 2000
...
@@ -154,7 +158,12 @@ endi
...
@@ -154,7 +158,12 @@ endi
sleep 10000
sleep 10000
$loopCnt = 0
wait_dnode_offline_overtime_dropped:
wait_dnode_offline_overtime_dropped:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
...
...
tests/script/unique/arbitrator/dn2_mn1_cache_file_sync.sim
浏览文件 @
88519c19
...
@@ -117,7 +117,13 @@ print ============== step4: stop dnode3, so date rows falling disc, generate two
...
@@ -117,7 +117,13 @@ print ============== step4: stop dnode3, so date rows falling disc, generate two
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode3_offline:
wait_dnode3_offline:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -179,7 +185,13 @@ print ============== step7: restart dnode3, waiting sync end
...
@@ -179,7 +185,13 @@ print ============== step7: restart dnode3, waiting sync end
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
sleep 3000
sleep 3000
$loopCnt = 0
wait_dnode3_ready:
wait_dnode3_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_full_createTableFail.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
...
tests/script/unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -37,6 +38,7 @@ system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
...
@@ -37,6 +38,7 @@ system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
...
tests/script/unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
...
tests/script/unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim
浏览文件 @
88519c19
...
@@ -3,37 +3,31 @@ system sh/deploy.sh -n dnode1 -i 1
...
@@ -3,37 +3,31 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode5 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode5 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode5 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
...
@@ -44,19 +38,16 @@ system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
...
@@ -44,19 +38,16 @@ system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode5 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode5 -c enableCoreFile -v 1
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -126,7 +117,13 @@ system sh/exec.sh -n dnode4 -s stop
...
@@ -126,7 +117,13 @@ system sh/exec.sh -n dnode4 -s stop
#system sh/port.sh -p 7400 -s down
#system sh/port.sh -p 7400 -s down
sleep 12000
sleep 12000
$loopCnt = 0
wait_dnode4_dropped:
wait_dnode4_dropped:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim
浏览文件 @
88519c19
...
@@ -36,14 +36,16 @@ system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
...
@@ -36,14 +36,16 @@ system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 200
#system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 200
#system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 200
#system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode5 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
system sh/cfg.sh -n dnode4 -c alternativeRole -v 2
system sh/cfg.sh -n dnode4 -c alternativeRole -v 2
system sh/cfg.sh -n dnode5 -c alternativeRole -v 2
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
...
@@ -71,7 +73,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -71,7 +73,7 @@ system sh/exec.sh -n dnode1 -s start
sleep 3000
sleep 3000
sql connect
sql connect
print ============== step2: start dnode2/dnode3 and add into cluster, then create database, create table , and insert data
print ============== step2: start dnode2/dnode3 and add into cluster, then create database
replica 2
, create table , and insert data
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
sql create dnode $hostname2
sql create dnode $hostname2
...
@@ -84,7 +86,7 @@ $totalRows = 0
...
@@ -84,7 +86,7 @@ $totalRows = 0
$tsStart = 1420041600000
$tsStart = 1420041600000
$db = db
$db = db
sql create database $db replica 2
maxTables 4
sql create database $db replica 2
sql use $db
sql use $db
# create table , insert data
# create table , insert data
...
@@ -164,7 +166,13 @@ endi
...
@@ -164,7 +166,13 @@ endi
sleep 15000
sleep 15000
$loopCnt = 0
wait_drop:
wait_drop:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 3000
sleep 3000
...
@@ -193,14 +201,17 @@ if $dnode4Status != ready then
...
@@ -193,14 +201,17 @@ if $dnode4Status != ready then
endi
endi
print ============== step4-1: restart dnode3, adn add into cluster
print ============== step4-1: restart dnode3, adn add into cluster
system rm -rf ../../sim/dnode3
system rm -rf ../../
../
sim/dnode3
sleep
3
000
sleep
1
000
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode3 -i 3
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 200
system sh/cfg.sh -n dnode3 -c alternativeRole -v 2
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
...
@@ -209,7 +220,13 @@ system sh/exec.sh -n dnode3 -s start
...
@@ -209,7 +220,13 @@ system sh/exec.sh -n dnode3 -s start
sql create dnode $hostname3
sql create dnode $hostname3
sleep 3000
sleep 3000
$loopCnt = 0
wait_dnode3_ready:
wait_dnode3_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
print rows: $rows
print rows: $rows
if $rows != 4 then
if $rows != 4 then
...
@@ -228,19 +245,19 @@ $dnode4Status = $data4_4
...
@@ -228,19 +245,19 @@ $dnode4Status = $data4_4
$dnode5Status = $data4_5
$dnode5Status = $data4_5
if $dnode1Status != ready then
if $dnode1Status != ready then
return -1
goto wait_dnode3_ready
endi
endi
if $dnode2Status != ready then
if $dnode2Status != ready then
return -1
goto wait_dnode3_ready
endi
endi
if $dnode3Status != null then
if $dnode3Status != null then
return -1
goto wait_dnode3_ready
endi
endi
if $dnode4Status != ready then
if $dnode4Status != ready then
return -1
goto wait_dnode3_ready
endi
endi
if $dnode5Status != ready then
if $dnode5Status != ready then
return -1
goto wait_dnode3_ready
endi
endi
sql select count(*) from $stb
sql select count(*) from $stb
...
@@ -255,7 +272,13 @@ sleep 1000
...
@@ -255,7 +272,13 @@ sleep 1000
system sh/exec.sh -n dnode5 -s start
system sh/exec.sh -n dnode5 -s start
sql create dnode $hostname5
sql create dnode $hostname5
sleep 3000
sleep 3000
$loopCnt = 0
wait_dnode5:
wait_dnode5:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 5 then
if $rows != 5 then
sleep 3000
sleep 3000
...
@@ -274,22 +297,22 @@ $dnode5Status = $data4_5
...
@@ -274,22 +297,22 @@ $dnode5Status = $data4_5
$dnode6Status = $data4_6
$dnode6Status = $data4_6
if $dnode1Status != ready then
if $dnode1Status != ready then
return -1
goto wait_dnode5
endi
endi
if $dnode2Status != ready then
if $dnode2Status != ready then
return -1
goto wait_dnode5
endi
endi
if $dnode3Status != null then
if $dnode3Status != null then
return -1
goto wait_dnode5
endi
endi
if $dnode4Status != ready then
if $dnode4Status != ready then
return -1
goto wait_dnode5
endi
endi
if $dnode5Status != ready then
if $dnode5Status != ready then
return -1
goto wait_dnode5
endi
endi
if $dnode6Status != ready then
if $dnode6Status != ready then
return -1
goto wait_dnode5
endi
endi
print ============== step6: create database and table until not free vnodes
print ============== step6: create database and table until not free vnodes
...
...
tests/script/unique/arbitrator/dn3_mn1_replica_change.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -92,7 +93,14 @@ endi
...
@@ -92,7 +93,14 @@ endi
print ============== step2-1: stop dnode2 for falling disc, then restart dnode2, and check rows
print ============== step2-1: stop dnode2 for falling disc, then restart dnode2, and check rows
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_offline_0:
wait_dnode2_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
@@ -117,7 +125,14 @@ endi
...
@@ -117,7 +125,14 @@ endi
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_reready:
wait_dnode2_reready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
@@ -155,8 +170,13 @@ sleep 3000
...
@@ -155,8 +170,13 @@ sleep 3000
sql alter database $db replica 2
sql alter database $db replica 2
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode3_ready:
wait_dnode3_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -195,8 +215,13 @@ endi
...
@@ -195,8 +215,13 @@ endi
print ============== step4: stop dnode2 for checking if sync ok
print ============== step4: stop dnode2 for checking if sync ok
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode2 -s stop
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_offline:
wait_dnode2_offline:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -235,7 +260,13 @@ print ============== step5: restart dnode2
...
@@ -235,7 +260,13 @@ print ============== step5: restart dnode2
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
sleep 3000
sleep 3000
$loopCnt = 0
wait_dnode2_ready:
wait_dnode2_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -273,8 +304,13 @@ sleep 3000
...
@@ -273,8 +304,13 @@ sleep 3000
sql alter database $db replica 3
sql alter database $db replica 3
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -308,8 +344,13 @@ endi
...
@@ -308,8 +344,13 @@ endi
print ============== step7: alter replica from 3 to 2, and waiting sync
print ============== step7: alter replica from 3 to 2, and waiting sync
sql alter database $db replica 2
sql alter database $db replica 2
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_vgroups_replic_to_2:
wait_vgroups_replic_to_2:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2
...
@@ -350,8 +391,13 @@ endi
...
@@ -350,8 +391,13 @@ endi
print ============== step8: alter replica from 2 to 1, and waiting sync
print ============== step8: alter replica from 2 to 1, and waiting sync
sql alter database $db replica 1
sql alter database $db replica 1
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_vgroups_replic_to_1:
wait_vgroups_replic_to_1:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2 $data5_2 $data6_2 $data7_2 $data8_2
...
@@ -381,7 +427,13 @@ if $sencodDnode_5 != null then
...
@@ -381,7 +427,13 @@ if $sencodDnode_5 != null then
goto wait_vgroups_replic_to_1
goto wait_vgroups_replic_to_1
endi
endi
$loopCnt = 0
all_dnodes_ready:
all_dnodes_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -429,7 +481,13 @@ sql drop dnode $hostname2
...
@@ -429,7 +481,13 @@ sql drop dnode $hostname2
sql drop dnode $hostname3
sql drop dnode $hostname3
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode23_dropped:
wait_dnode23_dropped:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -97,8 +98,13 @@ print ============== step3: drop dnode4, then check rows
...
@@ -97,8 +98,13 @@ print ============== step3: drop dnode4, then check rows
#system sh/exec.sh -n dnode4 -s stop -x SIGINT
#system sh/exec.sh -n dnode4 -s stop -x SIGINT
sql drop dnode $hostname4
sql drop dnode $hostname4
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode4_dropped:
wait_dnode4_dropped:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
浏览文件 @
88519c19
...
@@ -3,37 +3,31 @@ system sh/deploy.sh -n dnode1 -i 1
...
@@ -3,37 +3,31 @@ system sh/deploy.sh -n dnode1 -i 1
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode2 -i 2
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode3 -i 3
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode5 -i 5
system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode5 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode2 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode3 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode5 -c walLevel -v 1
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode2 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode3 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode5 -c balanceInterval -v 10
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode1 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode2 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode5 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode1 -c alternativeRole -v 1
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
system sh/cfg.sh -n dnode2 -c alternativeRole -v 2
...
@@ -44,19 +38,16 @@ system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
...
@@ -44,19 +38,16 @@ system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode5 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode5 -c offlineThreshold -v 10
system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode1 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode2 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode3 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode4 -c enableCoreFile -v 1
system sh/cfg.sh -n dnode5 -c enableCoreFile -v 1
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -124,7 +115,13 @@ print ============== step3: stop dnode4, after timerout dnode4 will be auto-drop
...
@@ -124,7 +115,13 @@ print ============== step3: stop dnode4, after timerout dnode4 will be auto-drop
system sh/exec.sh -n dnode4 -s stop
system sh/exec.sh -n dnode4 -s stop
sleep 12000
sleep 12000
$loopCnt = 0
wait_dnode4_dropped:
wait_dnode4_dropped:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -178,7 +175,7 @@ system sh/exec.sh -n dnode4 -s stop
...
@@ -178,7 +175,7 @@ system sh/exec.sh -n dnode4 -s stop
system rm -rf ../../../sim/dnode4
system rm -rf ../../../sim/dnode4
system sh/deploy.sh -n dnode4 -i 4
system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode4 -c numOfM
Peer
s -v 1
system sh/cfg.sh -n dnode4 -c numOfM
node
s -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c walLevel -v 1
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c balanceInterval -v 10
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 4
...
@@ -192,7 +189,13 @@ system sh/exec.sh -n dnode4 -s start
...
@@ -192,7 +189,13 @@ system sh/exec.sh -n dnode4 -s start
sql create dnode $hostname4
sql create dnode $hostname4
sleep 6000
sleep 6000
$loopCnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_change.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -46,7 +47,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -46,7 +47,7 @@ system sh/exec.sh -n dnode1 -s start
sleep 3000
sleep 3000
sql connect
sql connect
print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica
3
, and create table, insert data
print ============== step2: start dnode2/dnode3/dnode4 and add into cluster , then create database with replica
2
, and create table, insert data
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
...
@@ -59,7 +60,7 @@ $totalTableNum = 10
...
@@ -59,7 +60,7 @@ $totalTableNum = 10
$sleepTimer = 3000
$sleepTimer = 3000
$db = db
$db = db
sql create database $db replica
3
maxTables $totalTableNum
sql create database $db replica
2
maxTables $totalTableNum
sql use $db
sql use $db
# create table , insert data
# create table , insert data
...
@@ -87,13 +88,18 @@ while $i < $tblNum
...
@@ -87,13 +88,18 @@ while $i < $tblNum
endw
endw
sql select count(*) from $stb
sql select count(*) from $stb
sleep 1000
print data00 $data00
print data00 $data00
if $data00 != $totalRows then
if $data00 != $totalRows then
return -1
return -1
endi
endi
print ============== step3: stop dnode4, and remove its vnodeX subdirector
sql show dnodes
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
print ============== step3: stop dnode4, then destroy the contents of its data file
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
$loopCnt = 0
...
@@ -110,14 +116,11 @@ endi
...
@@ -110,14 +116,11 @@ endi
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
$dnode1Status = $data4_1
#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
#$dnode1Status = $data4_1
$dnode2Status = $data4_2
$dnode2Status = $data4_2
$dnode3Status = $data4_3
$dnode3Status = $data4_3
$dnode4Status = $data4_4
$dnode4Status = $data4_4
#$dnode5Status = $data4_5
if $dnode4Status != offline then
if $dnode4Status != offline then
sleep 2000
sleep 2000
...
@@ -146,10 +149,20 @@ if $dnode3Vtatus != master then
...
@@ -146,10 +149,20 @@ if $dnode3Vtatus != master then
goto wait_dnode4_vgroup_offline
goto wait_dnode4_vgroup_offline
endi
endi
system echo "haha, nothing......" > ../../../sim/dnode4/data/vnode/vnode2/tsdb/data/f1643.data
system rm -rf ../../../sim/dnode4/data/vnode/*
#
system rm -rf ../../../sim/dnode4/data/vnode/*
sleep 1000
sleep 1000
print ============== step3-1: insert new data
sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x )
$totalRows = $totalRows + 3
sql select count(*) from $stb
print data00 $data00
if $data00 != $totalRows then
return -1
endi
print ============== step4: restart dnode4, waiting sync end
print ============== step4: restart dnode4, waiting sync end
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
sleep $sleepTimer
sleep $sleepTimer
...
@@ -213,12 +226,17 @@ if $dnode3Vtatus != master then
...
@@ -213,12 +226,17 @@ if $dnode3Vtatus != master then
goto wait_dnode4_vgroup_slave
goto wait_dnode4_vgroup_slave
endi
endi
sql select count(*) from $stb
print data00 $data00
if $data00 != $totalRows then
return -1
endi
print ============== step5: stop dnode3/dnode2, and check rows
print ============== step5: stop dnode3/dnode2, and check rows
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode2 -s stop
-x SIGINT
system sh/exec.sh -n dnode3 -s stop
system sh/exec.sh -n dnode3 -s stop
-x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
$loopCnt = 0
wait_dnode23_offline:
wait_dnode23_offline:
$loopCnt = $loopCnt + 1
$loopCnt = $loopCnt + 1
...
@@ -234,13 +252,10 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
...
@@ -234,13 +252,10 @@ print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
$dnode1Status = $data4_1
#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
#$dnode1Status = $data4_1
$dnode2Status = $data4_2
$dnode2Status = $data4_2
$dnode3Status = $data4_3
$dnode3Status = $data4_3
$dnode4Status = $data4_4
$dnode4Status = $data4_4
#$dnode5Status = $data4_5
if $dnode2Status != offline then
if $dnode2Status != offline then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -96,7 +97,14 @@ endi
...
@@ -96,7 +97,14 @@ endi
print ============== step3: stop dnode3 for falling disc, then corrupt vnode data file in dnode3
print ============== step3: stop dnode3 for falling disc, then corrupt vnode data file in dnode3
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode3_offline_0:
wait_dnode3_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -119,7 +127,13 @@ if $dnode3Status != offline then
...
@@ -119,7 +127,13 @@ if $dnode3Status != offline then
goto wait_dnode3_offline_0
goto wait_dnode3_offline_0
endi
endi
$loopCnt = 0
wait_dnode3_vgroup_offline:
wait_dnode3_vgroup_offline:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -141,27 +155,47 @@ if $dnode2Vtatus != master then
...
@@ -141,27 +155,47 @@ if $dnode2Vtatus != master then
goto wait_dnode3_vgroup_offline
goto wait_dnode3_vgroup_offline
endi
endi
#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | sed 's/^[ \t]*//g'
#$expectCnt = 3 . :
#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | sed 's/[ \t]*$//g'
#print expectCnt: [ $expectCnt ]
#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':'
#system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr '\n' ':'
#print --2-->dnode3 data files: [ $system_content ]
#print --2-->dnode3 data files: [ $system_content ]
system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l
print ---->dnode2 data files: [ $system_content ], expect is 0
system_content ls ../../../sim/dnode
3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l
system_content ls ../../../sim/dnode
2/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n'
print ---->dnode
3 data files: [ $system_content ], expect is 3
print ---->dnode
2 data files: $system_content expect: 0
#if $system_content != 3 then
if $system_content != 0 then
#
return -1
return -1
#
endi
endi
#system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data
system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l | grep "^-" | wc -l | tr -d '\n'
#sleep 1000
print ---->dnode3 data files: $system_content expect: 3
if $system_content != 3 then
return -1
endi
system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data
print ============== step3-1: insert some news data for let version changed
sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x )
sql insert into $tb values ( now + 10a , $x ) ( now + 11a , $x ) ( now + 12a , $x )
$totalRows = $totalRows + 6
sql select count(*) from $stb
print data00 $data00
if $data00 != $totalRows then
return -1
endi
print ============== step4: restart dnode3, and run query
print ============== step4: restart dnode3, and run query
system sh/exec.sh -n dnode3 -s start
system sh/exec.sh -n dnode3 -s start
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode3_reready:
wait_dnode3_reready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -183,8 +217,13 @@ if $dnode3Status != ready then
...
@@ -183,8 +217,13 @@ if $dnode3Status != ready then
sleep 2000
sleep 2000
goto wait_dnode3_reready
goto wait_dnode3_reready
endi
endi
$loopCnt = 0
wait_dnode3_vgroup_slave:
wait_dnode3_vgroup_slave:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -212,25 +251,29 @@ if $data00 != $totalRows then
...
@@ -212,25 +251,29 @@ if $data00 != $totalRows then
return -1
return -1
endi
endi
system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l
system_content ls ../../../sim/dnode2/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n'
print ----> dnode2 data files: [ $system_content ], expect is 0
print ----> dnode2 data files: $system_content expect: 0
#if $system_content != 0 then
if $system_content != 0 then
# return -1
return -1
#endi
endi
system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l
print ----> dnode3 data files: [ $system_content ], expect is 0
#if $system_content != 0 then
# print there should be no data file in dnode3 after sync
# return -1
#endi
return -1
system_content ls ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/ -l |grep "^-"|wc -l | tr -d '\n'
print ----> dnode3 data files: $system_content expect: 0
if $system_content != 0 then
print there should be no data file in dnode3 after sync
return -1
endi
print ============== step5: stop dnode2, and check if dnode3 sync ok
print ============== step5: stop dnode2, and check if dnode3 sync ok
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_offline_0:
wait_dnode2_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -253,7 +296,13 @@ if $dnode2Status != offline then
...
@@ -253,7 +296,13 @@ if $dnode2Status != offline then
goto wait_dnode2_offline_0
goto wait_dnode2_offline_0
endi
endi
$loopCnt = 0
wait_dnode3_vgroup_master:
wait_dnode3_vgroup_master:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -94,11 +95,13 @@ if $data00 != $totalRows then
...
@@ -94,11 +95,13 @@ if $data00 != $totalRows then
endi
endi
print ============== step3: corrupt vnode data file in dnode3, not stop dnode3
print ============== step3: corrupt vnode data file in dnode3, not stop dnode3
# del the second row
system echo "haha, nothing......" > ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/f1643.data
system sed '2d' ../../../sim/dnode3/data/vnode/vnode2/tsdb/data/v1849.data
sleep 1000
sleep 1000
print ============== step4: run query
print ============== step4: insert new data, and run query
sql insert into $tb values ( now + 0a , $x ) ( now + 1a , $x ) ( now + 2a , $x )
$totalRows = $totalRows + 3
sql select count(*) from $stb
sql select count(*) from $stb
print data00 $data00
print data00 $data00
if $data00 != $totalRows then
if $data00 != $totalRows then
...
@@ -108,7 +111,14 @@ endi
...
@@ -108,7 +111,14 @@ endi
print ============== step5: stop dnode2, and check if dnode3 sync ok
print ============== step5: stop dnode2, and check if dnode3 sync ok
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_offline_0:
wait_dnode2_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -131,7 +141,13 @@ if $dnode2Status != offline then
...
@@ -131,7 +141,13 @@ if $dnode2Status != offline then
goto wait_dnode2_offline_0
goto wait_dnode2_offline_0
endi
endi
$loopCnt = 0
wait_dnode3_vgroup_master:
wait_dnode3_vgroup_master:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/dn3_mn1_vnode_nomaster.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -96,7 +97,13 @@ print ============== step3: stop dnode4/dnode2
...
@@ -96,7 +97,13 @@ print ============== step3: stop dnode4/dnode2
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -123,7 +130,13 @@ if $dnode2Status != offline then
...
@@ -123,7 +130,13 @@ if $dnode2Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$loopCnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -192,7 +205,12 @@ endi
...
@@ -192,7 +205,12 @@ endi
print ============== step5: stop dnode3
print ============== step5: stop dnode3
system sh/exec.sh -n dnode3 -s stop -x SIGINT
system sh/exec.sh -n dnode3 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode3_offline_0:
wait_dnode3_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -221,7 +239,12 @@ if $dnode2Status != ready then
...
@@ -221,7 +239,12 @@ if $dnode2Status != ready then
goto wait_dnode3_offline_0
goto wait_dnode3_offline_0
endi
endi
$loopCnt = 0
wait_dnode2_vgroup_master:
wait_dnode2_vgroup_master:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -243,8 +266,8 @@ if $dnode2Vtatus != master then
...
@@ -243,8 +266,8 @@ if $dnode2Vtatus != master then
goto wait_dnode2_vgroup_master
goto wait_dnode2_vgroup_master
endi
endi
sql insert into
tb98 values (now, 9000) (now + 1s, 9001) (now + 2s, 9002) tb99
values (now, 9000) (now + 1s, 9001) (now + 2s, 9002)
sql insert into
$tb
values (now, 9000) (now + 1s, 9001) (now + 2s, 9002)
$totalRows = $totalRows +
6
$totalRows = $totalRows +
3
sql select count(*) from $stb
sql select count(*) from $stb
print data00 $data00
print data00 $data00
if $data00 != $totalRows then
if $data00 != $totalRows then
...
...
tests/script/unique/arbitrator/dn3_mn2_killDnode.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -32,11 +33,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
...
tests/script/unique/arbitrator/insert_duplicationTs.sim
浏览文件 @
88519c19
...
@@ -43,11 +43,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -43,11 +43,11 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -117,7 +117,13 @@ print ============== step4: stop dnode2, so date rows falling disc, generate two
...
@@ -117,7 +117,13 @@ print ============== step4: stop dnode2, so date rows falling disc, generate two
system sh/exec.sh -n dnode2 -s stop -x SIGINT
system sh/exec.sh -n dnode2 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode2_offline:
wait_dnode2_offline:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -160,8 +166,13 @@ $totalRows = $totalRows + 2
...
@@ -160,8 +166,13 @@ $totalRows = $totalRows + 2
print ============== step5: restart dnode2, waiting sync end
print ============== step5: restart dnode2, waiting sync end
system sh/exec.sh -n dnode2 -s start
system sh/exec.sh -n dnode2 -s start
sleep 3000
sleep 3000
$loopCnt = 0
wait_dnode2_ready:
wait_dnode2_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica2_alterTable_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,13 @@ endi
...
@@ -99,7 +99,13 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$loopCnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -160,7 +166,12 @@ $totalRows = $totalRows + $addRows
...
@@ -160,7 +166,12 @@ $totalRows = $totalRows + $addRows
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$loopCnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$loopCnt = $loopCnt + 1
if $loopCnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica2_alterTag_online.sim
浏览文件 @
88519c19
...
@@ -100,7 +100,12 @@ endi
...
@@ -100,7 +100,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -187,7 +197,12 @@ endi
...
@@ -187,7 +197,12 @@ endi
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica2_createTable_online.sim
浏览文件 @
88519c19
...
@@ -101,7 +101,12 @@ endi
...
@@ -101,7 +101,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -124,7 +129,12 @@ if $dnode4Status != offline then
...
@@ -124,7 +129,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -174,7 +184,12 @@ endi
...
@@ -174,7 +184,12 @@ endi
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica2_dropDb_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica2_dropTable_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -158,7 +168,12 @@ $tblNum = $tblNum - 5
...
@@ -158,7 +168,12 @@ $tblNum = $tblNum - 5
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica3_alterTable_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -160,7 +170,12 @@ $totalRows = $totalRows + $addRows
...
@@ -160,7 +170,12 @@ $totalRows = $totalRows + $addRows
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica3_alterTag_online.sim
浏览文件 @
88519c19
...
@@ -100,7 +100,12 @@ endi
...
@@ -100,7 +100,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -187,7 +197,12 @@ endi
...
@@ -187,7 +197,12 @@ endi
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica3_createTable_online.sim
浏览文件 @
88519c19
...
@@ -100,7 +100,12 @@ endi
...
@@ -100,7 +100,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
...
@@ -123,7 +128,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -173,7 +183,12 @@ endi
...
@@ -173,7 +183,12 @@ endi
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica3_dropDb_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/offline_replica3_dropTable_online.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -158,7 +168,12 @@ $tblNum = $tblNum - 5
...
@@ -158,7 +168,12 @@ $tblNum = $tblNum - 5
print ============== step5: restart dnode4, waiting dnode4 synced
print ============== step5: restart dnode4, waiting dnode4 synced
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
$cnt = 0
wait_dnode4_ready:
wait_dnode4_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/replica_changeWithArbitrator.sim
浏览文件 @
88519c19
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
...
@@ -7,6 +7,7 @@ system sh/deploy.sh -n dnode4 -i 4
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode1 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
system sh/cfg.sh -n dnode2 -c walLevel -v 2
...
@@ -24,9 +25,9 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8
...
@@ -24,9 +25,9 @@ system sh/cfg.sh -n dnode3 -c numOfTotalVnodes -v 8
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 8
system sh/cfg.sh -n dnode4 -c numOfTotalVnodes -v 8
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c mnodeEqualVnodeNum -v 4
#
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode2 -c mnodeEqualVnodeNum -v 4
#
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode3 -c mnodeEqualVnodeNum -v 4
#
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode4 -c mnodeEqualVnodeNum -v 4
system sh/cfg.sh -n dnode1 -c alternativeRole -v 0
system sh/cfg.sh -n dnode1 -c alternativeRole -v 0
system sh/cfg.sh -n dnode2 -c alternativeRole -v 0
system sh/cfg.sh -n dnode2 -c alternativeRole -v 0
...
@@ -37,11 +38,21 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
...
@@ -37,11 +38,21 @@ system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode2 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode3 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode4 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode5 -c maxtablesPerVnode -v 4
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator
system sh/cfg.sh -n dnode1 -c offlineThreshold -v 8
system sh/cfg.sh -n dnode2 -c offlineThreshold -v 8
system sh/cfg.sh -n dnode3 -c offlineThreshold -v 8
system sh/cfg.sh -n dnode4 -c offlineThreshold -v 8
system sh/cfg.sh -n dnode1 -c statusInterval -v 3
system sh/cfg.sh -n dnode2 -c statusInterval -v 3
system sh/cfg.sh -n dnode3 -c statusInterval -v 3
system sh/cfg.sh -n dnode4 -c statusInterval -v 3
print ============== step0: start tarbitrator
print ============== step0: start tarbitrator
system sh/exec_tarbitrator.sh -s start
system sh/exec_tarbitrator.sh -s start
...
@@ -96,7 +107,12 @@ sql create dnode $hostname2
...
@@ -96,7 +107,12 @@ sql create dnode $hostname2
sleep 3000
sleep 3000
# expect after balanced, 2 vondes in dnode1, 1 vonde in dnode2
# expect after balanced, 2 vondes in dnode1, 1 vonde in dnode2
$cnt = 0
wait_dnode2_ready:
wait_dnode2_ready:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
@@ -105,14 +121,8 @@ endi
...
@@ -105,14 +121,8 @@ endi
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_2 $data1_2 $data2_2 $data3_2 $data4_2
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
print $data0_3 $data1_3 $data2_3 $data3_3 $data4_3
#print $data0_4 $data1_4 $data2_4 $data3_4 $data4_4
#print $data0_5 $data1_5 $data2_5 $data3_5 $data4_5
#print $data0_6 $data1_6 $data2_6 $data3_6 $data4_6
$dnode1Status = $data4_1
$dnode1Status = $data4_1
$dnode2Status = $data4_2
$dnode2Status = $data4_2
#$dnode3Status = $data4_3
#$dnode4Status = $data4_4
#$dnode5Status = $data4_5
if $dnode1Status != ready then
if $dnode1Status != ready then
sleep 2000
sleep 2000
...
@@ -123,7 +133,7 @@ if $dnode2Status != ready then
...
@@ -123,7 +133,7 @@ if $dnode2Status != ready then
goto wait_dnode2_ready
goto wait_dnode2_ready
endi
endi
print ============== step3: stop dnode1/dnode2, modify cfg
mpeer
s to 2, and restart dnode1/dnode2
print ============== step3: stop dnode1/dnode2, modify cfg
numOfMnode
s to 2, and restart dnode1/dnode2
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode2 -s stop
system sh/exec.sh -n dnode2 -s stop
sleep 3000
sleep 3000
...
@@ -143,7 +153,12 @@ sleep 5000
...
@@ -143,7 +153,12 @@ sleep 5000
print ============= step4: wait dnode ready
print ============= step4: wait dnode ready
$cnt = 0
wait_dnode_ready:
wait_dnode_ready:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
@@ -180,7 +195,12 @@ print ============== step5: stop dnode1
...
@@ -180,7 +195,12 @@ print ============== step5: stop dnode1
system sh/exec.sh -n dnode1 -s stop
system sh/exec.sh -n dnode1 -s stop
sleep 3000
sleep 3000
$cnt = 0
wait_dnode2_master:
wait_dnode2_master:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show mnodes
sql show mnodes
if $rows != 2 then
if $rows != 2 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica2_alterTable_add.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica2_alterTable_drop.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -172,7 +182,7 @@ system sh/exec.sh -n dnode4 -s start
...
@@ -172,7 +182,7 @@ system sh/exec.sh -n dnode4 -s start
run_back unique/arbitrator/sync_replica_alterTable_background_drop.sim
run_back unique/arbitrator/sync_replica_alterTable_background_drop.sim
print ============== step6: check result
print ============== step6: check result
#in background.sim, drop one column and add one new column, then insert
200
rows
#in background.sim, drop one column and add one new column, then insert
36
rows
$totalRows = $totalRows + 36
$totalRows = $totalRows + 36
$cnt = 0
$cnt = 0
...
...
tests/script/unique/arbitrator/sync_replica2_dropDb.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica2_dropTable.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 3 then
if $rows != 3 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica3_alterTable_add.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -162,7 +172,7 @@ while $i < $tblNum
...
@@ -162,7 +172,7 @@ while $i < $tblNum
endw
endw
sql select count(*) from $stb
sql select count(*) from $stb
print data00
$data00
print data00
:$data00 totalRows:$totalRows
if $data00 != $totalRows then
if $data00 != $totalRows then
return -1
return -1
endi
endi
...
@@ -172,7 +182,7 @@ system sh/exec.sh -n dnode4 -s start
...
@@ -172,7 +182,7 @@ system sh/exec.sh -n dnode4 -s start
run_back unique/arbitrator/sync_replica_alterTable_background_add.sim
run_back unique/arbitrator/sync_replica_alterTable_background_add.sim
print ============== step6: check result
print ============== step6: check result
#in background.sim, add one column and insert
200
rows
#in background.sim, add one column and insert
36
rows
$totalRows = $totalRows + 36
$totalRows = $totalRows + 36
$cnt = 0
$cnt = 0
...
@@ -183,7 +193,7 @@ if $cnt == 20 then
...
@@ -183,7 +193,7 @@ if $cnt == 20 then
endi
endi
sql select count(*) from $stb
sql select count(*) from $stb
if $data00 != $totalRows then
if $data00 != $totalRows then
print data00:
$data00 totalRows: $totalRows
print data00:
$data00 totalRows:$totalRows
sleep 2000
sleep 2000
goto wait_table_altered
goto wait_table_altered
endi
endi
...
...
tests/script/unique/arbitrator/sync_replica3_alterTable_drop.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 20 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica3_dropDb.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
...
tests/script/unique/arbitrator/sync_replica3_dropTable.sim
浏览文件 @
88519c19
...
@@ -99,7 +99,12 @@ endi
...
@@ -99,7 +99,12 @@ endi
print ============== step3: stop dnode4
print ============== step3: stop dnode4
system sh/exec.sh -n dnode4 -s stop -x SIGINT
system sh/exec.sh -n dnode4 -s stop -x SIGINT
sleep $sleepTimer
sleep $sleepTimer
$cnt = 0
wait_dnode4_offline_0:
wait_dnode4_offline_0:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show dnodes
sql show dnodes
if $rows != 4 then
if $rows != 4 then
sleep 2000
sleep 2000
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
...
@@ -122,7 +127,12 @@ if $dnode4Status != offline then
goto wait_dnode4_offline_0
goto wait_dnode4_offline_0
endi
endi
$cnt = 0
wait_dnode4_vgroup_offline:
wait_dnode4_vgroup_offline:
$cnt = $cnt + 1
if $cnt == 10 then
return -1
endi
sql show vgroups
sql show vgroups
if $rows != 1 then
if $rows != 1 then
sleep 2000
sleep 2000
...
@@ -143,7 +153,7 @@ if $dnode3Vtatus != master then
...
@@ -143,7 +153,7 @@ if $dnode3Vtatus != master then
sleep 2000
sleep 2000
goto wait_dnode4_vgroup_offline
goto wait_dnode4_vgroup_offline
endi
endi
sleep 2000
print ============== step4: insert more data rows
print ============== step4: insert more data rows
$tsStart = $tsEnd + 1000
$tsStart = $tsEnd + 1000
$i = 0
$i = 0
...
@@ -162,17 +172,17 @@ while $i < $tblNum
...
@@ -162,17 +172,17 @@ while $i < $tblNum
endw
endw
sql select count(*) from $stb
sql select count(*) from $stb
print data00
$data00
print data00
:$data00 totalRows:$totalRows
if $data00 != $totalRows then
if $data00 != $totalRows then
return -1
return -1
endi
endi
print ============== step5: restart dnode4, while drop
database in other th
ead when dnode4 is syncing
print ============== step5: restart dnode4, while drop
some tables in other thr
ead when dnode4 is syncing
system sh/exec.sh -n dnode4 -s start
system sh/exec.sh -n dnode4 -s start
run_back unique/arbitrator/sync_replica_dropTable_background.sim
run_back unique/arbitrator/sync_replica_dropTable_background.sim
print ============== step6: check result
print ============== step6: check result
#in background.sim, drop
10
tables
#in background.sim, drop
5
tables
$totalRows = $totalRows - 5400
$totalRows = $totalRows - 5400
$cnt = 0
$cnt = 0
...
@@ -183,7 +193,7 @@ if $cnt == 20 then
...
@@ -183,7 +193,7 @@ if $cnt == 20 then
endi
endi
sql select count(*) from $stb
sql select count(*) from $stb
if $data00 != $totalRows then
if $data00 != $totalRows then
print data00:
$data00
print data00:
$data00 totalRows:$totalRows
sleep 2000
sleep 2000
goto wait_table_dropped
goto wait_table_dropped
endi
endi
...
@@ -191,7 +201,7 @@ endi
...
@@ -191,7 +201,7 @@ endi
$tblNum = $tblNum - 5
$tblNum = $tblNum - 5
sql select count(tbname) from $stb
sql select count(tbname) from $stb
if $data00 != $tblNum then
if $data00 != $tblNum then
print data00: $data00
print data00: $data00
tblNum: $tblNum
sleep 2000
sleep 2000
goto wait_table_dropped
goto wait_table_dropped
endi
endi
...
...
tests/script/unique/arbitrator/testSuite.sim
浏览文件 @
88519c19
run unique/arbitrator/check_cluster_cfg_para.sim
run unique/arbitrator/dn2_mn1_cache_file_sync.sim
run unique/arbitrator/dn2_mn1_cache_file_sync.sim
run unique/arbitrator/dn2_mn1_cache_file_sync_second.sim
run unique/arbitrator/dn3_mn1_full_createTableFail.sim
run unique/arbitrator/dn3_mn1_full_createTableFail.sim
run unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
run unique/arbitrator/dn3_mn1_full_dropDnodeFail.sim
run unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
run unique/arbitrator/dn3_mn1_multiCreateDropTable.sim
...
@@ -11,7 +11,7 @@ run unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
...
@@ -11,7 +11,7 @@ run unique/arbitrator/dn3_mn1_stopDnode_timeout.sim
run unique/arbitrator/dn3_mn1_vnode_change.sim
run unique/arbitrator/dn3_mn1_vnode_change.sim
run unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
run unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim
run unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
run unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim
####
run unique/arbitrator/dn3_mn1_vnode_delDir.sim
run unique/arbitrator/dn3_mn1_vnode_delDir.sim
run unique/arbitrator/dn3_mn1_vnode_nomaster.sim
run unique/arbitrator/dn3_mn1_vnode_nomaster.sim
run unique/arbitrator/dn3_mn2_killDnode.sim
run unique/arbitrator/dn3_mn2_killDnode.sim
run unique/arbitrator/insert_duplicationTs.sim
run unique/arbitrator/insert_duplicationTs.sim
...
@@ -33,4 +33,4 @@ run unique/arbitrator/sync_replica2_dropTable.sim
...
@@ -33,4 +33,4 @@ run unique/arbitrator/sync_replica2_dropTable.sim
run unique/arbitrator/sync_replica3_alterTable_add.sim
run unique/arbitrator/sync_replica3_alterTable_add.sim
run unique/arbitrator/sync_replica3_alterTable_drop.sim
run unique/arbitrator/sync_replica3_alterTable_drop.sim
run unique/arbitrator/sync_replica3_dropDb.sim
run unique/arbitrator/sync_replica3_dropDb.sim
run unique/arbitrator/sync_replica3_dropTable.sim
run unique/arbitrator/sync_replica3_dropTable.sim
\ No newline at end of file
tests/script/unique/dnode/balance3.sim
浏览文件 @
88519c19
...
@@ -177,7 +177,6 @@ endi
...
@@ -177,7 +177,6 @@ endi
print ========== step5
print ========== step5
sql create dnode $hostname6
sql create dnode $hostname6
system sh/deploy.sh -n dnode6 -i 6
system sh/exec.sh -n dnode6 -s start
system sh/exec.sh -n dnode6 -s start
$x = 0
$x = 0
...
...
tests/test/c/insertPerRow.c
浏览文件 @
88519c19
...
@@ -33,6 +33,7 @@ typedef struct {
...
@@ -33,6 +33,7 @@ typedef struct {
int
threadIndex
;
int
threadIndex
;
char
dbName
[
32
];
char
dbName
[
32
];
char
stableName
[
64
];
char
stableName
[
64
];
float
createTableSpeed
;
pthread_t
thread
;
pthread_t
thread
;
}
SInfo
;
}
SInfo
;
...
@@ -49,8 +50,8 @@ int64_t numOfThreads = 1;
...
@@ -49,8 +50,8 @@ int64_t numOfThreads = 1;
int64_t
numOfTablesPerThread
=
200
;
int64_t
numOfTablesPerThread
=
200
;
char
dbName
[
32
]
=
"db"
;
char
dbName
[
32
]
=
"db"
;
char
stableName
[
64
]
=
"st"
;
char
stableName
[
64
]
=
"st"
;
int32_t
cache
=
16
384
;
int32_t
cache
=
16
;
int32_t
tables
=
1
000
;
int32_t
tables
=
5
000
;
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
shellParseArgument
(
argc
,
argv
);
shellParseArgument
(
argc
,
argv
);
...
@@ -63,9 +64,8 @@ int main(int argc, char *argv[]) {
...
@@ -63,9 +64,8 @@ int main(int argc, char *argv[]) {
void
createDbAndTable
()
{
void
createDbAndTable
()
{
pPrint
(
"start to create table"
);
pPrint
(
"start to create table"
);
TAOS_RES
*
pSql
;
TAOS
*
con
;
TAOS
*
con
;
struct
timeval
systemTime
;
int64_t
st
,
et
;
char
qstr
[
64000
];
char
qstr
[
64000
];
char
fqdn
[
TSDB_FQDN_LEN
];
char
fqdn
[
TSDB_FQDN_LEN
];
...
@@ -77,22 +77,24 @@ void createDbAndTable() {
...
@@ -77,22 +77,24 @@ void createDbAndTable() {
exit
(
1
);
exit
(
1
);
}
}
sprintf
(
qstr
,
"create database if not exists %s cache %d tables %d"
,
dbName
,
cache
,
tables
);
sprintf
(
qstr
,
"create database if not exists %s cache %d maxtables %d"
,
dbName
,
cache
,
tables
);
if
(
taos_query
(
con
,
qstr
))
{
pSql
=
taos_query
(
con
,
qstr
);
pError
(
"failed to create database:%s, code:%d reason:%s"
,
dbName
,
taos_errno
(
con
),
taos_errstr
(
con
));
int32_t
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to create database:%s, sql:%s, code:%d reason:%s"
,
dbName
,
qstr
,
taos_errno
(
con
),
taos_errstr
(
con
));
exit
(
0
);
exit
(
0
);
}
}
taos_free_result
(
pSql
);
sprintf
(
qstr
,
"use %s"
,
dbName
);
sprintf
(
qstr
,
"use %s"
,
dbName
);
if
(
taos_query
(
con
,
qstr
))
{
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to use db, code:%d reason:%s"
,
taos_errno
(
con
),
taos_errstr
(
con
));
pError
(
"failed to use db, code:%d reason:%s"
,
taos_errno
(
con
),
taos_errstr
(
con
));
exit
(
0
);
exit
(
0
);
}
}
taos_free_result
(
pSql
);
gettimeofday
(
&
systemTime
,
NULL
);
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
int64_t
totalTables
=
numOfTablesPerThread
*
numOfThreads
;
if
(
strcmp
(
stableName
,
"no"
)
!=
0
)
{
if
(
strcmp
(
stableName
,
"no"
)
!=
0
)
{
int
len
=
sprintf
(
qstr
,
"create table if not exists %s(ts timestamp"
,
stableName
);
int
len
=
sprintf
(
qstr
,
"create table if not exists %s(ts timestamp"
,
stableName
);
for
(
int64_t
f
=
0
;
f
<
pointsPerTable
;
++
f
)
{
for
(
int64_t
f
=
0
;
f
<
pointsPerTable
;
++
f
)
{
...
@@ -100,36 +102,14 @@ void createDbAndTable() {
...
@@ -100,36 +102,14 @@ void createDbAndTable() {
}
}
sprintf
(
qstr
+
len
,
") tags(t int)"
);
sprintf
(
qstr
+
len
,
") tags(t int)"
);
if
(
taos_query
(
con
,
qstr
))
{
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to create stable, code:%d reason:%s"
,
taos_errno
(
con
),
taos_errstr
(
con
));
pError
(
"failed to create stable, code:%d reason:%s"
,
taos_errno
(
con
),
taos_errstr
(
con
));
exit
(
0
);
exit
(
0
);
}
}
taos_free_result
(
pSql
);
for
(
int64_t
t
=
0
;
t
<
totalTables
;
++
t
)
{
sprintf
(
qstr
,
"create table if not exists %s%ld using %s tags(%ld)"
,
stableName
,
t
,
stableName
,
t
);
if
(
taos_query
(
con
,
qstr
))
{
pError
(
"failed to create table %s%d, reason:%s"
,
stableName
,
t
,
taos_errstr
(
con
));
exit
(
0
);
}
}
}
else
{
for
(
int64_t
t
=
0
;
t
<
totalTables
;
++
t
)
{
int
len
=
sprintf
(
qstr
,
"create table if not exists %s%ld(ts timestamp"
,
stableName
,
t
);
for
(
int64_t
f
=
0
;
f
<
pointsPerTable
;
++
f
)
{
len
+=
sprintf
(
qstr
+
len
,
", f%ld double"
,
f
);
}
sprintf
(
qstr
+
len
,
")"
);
if
(
taos_query
(
con
,
qstr
))
{
pError
(
"failed to create table %s%ld, reason:%s"
,
stableName
,
t
,
taos_errstr
(
con
));
exit
(
0
);
}
}
}
}
gettimeofday
(
&
systemTime
,
NULL
);
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
pPrint
(
"%.1f seconds to create %ld tables"
,
(
et
-
st
)
/
1000
.
0
/
1000
.
0
,
totalTables
);
}
}
void
insertData
()
{
void
insertData
()
{
...
@@ -144,7 +124,7 @@ void insertData() {
...
@@ -144,7 +124,7 @@ void insertData() {
pthread_attr_t
thattr
;
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
SInfo
*
pInfo
=
(
SInfo
*
)
malloc
(
sizeof
(
SInfo
)
*
numOfThreads
);
SInfo
*
pInfo
=
(
SInfo
*
)
calloc
(
numOfThreads
,
sizeof
(
SInfo
)
);
// Start threads to write
// Start threads to write
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
...
@@ -173,10 +153,15 @@ void insertData() {
...
@@ -173,10 +153,15 @@ void insertData() {
double
speedOfRows
=
totalRows
/
seconds
;
double
speedOfRows
=
totalRows
/
seconds
;
double
speedOfPoints
=
totalPoints
/
seconds
;
double
speedOfPoints
=
totalPoints
/
seconds
;
float
createTableSpeed
=
0
;
for
(
int
i
=
0
;
i
<
numOfThreads
;
++
i
)
{
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
}
pPrint
(
pPrint
(
"%sall threads:%ld finished, use %.1lf seconds, tables:%.ld rows:%ld points:%ld, speed RowsPerSecond:%.1lf "
"%sall threads:%ld finished, use %.1lf seconds, tables:%.ld rows:%ld points:%ld, speed RowsPerSecond:%.1lf "
"PointsPerSecond:%.1lf%s"
,
"PointsPerSecond:%.1lf
CreateTableSpeed:%.1f t/s
%s"
,
GREEN
,
numOfThreads
,
seconds
,
totalTables
,
totalRows
,
totalPoints
,
speedOfRows
,
speedOfPoints
,
NC
);
GREEN
,
numOfThreads
,
seconds
,
totalTables
,
totalRows
,
totalPoints
,
speedOfRows
,
speedOfPoints
,
createTableSpeed
,
NC
);
pPrint
(
"threads exit"
);
pPrint
(
"threads exit"
);
...
@@ -191,6 +176,7 @@ void *syncTest(void *param) {
...
@@ -191,6 +176,7 @@ void *syncTest(void *param) {
int64_t
st
,
et
;
int64_t
st
,
et
;
char
qstr
[
65000
];
char
qstr
[
65000
];
int
maxBytes
=
60000
;
int
maxBytes
=
60000
;
int
code
;
pPrint
(
"thread:%d, start to run"
,
pInfo
->
threadIndex
);
pPrint
(
"thread:%d, start to run"
,
pInfo
->
threadIndex
);
...
@@ -210,6 +196,48 @@ void *syncTest(void *param) {
...
@@ -210,6 +196,48 @@ void *syncTest(void *param) {
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
if
(
strcmp
(
stableName
,
"no"
)
!=
0
)
{
for
(
int64_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
sprintf
(
qstr
,
"create table if not exists %s%ld using %s tags(%ld)"
,
stableName
,
t
,
stableName
,
t
);
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to create table %s%d, reason:%s"
,
stableName
,
t
,
taos_errstr
(
con
));
exit
(
0
);
}
taos_free_result
(
pSql
);
}
}
else
{
for
(
int64_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
int
len
=
sprintf
(
qstr
,
"create table if not exists %s%ld(ts timestamp"
,
stableName
,
t
);
for
(
int64_t
f
=
0
;
f
<
pointsPerTable
;
++
f
)
{
len
+=
sprintf
(
qstr
+
len
,
", f%ld double"
,
f
);
}
sprintf
(
qstr
+
len
,
")"
);
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"failed to create table %s%ld, reason:%s"
,
stableName
,
t
,
taos_errstr
(
con
));
exit
(
0
);
}
taos_free_result
(
pSql
);
}
}
gettimeofday
(
&
systemTime
,
NULL
);
et
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
float
seconds
=
(
et
-
st
)
/
1000
.
0
/
1000
.
0
;
int64_t
tables
=
pInfo
->
tableEndIndex
-
pInfo
->
tableBeginIndex
;
pInfo
->
createTableSpeed
=
(
float
)
tables
/
seconds
;
pPrint
(
"thread:%d, %.1f seconds to create %ld tables, speed:%.1f"
,
pInfo
->
threadIndex
,
seconds
,
tables
,
pInfo
->
createTableSpeed
);
if
(
pInfo
->
rowsPerTable
==
0
)
return
NULL
;
gettimeofday
(
&
systemTime
,
NULL
);
st
=
systemTime
.
tv_sec
*
1000000
+
systemTime
.
tv_usec
;
int64_t
start
=
1430000000000
;
int64_t
start
=
1430000000000
;
int64_t
interval
=
1000
;
// 1000 ms
int64_t
interval
=
1000
;
// 1000 ms
...
@@ -227,10 +255,13 @@ void *syncTest(void *param) {
...
@@ -227,10 +255,13 @@ void *syncTest(void *param) {
}
}
len
+=
sprintf
(
sql
+
len
,
")"
);
len
+=
sprintf
(
sql
+
len
,
")"
);
if
(
len
>
maxBytes
)
{
if
(
len
>
maxBytes
)
{
if
(
taos_query
(
con
,
qstr
))
{
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
int32_t
code
=
taos_errno
(
pSql
);
if
(
code
!=
0
)
{
pError
(
"thread:%d, failed to insert table:%s%ld row:%ld, reason:%s"
,
pInfo
->
threadIndex
,
pInfo
->
stableName
,
pError
(
"thread:%d, failed to insert table:%s%ld row:%ld, reason:%s"
,
pInfo
->
threadIndex
,
pInfo
->
stableName
,
table
,
row
,
taos_errstr
(
con
));
table
,
row
,
taos_errstr
(
con
));
}
}
taos_free_result
(
pSql
);
// "insert into"
// "insert into"
len
=
sprintf
(
sql
,
"%s"
,
inserStr
);
len
=
sprintf
(
sql
,
"%s"
,
inserStr
);
...
@@ -239,7 +270,8 @@ void *syncTest(void *param) {
...
@@ -239,7 +270,8 @@ void *syncTest(void *param) {
}
}
if
(
len
!=
strlen
(
inserStr
))
{
if
(
len
!=
strlen
(
inserStr
))
{
taos_query
(
con
,
qstr
);
TAOS_RES
*
pSql
=
taos_query
(
con
,
qstr
);
taos_free_result
(
pSql
);
}
}
gettimeofday
(
&
systemTime
,
NULL
);
gettimeofday
(
&
systemTime
,
NULL
);
...
...
tests/test/c/insertPerTable.c
浏览文件 @
88519c19
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录