Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
35de0f4d
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看板
未验证
提交
35de0f4d
编写于
6月 07, 2021
作者:
D
DuanKuanJun
提交者:
GitHub
6月 07, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6390 from taosdata/cq
Kill Connection cause taosd crash
上级
6da72d82
47f85222
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
28 deletion
+48
-28
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-0
src/client/src/tscProfile.c
src/client/src/tscProfile.c
+20
-9
src/client/src/tscStream.c
src/client/src/tscStream.c
+7
-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
浏览文件 @
35de0f4d
...
...
@@ -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
浏览文件 @
35de0f4d
...
...
@@ -19,6 +19,7 @@
#include "ttimer.h"
#include "tutil.h"
#include "taosmsg.h"
#include "tcq.h"
#include "taos.h"
...
...
@@ -294,24 +295,34 @@ int tscBuildQueryStreamDesc(void *pMsg, STscObj *pObj) {
return
msgLen
;
}
void
tscKillConnection
(
STscObj
*
pObj
)
{
pthread_mutex_lock
(
&
pObj
->
mutex
);
// cqContext->dbconn is killed then call this callback
void
cqConnKilledNotify
(
void
*
handle
,
void
*
conn
)
{
if
(
handle
==
NULL
||
conn
==
NULL
){
return
;
}
S
SqlObj
*
pSql
=
pObj
->
sqlList
;
while
(
pSql
)
{
pSql
=
pSql
->
next
;
}
S
CqContext
*
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
);
SSqlStream
*
pStream
=
pObj
->
streamList
;
pthread_mutex_unlock
(
&
pObj
->
mutex
);
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
;
}
pthread_mutex_unlock
(
&
pObj
->
mutex
);
tscDebug
(
"connection:%p is killed"
,
pObj
);
taos_close
(
pObj
);
}
src/client/src/tscStream.c
浏览文件 @
35de0f4d
...
...
@@ -141,6 +141,10 @@ static void tscProcessStreamTimer(void *handle, void *tmrId) {
pStream
->
numOfRes
=
0
;
// reset the numOfRes.
SSqlObj
*
pSql
=
pStream
->
pSql
;
// pSql == NULL maybe killStream already called
if
(
pSql
==
NULL
)
{
return
;
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
&
pSql
->
cmd
,
0
);
tscDebug
(
"0x%"
PRIx64
" add into timer"
,
pSql
->
self
);
...
...
@@ -662,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
;
...
...
@@ -695,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
;
...
...
@@ -735,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
浏览文件 @
35de0f4d
...
...
@@ -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
浏览文件 @
35de0f4d
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录