Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c4d27182
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,发现更多精彩内容 >>
未验证
提交
c4d27182
编写于
3月 08, 2023
作者:
S
Shengliang Guan
提交者:
GitHub
3月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20332 from taosdata/fix/main_bugfix_wxy
fix: check the compatibility of client version and server version
上级
098dddc3
5d80e71d
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
72 addition
and
25 deletion
+72
-25
include/common/tmsg.h
include/common/tmsg.h
+1
-0
include/util/tversion.h
include/util/tversion.h
+5
-3
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-0
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+25
-16
source/common/src/tmsg.c
source/common/src/tmsg.c
+7
-0
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+10
-3
source/dnode/mnode/impl/test/profile/profile.cpp
source/dnode/mnode/impl/test/profile/profile.cpp
+4
-2
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+2
-1
source/util/src/tversion.c
source/util/src/tversion.c
+17
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
c4d27182
...
...
@@ -612,6 +612,7 @@ typedef struct {
char
user
[
TSDB_USER_LEN
];
char
passwd
[
TSDB_PASSWORD_LEN
];
int64_t
startTime
;
char
sVer
[
TSDB_VERSION_LEN
];
}
SConnectReq
;
int32_t
tSerializeSConnectReq
(
void
*
buf
,
int32_t
bufLen
,
SConnectReq
*
pReq
);
...
...
include/util/tversion.h
浏览文件 @
c4d27182
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_VERSION_H_
#define _TD_UTIL_VERSION_H_
#ifndef _TD_UTIL_
T
VERSION_H_
#define _TD_UTIL_
T
VERSION_H_
#include "os.h"
...
...
@@ -25,9 +25,11 @@ extern "C" {
int32_t
taosVersionStrToInt
(
const
char
*
vstr
,
int32_t
*
vint
);
int32_t
taosVersionIntToStr
(
int32_t
vint
,
char
*
vstr
,
int32_t
len
);
int32_t
taosCheckVersionCompatible
(
int32_t
clientVer
,
int32_t
serverVer
,
int32_t
comparedSegments
);
int32_t
taosCheckVersionCompatibleFromStr
(
const
char
*
pClientVersion
,
const
char
*
pServerVersion
,
int32_t
comparedSegments
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_VERSION_H_*/
#endif
/*_TD_UTIL_
T
VERSION_H_*/
source/client/src/clientImpl.c
浏览文件 @
c4d27182
...
...
@@ -1307,6 +1307,7 @@ static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) {
tstrncpy
(
connectReq
.
app
,
appInfo
.
appName
,
sizeof
(
connectReq
.
app
));
tstrncpy
(
connectReq
.
user
,
pObj
->
user
,
sizeof
(
connectReq
.
user
));
tstrncpy
(
connectReq
.
passwd
,
pObj
->
pass
,
sizeof
(
connectReq
.
passwd
));
tstrncpy
(
connectReq
.
sVer
,
version
,
sizeof
(
connectReq
.
sVer
));
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
taosMemoryMalloc
(
contLen
);
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
c4d27182
...
...
@@ -18,10 +18,12 @@
#include "clientLog.h"
#include "os.h"
#include "query.h"
#include "systable.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tglobal.h"
#include "tname.h"
#include "tdatablock.h"
#include "systable.h"
#include "tversion.h"
static
void
setErrno
(
SRequestObj
*
pRequest
,
int32_t
code
)
{
pRequest
->
code
=
code
;
...
...
@@ -47,11 +49,11 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
}
int32_t
processConnectRsp
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
SRequestObj
*
pRequest
=
acquireRequest
(
*
(
int64_t
*
)
param
);
SRequestObj
*
pRequest
=
acquireRequest
(
*
(
int64_t
*
)
param
);
if
(
NULL
==
pRequest
)
{
goto
End
;
}
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
...
...
@@ -65,7 +67,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
tsem_post
(
&
pRequest
->
body
.
rspSem
);
goto
End
;
}
SConnectRsp
connectRsp
=
{
0
};
if
(
tDeserializeSConnectRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
connectRsp
)
!=
0
)
{
code
=
TSDB_CODE_TSC_INVALID_VERSION
;
...
...
@@ -74,6 +76,12 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
goto
End
;
}
if
((
code
=
taosCheckVersionCompatibleFromStr
(
version
,
connectRsp
.
sVer
,
2
))
!=
0
)
{
setErrno
(
pRequest
,
code
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
goto
End
;
}
int32_t
now
=
taosGetTimestampSec
();
int32_t
delta
=
abs
(
now
-
connectRsp
.
svrTimestamp
);
if
(
delta
>
timestampDeltaLimit
)
{
...
...
@@ -127,14 +135,14 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
tscDebug
(
"0x%"
PRIx64
" clusterId:%"
PRId64
", totalConn:%"
PRId64
,
pRequest
->
requestId
,
connectRsp
.
clusterId
,
pTscObj
->
pAppInfo
->
numOfConns
);
tsem_post
(
&
pRequest
->
body
.
rspSem
);
End:
if
(
pRequest
)
{
releaseRequest
(
pRequest
->
self
);
}
taosMemoryFree
(
param
);
taosMemoryFree
(
pMsg
->
pEpSet
);
taosMemoryFree
(
pMsg
->
pData
);
...
...
@@ -166,18 +174,18 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
struct
SCatalog
*
pCatalog
=
NULL
;
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SRequestConnInfo
conn
=
{.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
,
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
)};
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
snprintf
(
dbFName
,
sizeof
(
dbFName
)
-
1
,
"%d.%s"
,
pTscObj
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
);
catalogRefreshDBVgInfo
(
pCatalog
,
&
conn
,
dbFName
);
snprintf
(
dbFName
,
sizeof
(
dbFName
)
-
1
,
"%d.%s"
,
pTscObj
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
);
catalogRefreshDBVgInfo
(
pCatalog
,
&
conn
,
dbFName
);
}
}
}
if
(
pRequest
->
body
.
queryFp
)
{
...
...
@@ -197,7 +205,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tDeserializeSUseDbRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
usedbRsp
);
struct
SCatalog
*
pCatalog
=
NULL
;
if
(
usedbRsp
.
vgVersion
>=
0
)
{
// cached in local
if
(
usedbRsp
.
vgVersion
>=
0
)
{
// cached in local
uint64_t
clusterId
=
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
;
int32_t
code1
=
catalogGetHandle
(
clusterId
,
&
pCatalog
);
if
(
code1
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -289,7 +297,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
int32_t
processCreateSTableRsp
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
if
(
pMsg
==
NULL
||
param
==
NULL
)
{
if
(
pMsg
==
NULL
||
param
==
NULL
)
{
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
SRequestObj
*
pRequest
=
param
;
...
...
@@ -344,13 +352,13 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
int32_t
code
=
catalogGetHandle
(
pRequest
->
pTscObj
->
pAppInfo
->
clusterId
,
&
pCatalog
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
catalogRemoveDB
(
pCatalog
,
dropdbRsp
.
db
,
dropdbRsp
.
uid
);
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SRequestConnInfo
conn
=
{.
pTrans
=
pTscObj
->
pAppInfo
->
pTransporter
,
.
requestId
=
pRequest
->
requestId
,
.
requestObjRefId
=
pRequest
->
self
,
.
mgmtEps
=
getEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
)};
char
dbFName
[
TSDB_DB_FNAME_LEN
];
char
dbFName
[
TSDB_DB_FNAME_LEN
];
snprintf
(
dbFName
,
sizeof
(
dbFName
)
-
1
,
"%d.%s"
,
pTscObj
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
);
catalogRefreshDBVgInfo
(
pCatalog
,
&
conn
,
dbFName
);
snprintf
(
dbFName
,
sizeof
(
dbFName
)
-
1
,
"%d.%s"
,
pTscObj
->
acctId
,
TSDB_PERFORMANCE_SCHEMA_DB
);
...
...
@@ -474,8 +482,9 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
int32_t
len
=
blockEncode
(
pBlock
,
(
*
pRsp
)
->
data
,
SHOW_VARIABLES_RESULT_COLS
);
blockDataDestroy
(
pBlock
);
if
(
len
!=
rspSize
-
sizeof
(
SRetrieveTableRsp
)){
uError
(
"buildShowVariablesRsp error, len:%d != rspSize - sizeof(SRetrieveTableRsp):%"
PRIu64
,
len
,
(
uint64_t
)
(
rspSize
-
sizeof
(
SRetrieveTableRsp
)));
if
(
len
!=
rspSize
-
sizeof
(
SRetrieveTableRsp
))
{
uError
(
"buildShowVariablesRsp error, len:%d != rspSize - sizeof(SRetrieveTableRsp):%"
PRIu64
,
len
,
(
uint64_t
)(
rspSize
-
sizeof
(
SRetrieveTableRsp
)));
return
TSDB_CODE_TSC_INVALID_INPUT
;
}
...
...
source/common/src/tmsg.c
浏览文件 @
c4d27182
...
...
@@ -3741,6 +3741,7 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tEncodeCStrWithLen
(
&
encoder
,
pReq
->
passwd
,
TSDB_PASSWORD_LEN
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
startTime
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
sVer
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
...
...
@@ -3760,6 +3761,12 @@ int32_t tDeserializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) {
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
user
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
passwd
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
startTime
)
<
0
)
return
-
1
;
// Check the client version from version 3.0.3.0
if
(
tDecodeIsEnd
(
&
decoder
))
{
tDecoderClear
(
&
decoder
);
return
TSDB_CODE_VERSION_NOT_COMPATIBLE
;
}
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
sVer
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
c4d27182
...
...
@@ -24,7 +24,7 @@
#include "mndStb.h"
#include "mndUser.h"
#include "tglobal.h"
#include "version.h"
#include "
t
version.h"
typedef
struct
{
uint32_t
id
;
...
...
@@ -221,11 +221,18 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
char
ip
[
24
]
=
{
0
};
const
STraceId
*
trace
=
&
pReq
->
info
.
traceId
;
if
(
tDeserializeSConnectReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
connReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
if
(
(
code
=
tDeserializeSConnectReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
connReq
)
)
!=
0
)
{
terrno
=
(
-
1
==
code
?
TSDB_CODE_INVALID_MSG
:
code
)
;
goto
_OVER
;
}
if
((
code
=
taosCheckVersionCompatibleFromStr
(
connReq
.
sVer
,
version
,
2
))
!=
0
)
{
terrno
=
code
;
goto
_OVER
;
}
code
=
-
1
;
taosIp2String
(
pReq
->
info
.
conn
.
clientIp
,
ip
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONNECT
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
...
...
source/dnode/mnode/impl/test/profile/profile.cpp
浏览文件 @
c4d27182
...
...
@@ -32,13 +32,14 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
connectReq
.
pid
=
1234
;
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
secretEncrypt
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
strcpy
(
connectReq
.
app
,
"mnode_test_profile"
);
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
strcpy
(
connectReq
.
sVer
,
version
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
@@ -66,7 +67,7 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
TEST_F
(
MndTestProfile
,
02
_ConnectMsg_InvalidDB
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
secretEncrypt
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
...
...
@@ -75,6 +76,7 @@ TEST_F(MndTestProfile, 02_ConnectMsg_InvalidDB) {
strcpy
(
connectReq
.
db
,
"invalid_db"
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
strcpy
(
connectReq
.
sVer
,
version
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
c4d27182
...
...
@@ -55,7 +55,7 @@ TEST_F(MndTestShow, 02_ShowMsg_InvalidMsgStart) {
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
char
passwd
[]
=
"taosdata"
;
char
secretEncrypt
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
secretEncrypt
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
taosEncryptPass_c
((
uint8_t
*
)
passwd
,
strlen
(
passwd
),
secretEncrypt
);
SConnectReq
connectReq
=
{
0
};
...
...
@@ -64,6 +64,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
strcpy
(
connectReq
.
db
,
""
);
strcpy
(
connectReq
.
user
,
"root"
);
strcpy
(
connectReq
.
passwd
,
secretEncrypt
);
strcpy
(
connectReq
.
sVer
,
version
);
int32_t
contLen
=
tSerializeSConnectReq
(
NULL
,
0
,
&
connectReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
...
...
source/util/src/tversion.c
浏览文件 @
c4d27182
...
...
@@ -89,3 +89,20 @@ int32_t taosCheckVersionCompatible(int32_t clientVer, int32_t serverVer, int32_t
return
-
1
;
}
}
int32_t
taosCheckVersionCompatibleFromStr
(
const
char
*
pClientVersion
,
const
char
*
pServerVersion
,
int32_t
comparedSegments
)
{
int32_t
clientVersion
=
0
;
int32_t
serverVersion
=
0
;
int32_t
code
=
taosVersionStrToInt
(
pClientVersion
,
&
clientVersion
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
taosVersionStrToInt
(
pServerVersion
,
&
serverVersion
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
taosCheckVersionCompatible
(
clientVersion
,
serverVersion
,
comparedSegments
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
code
=
terrno
;
}
return
code
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录