Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
49da63be
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
49da63be
编写于
10月 21, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
10月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3951 from taosdata/feature/os
TD-1768
上级
bf2d3909
57417c7f
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
82 addition
and
66 deletion
+82
-66
src/client/src/tscSql.c
src/client/src/tscSql.c
+3
-3
src/inc/taos.h
src/inc/taos.h
+6
-7
src/inc/vnode.h
src/inc/vnode.h
+2
-0
src/sync/CMakeLists.txt
src/sync/CMakeLists.txt
+4
-4
src/vnode/src/vnodeMain.c
src/vnode/src/vnodeMain.c
+9
-7
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+36
-36
src/vnode/src/vnodeWrite.c
src/vnode/src/vnodeWrite.c
+22
-9
未找到文件。
src/client/src/tscSql.c
浏览文件 @
49da63be
...
...
@@ -174,7 +174,7 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
&
pObj
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
if
(
pSql
!=
NULL
)
{
pSql
->
fp
=
syncConnCallback
;
pSql
->
param
=
pSql
;
...
...
@@ -245,7 +245,7 @@ static void asyncConnCallback(void *param, TAOS_RES *tres, int code) {
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
TAOS
**
taos
)
{
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
&
pObj
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
asyncConnCallback
,
param
,
(
void
**
)
&
pObj
);
if
(
pSql
==
NULL
)
{
return
NULL
;
}
...
...
src/inc/taos.h
浏览文件 @
49da63be
...
...
@@ -22,13 +22,12 @@
extern
"C"
{
#endif
typedef
struct
STscObj
TAOS
;
typedef
struct
STscStmt
TAOS_STMT
;
typedef
struct
SSqlObj
TAOS_RES
;
typedef
struct
SSqlStream
TAOS_STREAM
;
typedef
struct
SSub
TAOS_SUB
;
typedef
unsigned
char
**
TAOS_ROW
;
typedef
void
TAOS
;
typedef
void
TAOS_STMT
;
typedef
void
TAOS_RES
;
typedef
void
TAOS_STREAM
;
typedef
void
TAOS_SUB
;
typedef
void
**
TAOS_ROW
;
// Data type definition
#define TSDB_DATA_TYPE_NULL 0 // 1 bytes
...
...
src/inc/vnode.h
浏览文件 @
49da63be
...
...
@@ -56,6 +56,7 @@ void vnodeRelease(void *pVnode); // dec refCount
void
*
vnodeGetWal
(
void
*
pVnode
);
int32_t
vnodeProcessWrite
(
void
*
pVnode
,
int
qtype
,
void
*
pHead
,
void
*
item
);
int32_t
vnodeCheckWrite
(
void
*
pVnode
);
int32_t
vnodeGetVnodeList
(
int32_t
vnodeList
[],
int32_t
*
numOfVnodes
);
void
vnodeBuildStatusMsg
(
void
*
param
);
void
vnodeConfirmForward
(
void
*
param
,
uint64_t
version
,
int32_t
code
);
...
...
@@ -65,6 +66,7 @@ int32_t vnodeInitResources();
void
vnodeCleanupResources
();
int32_t
vnodeProcessRead
(
void
*
pVnode
,
SReadMsg
*
pReadMsg
);
int32_t
vnodeCheckRead
(
void
*
pVnode
);
#ifdef __cplusplus
}
...
...
src/sync/CMakeLists.txt
浏览文件 @
49da63be
...
...
@@ -5,14 +5,14 @@ INCLUDE_DIRECTORIES(inc)
AUX_SOURCE_DIRECTORY
(
src SRC
)
IF
(
TD_LINUX
)
LIST
(
REMOVE_ITEM SRC
./
src/tarbitrator.c
)
LIST
(
REMOVE_ITEM SRC src/tarbitrator.c
)
ADD_LIBRARY
(
sync
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
sync tutil pthread common
)
LIST
(
APPEND BIN_SRC
./
src/tarbitrator.c
)
LIST
(
APPEND BIN_SRC
./
src/taosTcpPool.c
)
LIST
(
APPEND BIN_SRC src/tarbitrator.c
)
LIST
(
APPEND BIN_SRC src/taosTcpPool.c
)
ADD_EXECUTABLE
(
tarbitrator
${
BIN_SRC
}
)
TARGET_LINK_LIBRARIES
(
tarbitrator sync common osdetail tutil
)
ADD_SUBDIRECTORY
(
test
)
#
ADD_SUBDIRECTORY(test)
ENDIF
()
src/vnode/src/vnodeMain.c
浏览文件 @
49da63be
...
...
@@ -465,9 +465,10 @@ void *vnodeAcquireRqueue(int32_t vgId) {
SVnodeObj
*
pVnode
=
vnodeAcquire
(
vgId
);
if
(
pVnode
==
NULL
)
return
NULL
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_RESET
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
vInfo
(
"vgId:%d, status is in reset"
,
vgId
);
int32_t
code
=
vnodeCheckRead
(
pVnode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
vInfo
(
"vgId:%d, can not provide read service, status is %s"
,
vgId
,
vnodeStatus
[
pVnode
->
status
]);
vnodeRelease
(
pVnode
);
return
NULL
;
}
...
...
@@ -479,9 +480,10 @@ void *vnodeAcquireWqueue(int32_t vgId) {
SVnodeObj
*
pVnode
=
vnodeAcquire
(
vgId
);
if
(
pVnode
==
NULL
)
return
NULL
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_RESET
)
{
terrno
=
TSDB_CODE_APP_NOT_READY
;
vInfo
(
"vgId:%d, status is in reset"
,
vgId
);
int32_t
code
=
vnodeCheckWrite
(
pVnode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
vInfo
(
"vgId:%d, can not provide write service, status is %s"
,
vgId
,
vnodeStatus
[
pVnode
->
status
]);
vnodeRelease
(
pVnode
);
return
NULL
;
}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
49da63be
...
...
@@ -39,7 +39,13 @@ void vnodeInitReadFp(void) {
vnodeProcessReadMsgFp
[
TSDB_MSG_TYPE_FETCH
]
=
vnodeProcessFetchMsg
;
}
static
int32_t
vnodeProcessReadImp
(
SVnodeObj
*
pVnode
,
SReadMsg
*
pReadMsg
)
{
//
// After the fetch request enters the vnode queue, if the vnode cannot provide services, the process function are
// still required, or there will be a deadlock, so we don’t do any check here, but put the check codes before the
// request enters the queue
//
int32_t
vnodeProcessRead
(
void
*
param
,
SReadMsg
*
pReadMsg
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
int
msgType
=
pReadMsg
->
rpcMsg
.
msgType
;
if
(
vnodeProcessReadMsgFp
[
msgType
]
==
NULL
)
{
...
...
@@ -47,53 +53,35 @@ static int32_t vnodeProcessReadImp(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
return
TSDB_CODE_VND_MSG_NOT_PROCESSED
;
}
return
(
*
vnodeProcessReadMsgFp
[
msgType
])(
pVnode
,
pReadMsg
);
}
int32_t
vnodeCheckRead
(
void
*
param
)
{
SVnodeObj
*
pVnode
=
param
;
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_READY
)
{
vDebug
(
"vgId:%d,
msgType:%s not processed, vnode status is %s"
,
pVnode
->
vgId
,
taosMsg
[
msgType
],
vnodeStatus
[
pVnode
->
status
]
);
vDebug
(
"vgId:%d,
vnode status is %s, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
vnodeStatus
[
pVnode
->
status
],
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_APP_NOT_READY
;
}
// tsdb may be in reset state
if
(
pVnode
->
tsdb
==
NULL
)
{
vDebug
(
"vgId:%d, msgType:%s not processed, tsdb is null"
,
pVnode
->
vgId
,
taosMsg
[
msgType
]);
return
TSDB_CODE_APP_NOT_READY
;
}
if
(
pVnode
->
status
==
TAOS_VN_STATUS_CLOSING
)
{
vDebug
(
"vgId:%d, msgType:%s not processed, vstatus is %s"
,
pVnode
->
vgId
,
taosMsg
[
msgType
],
vnodeStatus
[
pVnode
->
status
]);
vDebug
(
"vgId:%d, tsdb is null, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_APP_NOT_READY
;
}
if
(
pVnode
->
role
!=
TAOS_SYNC_ROLE_SLAVE
&&
pVnode
->
role
!=
TAOS_SYNC_ROLE_MASTER
)
{
vDebug
(
"vgId:%d,
msgType:%s not processed, replica:%d role:%s"
,
pVnode
->
vgId
,
taosMsg
[
msgType
]
,
pVnode
->
syncCfg
.
replica
,
syncRole
[
pVnode
->
role
]
);
vDebug
(
"vgId:%d,
replica:%d role:%s, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
pVnode
->
syncCfg
.
replica
,
syncRole
[
pVnode
->
role
],
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_APP_NOT_READY
;
}
return
(
*
vnodeProcessReadMsgFp
[
msgType
])(
pVnode
,
pReadMsg
);
}
int32_t
vnodeProcessRead
(
void
*
param
,
SReadMsg
*
pRead
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
int32_t
code
=
vnodeProcessReadImp
(
pVnode
,
pRead
);
if
(
code
==
TSDB_CODE_APP_NOT_READY
&&
pRead
->
rpcMsg
.
msgType
==
TSDB_MSG_TYPE_QUERY
)
{
// After the fetch request enters the vnode queue
// If the vnode cannot provide services, the following operations are still required
// Or, there will be a deadlock
void
**
qhandle
=
(
void
**
)
pRead
->
pCont
;
vError
(
"QInfo:%p msg:%p will be killed for vstatus is %s"
,
*
qhandle
,
pRead
,
vnodeStatus
[
pVnode
->
status
]);
// qKillQuery(*qhandle);
// qReleaseQInfo(pVnode->qMgmt, (void **)&qhandle, true);
return
TSDB_CODE_APP_NOT_READY
;
}
else
{
return
code
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
vnodePutItemIntoReadQueue
(
SVnodeObj
*
pVnode
,
void
**
qhandle
,
void
*
ahandle
)
{
int32_t
code
=
vnodeCheckRead
(
pVnode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
return
code
;
static
void
vnodePutItemIntoReadQueue
(
SVnodeObj
*
pVnode
,
void
**
qhandle
,
void
*
ahandle
)
{
SReadMsg
*
pRead
=
(
SReadMsg
*
)
taosAllocateQitem
(
sizeof
(
SReadMsg
));
pRead
->
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_QUERY
;
pRead
->
pCont
=
qhandle
;
...
...
@@ -104,6 +92,8 @@ static void vnodePutItemIntoReadQueue(SVnodeObj *pVnode, void **qhandle, void *a
vDebug
(
"QInfo:%p add to vread queue for exec query, msg:%p"
,
*
qhandle
,
pRead
);
taosWriteQitem
(
pVnode
->
rqueue
,
TAOS_QTYPE_QUERY
,
pRead
);
return
TSDB_CODE_SUCCESS
;
}
/**
...
...
@@ -122,8 +112,13 @@ static int32_t vnodeDumpQueryResult(SRspRet *pRet, void *pVnode, void **handle,
if
((
code
=
qDumpRetrieveResult
(
*
handle
,
(
SRetrieveTableRsp
**
)
&
pRet
->
rsp
,
&
pRet
->
len
,
&
continueExec
))
==
TSDB_CODE_SUCCESS
)
{
if
(
continueExec
)
{
*
freeHandle
=
false
;
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
ahandle
);
code
=
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
ahandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
*
freeHandle
=
true
;
return
code
;
}
else
{
pRet
->
qhandle
=
*
handle
;
}
}
else
{
*
freeHandle
=
true
;
vDebug
(
"QInfo:%p exec completed, free handle:%d"
,
*
handle
,
*
freeHandle
);
...
...
@@ -226,7 +221,12 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
if
(
handle
!=
NULL
)
{
vDebug
(
"vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app"
,
vgId
,
*
handle
);
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
pReadMsg
->
rpcMsg
.
ahandle
);
code
=
vnodePutItemIntoReadQueue
(
pVnode
,
handle
,
pReadMsg
->
rpcMsg
.
ahandle
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pRsp
->
code
=
code
;
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
return
pRsp
->
code
;
}
}
}
else
{
assert
(
pCont
!=
NULL
);
...
...
src/vnode/src/vnodeWrite.c
浏览文件 @
49da63be
...
...
@@ -56,15 +56,6 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
return
TSDB_CODE_VND_MSG_NOT_PROCESSED
;
}
if
(
!
(
pVnode
->
accessState
&
TSDB_VN_WRITE_ACCCESS
))
{
vDebug
(
"vgId:%d, msgType:%s not processed, no write auth"
,
pVnode
->
vgId
,
taosMsg
[
pHead
->
msgType
]);
return
TSDB_CODE_VND_NO_WRITE_AUTH
;
}
// tsdb may be in reset state
if
(
pVnode
->
tsdb
==
NULL
)
return
TSDB_CODE_APP_NOT_READY
;
if
(
pVnode
->
status
==
TAOS_VN_STATUS_CLOSING
)
return
TSDB_CODE_APP_NOT_READY
;
if
(
pHead
->
version
==
0
)
{
// from client or CQ
if
(
pVnode
->
status
!=
TAOS_VN_STATUS_READY
)
{
vDebug
(
"vgId:%d, msgType:%s not processed, vnode status is %d"
,
pVnode
->
vgId
,
taosMsg
[
pHead
->
msgType
],
...
...
@@ -105,6 +96,28 @@ int32_t vnodeProcessWrite(void *param1, int qtype, void *param2, void *item) {
return
syncCode
;
}
int32_t
vnodeCheckWrite
(
void
*
param
)
{
SVnodeObj
*
pVnode
=
param
;
if
(
!
(
pVnode
->
accessState
&
TSDB_VN_WRITE_ACCCESS
))
{
vDebug
(
"vgId:%d, no write auth, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_VND_NO_WRITE_AUTH
;
}
// tsdb may be in reset state
if
(
pVnode
->
tsdb
==
NULL
)
{
vDebug
(
"vgId:%d, tsdb is null, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_APP_NOT_READY
;
}
if
(
pVnode
->
status
==
TAOS_VN_STATUS_CLOSING
)
{
vDebug
(
"vgId:%d, vnode status is %s, recCount:%d pVnode:%p"
,
pVnode
->
vgId
,
vnodeStatus
[
pVnode
->
status
],
pVnode
->
refCount
,
pVnode
);
return
TSDB_CODE_APP_NOT_READY
;
}
return
TSDB_CODE_SUCCESS
;
}
void
vnodeConfirmForward
(
void
*
param
,
uint64_t
version
,
int32_t
code
)
{
SVnodeObj
*
pVnode
=
(
SVnodeObj
*
)
param
;
syncConfirmForward
(
pVnode
->
sync
,
version
,
code
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录