diff --git a/include/client/taos.h b/include/client/taos.h index bfb29456be9ad632d721e81a07580589ad216ed3..530b40f5aaaa55c29ad7e49429d9143eba998bba 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -101,7 +101,7 @@ typedef struct TAOS_FIELD_E { #endif typedef void (*__taos_async_fn_t)(void *param, TAOS_RES *res, int code); -typedef void (*__taos_notify_fn_t)(void *param); +typedef void (*__taos_notify_fn_t)(void *param, void *ext, int type); typedef struct TAOS_MULTI_BIND { int buffer_type; @@ -122,6 +122,10 @@ typedef enum { SET_CONF_RET_ERR_TOO_LONG = -6 } SET_CONF_RET_CODE; +typedef enum { + TAOS_NOTIFY_PASSVER = 1, +} TAOS_NOTIFY_TYPE; + #define RET_MSG_LENGTH 1024 typedef struct setConfRet { SET_CONF_RET_CODE retCode; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 1ea12c3a1067fac719c689dc7d6a2bf3a085a356..b7332dd1cc33fcf9373599f30904b516e8c0b7eb 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -629,6 +629,7 @@ typedef struct { int8_t connType; SEpSet epSet; int32_t svrTimestamp; + int32_t passVer; char sVer[TSDB_VERSION_LEN]; char sDetailVer[128]; } SConnectRsp; diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index f547f9123cd03c994a50b73f158010d441bf2fbd..6596bc4bb332f7f46ddab081b236b07f00b01a25 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -54,15 +54,14 @@ static int32_t hbProcessUserPassInfoRsp(void *value, int32_t valueLen, SClientHb STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); if (NULL == pTscObj) { tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); - return TSDB_CODE_SUCCESS; + return code; } SUserPassBatchRsp batchRsp = {0}; if (tDeserializeSUserPassBatchRsp(value, valueLen, &batchRsp) != 0) { - terrno = TSDB_CODE_INVALID_MSG; + code = TSDB_CODE_INVALID_MSG; releaseTscObj(connKey->tscRid); - assert(0); - return -1; + return code; } SPassInfo *passInfo = &pTscObj->passInfo; @@ -70,11 +69,11 @@ static int32_t hbProcessUserPassInfoRsp(void *value, int32_t valueLen, SClientHb for (int32_t i = 0; i < numOfBatchs; ++i) { SGetUserPassRsp *rsp = taosArrayGet(batchRsp.pArray, i); if (0 == strncmp(rsp->user, pTscObj->user, TSDB_USER_LEN)) { - tscError("update user:%s passVer from %d to %d", rsp->user, passInfo->ver, rsp->version); + tscDebug("update passVer of user %s from %d to %d", rsp->user, passInfo->ver, rsp->version); if (atomic_load_32(&passInfo->ver) < rsp->version) { atomic_store_32(&passInfo->ver, rsp->version); if (passInfo->fp) { - (*passInfo->fp)(NULL); + (*passInfo->fp)(&pTscObj->id, NULL, TAOS_NOTIFY_PASSVER); } } } @@ -82,7 +81,7 @@ static int32_t hbProcessUserPassInfoRsp(void *value, int32_t valueLen, SClientHb taosArrayDestroy(batchRsp.pArray); releaseTscObj(connKey->tscRid); - return TSDB_CODE_SUCCESS; + return code; } static int32_t hbGenerateVgInfoFromRsp(SDBVgInfo **pInfo, SUseDbRsp *rsp) { diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index a0146cfa39fee78fee7287526a3a1c7ea7a8c2da..52c5fc79408a05cf499d33059c6e7c07d176b615 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -130,6 +130,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { lastClusterId = connectRsp.clusterId; pTscObj->connType = connectRsp.connType; + pTscObj->passInfo.ver = connectRsp.passVer; hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index a59fa7a2d6df73b3285845e9a14190c5980f9949..1f9a44b1f4e3eee7be9e7d136b8101585661e97d 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3874,6 +3874,7 @@ int32_t tSerializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tEncodeI32(&encoder, pRsp->svrTimestamp) < 0) return -1; if (tEncodeCStr(&encoder, pRsp->sVer) < 0) return -1; if (tEncodeCStr(&encoder, pRsp->sDetailVer) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->passVer) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -3897,6 +3898,13 @@ int32_t tDeserializeSConnectRsp(void *buf, int32_t bufLen, SConnectRsp *pRsp) { if (tDecodeI32(&decoder, &pRsp->svrTimestamp) < 0) return -1; if (tDecodeCStrTo(&decoder, pRsp->sVer) < 0) return -1; if (tDecodeCStrTo(&decoder, pRsp->sDetailVer) < 0) return -1; + + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI32(&decoder, &pRsp->passVer) < 0) return -1; + } else { + pRsp->passVer = 0; + } + tEndDecode(&decoder); tDecoderClear(&decoder); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 6e78982b036769322f3a46f782002e1f5d772a3e..2ebb5aeb9904cbabcc95086846b9ded2cdd2f1ef 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -283,6 +283,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { connectRsp.connType = connReq.connType; connectRsp.dnodeNum = mndGetDnodeSize(pMnode); connectRsp.svrTimestamp = taosGetTimestampSec(); + connectRsp.passVer = pUser->passVersion; strcpy(connectRsp.sVer, version); snprintf(connectRsp.sDetailVer, sizeof(connectRsp.sDetailVer), "ver:%s\nbuild:%s\ngitinfo:%s", version, buildinfo, diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 54e5eac20e134cf64233bc7afa37da36d17e78fe..de4768d74652517206154458559c9416bb23a2ef 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -1042,7 +1042,7 @@ int32_t mndValidateUserPassInfo(SMnode *pMnode, SUserPassVersion *pUsers, int32_ pUsers[i].version = ntohl(pUsers[i].version); if (pUser->passVersion <= pUsers[i].version) { - mDebug("user:%s, not update since mnd passVer %d <= client passVer %d", pUsers[i].user, pUser->passVersion, + mTrace("user:%s, not update since mnd passVer %d <= client passVer %d", pUsers[i].user, pUser->passVersion, pUsers[i].version); mndReleaseUser(pMnode, pUser); continue;