Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9a5f4f2f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9a5f4f2f
编写于
1月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix create table error while use multi dnodes
上级
8b808fbc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
58 deletion
+60
-58
source/dnode/mnode/impl/src/mndAuth.c
source/dnode/mnode/impl/src/mndAuth.c
+12
-3
tests/test/c/create_table.c
tests/test/c/create_table.c
+48
-55
未找到文件。
source/dnode/mnode/impl/src/mndAuth.c
浏览文件 @
9a5f4f2f
...
...
@@ -16,9 +16,18 @@
#define _DEFAULT_SOURCE
#include "mndAuth.h"
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
return
0
;
}
void
mndCleanupAuth
(
SMnode
*
pMnode
)
{}
static
int32_t
mndProcessAuthReq
(
SMnodeMsg
*
pReq
);
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
mndSetMsgHandle
(
pMnode
,
TDMT_MND_AUTH
,
mndProcessAuthReq
);
return
0
;
}
void
mndCleanupAuth
(
SMnode
*
pMnode
)
{}
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
char
*
user
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
)
{
return
0
;
}
static
int32_t
mndProcessAuthReq
(
SMnodeMsg
*
pReq
)
{
mDebug
(
"user:%s, auth req is processed"
,
pReq
->
user
);
return
0
;
}
\ No newline at end of file
tests/test/c/create_table.c
浏览文件 @
9a5f4f2f
...
...
@@ -46,9 +46,9 @@ typedef struct {
pthread_t
thread
;
}
SThreadInfo
;
//void parseArgument(int32_t argc, char *argv[]);
//void *threadFunc(void *param);
//void createDbAndStb();
//
void parseArgument(int32_t argc, char *argv[]);
//
void *threadFunc(void *param);
//
void createDbAndStb();
void
createDbAndStb
()
{
pPrint
(
"start to create db and stable"
);
...
...
@@ -64,7 +64,8 @@ void createDbAndStb() {
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
int32_t
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
)
{
pError
(
"failed to create database:%s, sql:%s, code:%d reason:%s"
,
dbName
,
qstr
,
taos_errno
(
pRes
),
taos_errstr
(
pRes
));
pError
(
"failed to create database:%s, sql:%s, code:%d reason:%s"
,
dbName
,
qstr
,
taos_errno
(
pRes
),
taos_errstr
(
pRes
));
exit
(
0
);
}
taos_free_result
(
pRes
);
...
...
@@ -129,10 +130,9 @@ static int64_t getResult(TAOS_RES *tres) {
return
numOfRows
;
}
void
showTables
()
{
void
showTables
()
{
pPrint
(
"start to show tables"
);
char
qstr
[
32
];
char
qstr
[
128
];
TAOS
*
con
=
taos_connect
(
NULL
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
con
==
NULL
)
{
...
...
@@ -140,9 +140,9 @@ void showTables() {
exit
(
1
);
}
s
printf
(
qstr
,
"use %s"
,
dbName
);
s
nprintf
(
qstr
,
128
,
"use %s"
,
dbName
);
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
int
code
=
taos_errno
(
pRes
);
int
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
)
{
pError
(
"failed to use db, code:%d reason:%s"
,
taos_errno
(
pRes
),
taos_errstr
(
pRes
));
exit
(
1
);
...
...
@@ -160,12 +160,11 @@ void showTables() {
int64_t
totalTableNum
=
getResult
(
pRes
);
taos_free_result
(
pRes
);
pPrint
(
"%s database: %s, total %"
PRId64
" tables %s"
,
GREEN
,
dbName
,
totalTableNum
,
NC
);
pPrint
(
"%s database: %s, total %"
PRId64
" tables %s"
,
GREEN
,
dbName
,
totalTableNum
,
NC
);
taos_close
(
con
);
}
void
*
threadFunc
(
void
*
param
)
{
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
param
;
char
*
qstr
=
malloc
(
2000
*
1000
);
...
...
@@ -177,48 +176,48 @@ void *threadFunc(void *param) {
exit
(
1
);
}
//printf("thread:%d, table range: %"PRId64 " - %"PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex, pInfo->tableEndIndex);
// printf("thread:%d, table range: %"PRId64 " - %"PRId64 "\n", pInfo->threadIndex, pInfo->tableBeginIndex,
// pInfo->tableEndIndex);
sprintf
(
qstr
,
"use %s"
,
pInfo
->
dbName
);
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
taos_free_result
(
pRes
);
if
(
createTable
)
{
int64_t
curMs
=
0
;
int64_t
beginMs
=
taosGetTimestampMs
();
pInfo
->
startMs
=
beginMs
;
int64_t
t
=
pInfo
->
tableBeginIndex
;
int64_t
t
=
pInfo
->
tableBeginIndex
;
for
(;
t
<=
pInfo
->
tableEndIndex
;)
{
//int64_t batch = (pInfo->tableEndIndex - t);
//batch = MIN(batch, batchNum);
//
int64_t batch = (pInfo->tableEndIndex - t);
//
batch = MIN(batch, batchNum);
int32_t
len
=
sprintf
(
qstr
,
"create table"
);
for
(
int32_t
i
=
0
;
i
<
batchNum
;)
{
len
+=
sprintf
(
qstr
+
len
,
" %s_t%"
PRId64
" using %s tags(%"
PRId64
")"
,
stbName
,
t
,
stbName
,
t
);
t
++
;
i
++
;
t
++
;
i
++
;
if
(
t
>
pInfo
->
tableEndIndex
)
{
break
;
}
break
;
}
}
int64_t
startTs
=
taosGetTimestampUs
();
int64_t
startTs
=
taosGetTimestampUs
();
TAOS_RES
*
pRes
=
taos_query
(
con
,
qstr
);
code
=
taos_errno
(
pRes
);
if
(
code
!=
0
)
{
pError
(
"failed to create table t%"
PRId64
", reason:%s"
,
t
,
tstrerror
(
code
));
}
taos_free_result
(
pRes
);
int64_t
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
//
printf("==== %"PRId64" - %"PRId64", %"PRId64"\n", startTs, endTs, delay);
if
(
delay
>
pInfo
->
maxDelay
)
pInfo
->
maxDelay
=
delay
;
int64_t
endTs
=
taosGetTimestampUs
();
int64_t
delay
=
endTs
-
startTs
;
//
printf("==== %"PRId64" - %"PRId64", %"PRId64"\n", startTs, endTs, delay);
if
(
delay
>
pInfo
->
maxDelay
)
pInfo
->
maxDelay
=
delay
;
if
(
delay
<
pInfo
->
minDelay
)
pInfo
->
minDelay
=
delay
;
curMs
=
taosGetTimestampMs
();
if
(
curMs
-
beginMs
>
10000
)
{
beginMs
=
curMs
;
//
printf("==== tableBeginIndex: %"PRId64", t: %"PRId64"\n", pInfo->tableBeginIndex, t);
curMs
=
taosGetTimestampMs
();
if
(
curMs
-
beginMs
>
10000
)
{
beginMs
=
curMs
;
//
printf("==== tableBeginIndex: %"PRId64", t: %"PRId64"\n", pInfo->tableBeginIndex, t);
printCreateProgress
(
pInfo
,
t
);
}
}
...
...
@@ -227,7 +226,8 @@ void *threadFunc(void *param) {
if
(
insertData
)
{
int64_t
curMs
=
0
;
int64_t
beginMs
=
taosGetTimestampMs
();;
int64_t
beginMs
=
taosGetTimestampMs
();
;
pInfo
->
startMs
=
taosGetTimestampMs
();
for
(
int64_t
t
=
pInfo
->
tableBeginIndex
;
t
<
pInfo
->
tableEndIndex
;
++
t
)
{
...
...
@@ -247,7 +247,7 @@ void *threadFunc(void *param) {
taos_free_result
(
pRes
);
curMs
=
taosGetTimestampMs
();
if
(
curMs
-
beginMs
>
10000
)
{
if
(
curMs
-
beginMs
>
10000
)
{
printInsertProgress
(
pInfo
,
t
);
}
t
+=
(
batch
-
1
);
...
...
@@ -335,33 +335,32 @@ int32_t main(int32_t argc, char *argv[]) {
parseArgument
(
argc
,
argv
);
if
(
showTablesFlag
)
{
showTables
();
return
0
;
showTables
();
return
0
;
}
createDbAndStb
();
pPrint
(
"%d threads are spawned to create %
d tables"
,
numOfThreads
,
numOfThread
s
);
pPrint
(
"%d threads are spawned to create %
"
PRId64
" tables"
,
numOfThreads
,
numOfTable
s
);
pthread_attr_t
thattr
;
pthread_attr_init
(
&
thattr
);
pthread_attr_setdetachstate
(
&
thattr
,
PTHREAD_CREATE_JOINABLE
);
SThreadInfo
*
pInfo
=
(
SThreadInfo
*
)
calloc
(
numOfThreads
,
sizeof
(
SThreadInfo
));
//int64_t numOfTablesPerThread = numOfTables / numOfThreads;
//numOfTables = numOfTablesPerThread * numOfThreads;
// int64_t numOfTablesPerThread = numOfTables / numOfThreads;
// numOfTables = numOfTablesPerThread * numOfThreads;
if
(
numOfThreads
<
1
)
{
numOfThreads
=
1
;
}
int64_t
a
=
numOfTables
/
numOfThreads
;
if
(
a
<
1
)
{
numOfThreads
=
numOfTables
;
a
=
1
;
numOfThreads
=
numOfTables
;
a
=
1
;
}
int64_t
b
=
0
;
b
=
numOfTables
%
numOfThreads
;
...
...
@@ -371,7 +370,7 @@ int32_t main(int32_t argc, char *argv[]) {
pInfo
[
i
].
tableEndIndex
=
i
<
b
?
tableFrom
+
a
:
tableFrom
+
a
-
1
;
tableFrom
=
pInfo
[
i
].
tableEndIndex
+
1
;
pInfo
[
i
].
threadIndex
=
i
;
pInfo
[
i
].
minDelay
=
INT64_MAX
;
pInfo
[
i
].
minDelay
=
INT64_MAX
;
strcpy
(
pInfo
[
i
].
dbName
,
dbName
);
strcpy
(
pInfo
[
i
].
stbName
,
stbName
);
pthread_create
(
&
(
pInfo
[
i
].
thread
),
&
thattr
,
threadFunc
,
(
void
*
)(
pInfo
+
i
));
...
...
@@ -390,7 +389,7 @@ int32_t main(int32_t argc, char *argv[]) {
createTableSpeed
+=
pInfo
[
i
].
createTableSpeed
;
if
(
pInfo
[
i
].
maxDelay
>
maxDelay
)
maxDelay
=
pInfo
[
i
].
maxDelay
;
if
(
pInfo
[
i
].
minDelay
<
minDelay
)
minDelay
=
pInfo
[
i
].
minDelay
;
if
(
pInfo
[
i
].
minDelay
<
minDelay
)
minDelay
=
pInfo
[
i
].
minDelay
;
}
float
insertDataSpeed
=
0
;
...
...
@@ -398,21 +397,15 @@ int32_t main(int32_t argc, char *argv[]) {
insertDataSpeed
+=
pInfo
[
i
].
insertDataSpeed
;
}
pPrint
(
"%s total %"
PRId64
" tables, %.1f tables/second, threads:%d, maxDelay: %"
PRId64
"us, minDelay: %"
PRId64
"us %s"
,
GREEN
,
numOfTables
,
createTableSpeed
,
numOfThreads
,
maxDelay
,
minDelay
,
NC
);
pPrint
(
"%s total %"
PRId64
" tables, %.1f tables/second, threads:%d, maxDelay: %"
PRId64
"us, minDelay: %"
PRId64
"us %s"
,
GREEN
,
numOfTables
,
createTableSpeed
,
numOfThreads
,
maxDelay
,
minDelay
,
NC
);
if
(
insertData
)
{
pPrint
(
"%s total %"
PRId64
" tables, %.1f rows/second, threads:%d %s"
,
GREEN
,
numOfTables
,
insertDataSpeed
,
numOfThreads
,
NC
);
pPrint
(
"%s total %"
PRId64
" tables, %.1f rows/second, threads:%d %s"
,
GREEN
,
numOfTables
,
insertDataSpeed
,
numOfThreads
,
NC
);
}
pthread_attr_destroy
(
&
thattr
);
free
(
pInfo
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录