Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
47f85222
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
47f85222
编写于
6月 07, 2021
作者:
T
tickduan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
after kill client connection in taosd can not create stream normally
上级
164a7c47
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
19 deletion
+40
-19
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+16
-0
src/client/src/tscStream.c
src/client/src/tscStream.c
+3
-2
src/cq/src/cqMain.c
src/cq/src/cqMain.c
+3
-17
src/inc/tcq.h
src/inc/tcq.h
+17
-0
未找到文件。
src/client/inc/tsclient.h
浏览文件 @
47f85222
...
...
@@ -405,6 +405,7 @@ typedef struct SSqlObj {
typedef
struct
SSqlStream
{
SSqlObj
*
pSql
;
void
*
cqhandle
;
// stream belong to SCQContext handle
const
char
*
dstTable
;
uint32_t
streamId
;
char
listed
;
...
...
src/client/src/tscProfile.c
浏览文件 @
47f85222
...
...
@@ -19,6 +19,7 @@
#include "ttimer.h"
#include "tutil.h"
#include "taosmsg.h"
#include "tcq.h"
#include "taos.h"
...
...
@@ -294,6 +295,18 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
return
msgLen
;
}
// cqContext->dbconn is killed then call this callback
void
cqConnKilledNotify
(
void
*
handle
,
void
*
conn
)
{
if
(
handle
==
NULL
||
conn
==
NULL
){
return
;
}
SCqContext
*
pContext
=
(
SCqContext
*
)
handle
;
if
(
pContext
->
dbConn
==
conn
){
atomic_store_ptr
(
&
(
pContext
->
dbConn
),
NULL
);
}
}
void
tscKillConnection
(
STscObj
*
pObj
)
{
// get stream header by locked
pthread_mutex_lock
(
&
pObj
->
mutex
);
...
...
@@ -302,6 +315,8 @@ void tscKillConnection(STscObj *pObj) {
while
(
pStream
)
{
SSqlStream
*
tmp
=
pStream
->
next
;
// set associate variant to NULL
cqConnKilledNotify
(
pStream
->
cqhandle
,
pObj
);
// taos_close_stream function call pObj->mutet lock , careful death-lock
taos_close_stream
(
pStream
);
pStream
=
tmp
;
...
...
@@ -310,3 +325,4 @@ void tscKillConnection(STscObj *pObj) {
tscDebug
(
"connection:%p is killed"
,
pObj
);
taos_close
(
pObj
);
}
src/client/src/tscStream.c
浏览文件 @
47f85222
...
...
@@ -666,7 +666,7 @@ void cbParseSql(void* param, TAOS_RES* res, int code) {
}
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
dstTable
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
)
,
void
*
cqhandle
)
{
STscObj
*
pObj
=
(
STscObj
*
)
taos
;
if
(
pObj
==
NULL
||
pObj
->
signature
!=
pObj
)
return
NULL
;
...
...
@@ -699,6 +699,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
pStream
->
callback
=
callback
;
pStream
->
param
=
param
;
pStream
->
pSql
=
pSql
;
pStream
->
cqhandle
=
cqhandle
;
pSql
->
pStream
=
pStream
;
pSql
->
param
=
pStream
;
pSql
->
maxRetry
=
TSDB_MAX_REPLICA
;
...
...
@@ -739,7 +740,7 @@ TAOS_STREAM *taos_open_stream_withname(TAOS *taos, const char* dstTable, const c
TAOS_STREAM
*
taos_open_stream
(
TAOS
*
taos
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
))
{
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
stime
,
param
,
callback
);
return
taos_open_stream_withname
(
taos
,
""
,
sqlstr
,
fp
,
stime
,
param
,
callback
,
NULL
);
}
void
taos_close_stream
(
TAOS_STREAM
*
handle
)
{
...
...
src/cq/src/cqMain.c
浏览文件 @
47f85222
...
...
@@ -38,21 +38,6 @@
#define cDebug(...) { if (cqDebugFlag & DEBUG_DEBUG) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
#define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
typedef
struct
{
int32_t
vgId
;
int32_t
master
;
int32_t
num
;
// number of continuous streams
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
FCqWrite
cqWrite
;
struct
SCqObj
*
pHead
;
void
*
dbConn
;
void
*
tmrCtrl
;
pthread_mutex_t
mutex
;
int32_t
delete
;
int32_t
cqObjNum
;
}
SCqContext
;
typedef
struct
SCqObj
{
tmr_h
tmrId
;
...
...
@@ -439,7 +424,7 @@ static void cqProcessCreateTimer(void *param, void *tmrId) {
// inner implement in tscStream.c
TAOS_STREAM
*
taos_open_stream_withname
(
TAOS
*
taos
,
const
char
*
desName
,
const
char
*
sqlstr
,
void
(
*
fp
)(
void
*
param
,
TAOS_RES
*
,
TAOS_ROW
row
),
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
));
int64_t
stime
,
void
*
param
,
void
(
*
callback
)(
void
*
)
,
void
*
cqhandle
);
static
void
cqCreateStream
(
SCqContext
*
pContext
,
SCqObj
*
pObj
)
{
pObj
->
pContext
=
pContext
;
...
...
@@ -453,7 +438,8 @@ static void cqCreateStream(SCqContext *pContext, SCqObj *pObj) {
pObj
->
tmrId
=
0
;
if
(
pObj
->
pStream
==
NULL
)
{
pObj
->
pStream
=
taos_open_stream_withname
(
pContext
->
dbConn
,
pObj
->
dstTable
,
pObj
->
sqlStr
,
cqProcessStreamRes
,
INT64_MIN
,
(
void
*
)
pObj
->
rid
,
NULL
);
pObj
->
pStream
=
taos_open_stream_withname
(
pContext
->
dbConn
,
pObj
->
dstTable
,
pObj
->
sqlStr
,
cqProcessStreamRes
,
\
INT64_MIN
,
(
void
*
)
pObj
->
rid
,
NULL
,
pContext
);
// TODO the pObj->pStream may be released if error happens
if
(
pObj
->
pStream
)
{
...
...
src/inc/tcq.h
浏览文件 @
47f85222
...
...
@@ -31,6 +31,23 @@ typedef struct {
FCqWrite
cqWrite
;
}
SCqCfg
;
// SCqContext
typedef
struct
{
int32_t
vgId
;
int32_t
master
;
int32_t
num
;
// number of continuous streams
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_KEY_LEN
];
char
db
[
TSDB_DB_NAME_LEN
];
FCqWrite
cqWrite
;
struct
SCqObj
*
pHead
;
void
*
dbConn
;
void
*
tmrCtrl
;
pthread_mutex_t
mutex
;
int32_t
delete
;
int32_t
cqObjNum
;
}
SCqContext
;
// the following API shall be called by vnode
void
*
cqOpen
(
void
*
ahandle
,
const
SCqCfg
*
pCfg
);
void
cqClose
(
void
*
handle
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录