From 424a37fd3a73dd2a5b440a67fc939007b4d10175 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 7 Mar 2023 10:20:48 +0800 Subject: [PATCH 01/21] some code --- source/dnode/vnode/src/inc/vnodeInt.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index c0d017e350..ca61a4dfce 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -460,6 +460,8 @@ struct SCompactInfo { SVnode* pVnode; int32_t flag; int64_t commitID; + int64_t stime; + int64_t etime; }; #ifdef __cplusplus From 22e236f4e6b855579302f813806a93b6ccfcc4ba Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 7 Mar 2023 15:15:46 +0800 Subject: [PATCH 02/21] fix: check pWal->cfg.retentionPeriod properly --- source/libs/wal/src/walWrite.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index b74bbdd15f..00ad7a3d67 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -328,8 +328,8 @@ int32_t walEndSnapshot(SWal *pWal) { "), new tot size %" PRId64, pWal->cfg.vgId, iter->firstVer, iter->fileSize, iter->closeTs, newTotSize); if (((pWal->cfg.retentionSize == 0) || (pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize)) || - ((pWal->cfg.retentionPeriod == 0) || - (pWal->cfg.retentionPeriod != -1 && iter->closeTs + pWal->cfg.retentionPeriod > ts))) { + ((pWal->cfg.retentionPeriod == 0) || (pWal->cfg.retentionPeriod != -1 && iter->closeTs != -1 && + iter->closeTs + pWal->cfg.retentionPeriod < ts))) { // delete according to file size or close time wDebug("vgId:%d, check pass", pWal->cfg.vgId); deleteCnt++; From 383459441d9c12a64ff2f6017a9fe97f344f91f1 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Mon, 6 Mar 2023 20:24:47 +0800 Subject: [PATCH 03/21] enh: simplify conditions of triggering snapshot --- source/libs/sync/src/syncPipeline.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index faa44a626c..cc1a40a430 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -742,7 +742,8 @@ int32_t syncLogReplMgrProcessReplyAsRecovery(SSyncLogReplMgr* pMgr, SSyncNode* p if (pMsg->matchIndex < pNode->pLogBuf->matchIndex) { term = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index + 1); - if (term < 0 || (term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) { + if ((index + 1 < firstVer) || (term < 0) || + (term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) { ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); if (syncNodeStartSnapshot(pNode, &destId) < 0) { sError("vgId:%d, failed to start snapshot for peer dnode:%d", pNode->vgId, DID(&destId)); From 21c18a4a9b14064371067664e03cc8185eda1224 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 7 Mar 2023 16:34:02 +0800 Subject: [PATCH 04/21] enh: use syncNodeReplicateReset in syncNodeOnSnapshotRsp --- source/libs/sync/inc/syncReplication.h | 2 +- source/libs/sync/src/syncReplication.c | 9 +++++++++ source/libs/sync/src/syncSnapshot.c | 10 +++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/source/libs/sync/inc/syncReplication.h b/source/libs/sync/inc/syncReplication.h index f2e240344f..a55fd7ead3 100644 --- a/source/libs/sync/inc/syncReplication.h +++ b/source/libs/sync/inc/syncReplication.h @@ -51,7 +51,7 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode); int32_t syncNodeSendHeartbeat(SSyncNode* pSyncNode, const SRaftId* pDestId, SRpcMsg* pMsg); int32_t syncNodeReplicate(SSyncNode* pSyncNode); -int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapshot); +int32_t syncNodeReplicateReset(SSyncNode* pSyncNode, SRaftId* pDestId); int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode); int32_t syncNodeSendAppendEntries(SSyncNode* pNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 8cdf821cff..1d94b288d3 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -48,6 +48,15 @@ int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); +int32_t syncNodeReplicateReset(SSyncNode* pNode, SRaftId* pDestId) { + SSyncLogBuffer* pBuf = pNode->pLogBuf; + taosThreadMutexLock(&pBuf->mutex); + SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(pNode, pDestId); + syncLogReplMgrReset(pMgr); + taosThreadMutexUnlock(&pBuf->mutex); + return 0; +} + int32_t syncNodeReplicate(SSyncNode* pNode) { SSyncLogBuffer* pBuf = pNode->pLogBuf; taosThreadMutexLock(&pBuf->mutex); diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 381327d4d7..413d6adf05 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -992,8 +992,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "process seq end"); snapshotSenderStop(pSender, true); - SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); - syncLogReplMgrReset(pMgr); + syncNodeReplicateReset(pSyncNode, &pMsg->srcId); return 0; } @@ -1018,8 +1017,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { syncLogRecvSyncSnapshotRsp(pSyncNode, pMsg, "receive error ack"); sSError(pSender, "snapshot sender receive error ack:%d, my seq:%d", pMsg->ack, pSender->seq); snapshotSenderStop(pSender, true); - SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); - syncLogReplMgrReset(pMgr); + syncNodeReplicateReset(pSyncNode, &pMsg->srcId); return -1; } @@ -1027,8 +1025,6 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { _ERROR: snapshotSenderStop(pSender, true); - SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); - syncLogReplMgrReset(pMgr); - + syncNodeReplicateReset(pSyncNode, &pMsg->srcId); return -1; } From eca97bf5b49e4f1ceb251a193b877b8873fbd7fc Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 7 Mar 2023 16:44:47 +0800 Subject: [PATCH 05/21] enh: keep extra raft Logs before minimum match index --- source/libs/sync/src/syncMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 9601cd6ab0..04e4859c5e 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -301,7 +301,7 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { syncNodeRelease(pSyncNode); return 0; } - logRetention = TMAX(logRetention, lastApplyIndex - pSyncNode->minMatchIndex); + logRetention = TMAX(logRetention, lastApplyIndex - pSyncNode->minMatchIndex + logRetention); } _DEL_WAL: From a063d698901e1a9f4574c29149b683ffbeaa323f Mon Sep 17 00:00:00 2001 From: cadem Date: Tue, 7 Mar 2023 18:27:26 +0800 Subject: [PATCH 06/21] feat/add-reboot-time --- source/common/src/systable.c | 2 ++ source/dnode/mnode/impl/src/mndDnode.c | 3 +++ source/dnode/mnode/impl/src/mndMnode.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 6198f923f4..4aa47a3819 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -33,6 +33,7 @@ static const SSysDbTableSchema dnodesSchema[] = { {.name = "support_vnodes", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, + {.name = "reboot_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, {.name = "note", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; @@ -42,6 +43,7 @@ static const SSysDbTableSchema mnodesSchema[] = { {.name = "role", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, + {.name = "reboot_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, }; static const SSysDbTableSchema modulesSchema[] = { diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 5dd1742e5e..1d9db37a7d 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -1074,6 +1074,9 @@ static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->createdTime, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pDnode->rebootTime, false); + char *b = taosMemoryCalloc(VARSTR_HEADER_SIZE + strlen(offlineReason[pDnode->offlineReason]) + 1, 1); STR_TO_VARSTR(b, online ? "" : offlineReason[pDnode->offlineReason]); diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index aada00296e..50fab447e3 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -644,6 +644,9 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->stateStartTime, false); + numOfRows++; sdbRelease(pSdb, pObj); } From 89281ee488c01e64c1010260d6566406d966691a Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 7 Mar 2023 21:46:34 +0800 Subject: [PATCH 07/21] compact with time range --- include/common/tmsg.h | 7 ++++--- source/common/src/tmsg.c | 17 ++++++++++++++++- source/dnode/mnode/impl/inc/mndVgroup.h | 3 ++- source/dnode/mnode/impl/src/mndVgroup.c | 16 +++++++++------- source/dnode/vnode/src/inc/vnodeInt.h | 9 ++++----- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 308246df64..eb283d6534 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1291,9 +1291,10 @@ int32_t tSerializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq); int32_t tDeserializeSDropIdxReq(void* buf, int32_t bufLen, SDropIndexReq* pReq); typedef struct { - int64_t dbUid; - char db[TSDB_DB_FNAME_LEN]; - int64_t compactStartTime; + int64_t dbUid; + char db[TSDB_DB_FNAME_LEN]; + int64_t compactStartTime; + STimeWindow tw; } SCompactVnodeReq; int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 5018a517e1..3a9dfa677c 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -4108,6 +4108,11 @@ int32_t tSerializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq * if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeI64(&encoder, pReq->compactStartTime) < 0) return -1; + + // 1.1 add tw.skey and tw.ekey + if (tEncodeI64(&encoder, pReq->tw.skey) < 0) return -1; + if (tEncodeI64(&encoder, pReq->tw.ekey) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -4120,11 +4125,21 @@ int32_t tDeserializeSCompactVnodeReq(void *buf, int32_t bufLen, SCompactVnodeReq tDecoderInit(&decoder, buf, bufLen); if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->db) < 0) return -1; if (tDecodeI64(&decoder, &pReq->compactStartTime) < 0) return -1; - tEndDecode(&decoder); + // 1.1 + if (tDecodeIsEnd(&decoder)) { + pReq->tw.skey = TSKEY_MIN; + pReq->tw.ekey = TSKEY_MAX; + } else { + if (tDecodeI64(&decoder, &pReq->tw.skey) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->tw.ekey) < 0) return -1; + } + + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; } diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index 51eb24f402..0229735952 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -43,7 +43,8 @@ int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVg int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnodeId, bool force); int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup, SArray *pArray); -int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs); +int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs, + STimeWindow tw); void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen); void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index b7bcaf41fd..b5d9353b68 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -2209,11 +2209,12 @@ _OVER: bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid) { return !pVgroup->isTsma && pVgroup->dbUid == dbUid; } -static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen, - int64_t compactTs) { +static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen, int64_t compactTs, + STimeWindow tw) { SCompactVnodeReq compactReq = {0}; compactReq.dbUid = pDb->uid; compactReq.compactStartTime = compactTs; + compactReq.tw = tw; tstrncpy(compactReq.db, pDb->name, TSDB_DB_FNAME_LEN); mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId); @@ -2239,13 +2240,13 @@ static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgrou return pReq; } -static int32_t mndAddCompactVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, - int64_t compactTs) { +static int32_t mndAddCompactVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs, + STimeWindow tw) { STransAction action = {0}; action.epSet = mndGetVgroupEpset(pMnode, pVgroup); int32_t contLen = 0; - void *pReq = mndBuildCompactVnodeReq(pMnode, pDb, pVgroup, &contLen, compactTs); + void *pReq = mndBuildCompactVnodeReq(pMnode, pDb, pVgroup, &contLen, compactTs, tw); if (pReq == NULL) return -1; action.pCont = pReq; @@ -2260,7 +2261,8 @@ static int32_t mndAddCompactVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj * return 0; } -int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs) { - if (mndAddCompactVnodeAction(pMnode, pTrans, pDb, pVgroup, compactTs) != 0) return -1; +int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs, + STimeWindow tw) { + if (mndAddCompactVnodeAction(pMnode, pTrans, pDb, pVgroup, compactTs, tw) != 0) return -1; return 0; } \ No newline at end of file diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index ca61a4dfce..0dff2420ec 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -457,11 +457,10 @@ struct SCommitInfo { }; struct SCompactInfo { - SVnode* pVnode; - int32_t flag; - int64_t commitID; - int64_t stime; - int64_t etime; + SVnode* pVnode; + int32_t flag; + int64_t commitID; + STimeWindow tw; }; #ifdef __cplusplus From f0e23812a168333f12fb46df3c0853955912be55 Mon Sep 17 00:00:00 2001 From: cadem Date: Wed, 8 Mar 2023 09:57:07 +0800 Subject: [PATCH 08/21] fix offline_reason.sim --- tests/script/tsim/dnode/offline_reason.sim | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/script/tsim/dnode/offline_reason.sim b/tests/script/tsim/dnode/offline_reason.sim index 6b1686dbb4..8c4d8b47f7 100644 --- a/tests/script/tsim/dnode/offline_reason.sim +++ b/tests/script/tsim/dnode/offline_reason.sim @@ -8,10 +8,10 @@ sql connect sql create dnode $hostname port 7200 sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode2 off: $data(2)[6] +print dnode1 off: $data(1)[7] +print dnode2 off: $data(2)[7] -if $data(2)[6] != @status not received@ then +if $data(2)[7] != @status not received@ then return -1 endi @@ -50,9 +50,9 @@ step3: return -1 endi sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode2 off: $data(2)[6] -if $data(2)[6] != @status msg timeout@ then +print dnode1 off: $data(1)[7] +print dnode2 off: $data(2)[7] +if $data(2)[7] != @status msg timeout@ then goto step3 endi @@ -77,9 +77,9 @@ step5: endi sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode2 off: $data(3)[6] -if $data(3)[6] != @dnodeId not match@ then +print dnode1 off: $data(1)[7] +print dnode2 off: $data(3)[7] +if $data(3)[7] != @dnodeId not match@ then goto step5 endi @@ -98,10 +98,10 @@ step6: endi sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode2 off: $data(3)[6] -print dnode3 off: $data(4)[6] -if $data(4)[6] != @interval not match@ then +print dnode1 off: $data(1)[7] +print dnode2 off: $data(3)[7] +print dnode3 off: $data(4)[67 +if $data(4)[7] != @interval not match@ then goto step6 endi @@ -120,11 +120,11 @@ step7: endi sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode3 off: $data(3)[6] -print dnode4 off: $data(4)[6] -print dnode5 off: $data(5)[6] -if $data(5)[6] != @locale not match@ then +print dnode1 off: $data(1)[7] +print dnode3 off: $data(3)[7] +print dnode4 off: $data(4)[7] +print dnode5 off: $data(5)[7] +if $data(5)[7] != @locale not match@ then goto step7 endi @@ -143,12 +143,12 @@ step8: endi sql select * from information_schema.ins_dnodes -print dnode1 off: $data(1)[6] -print dnode3 off: $data(3)[6] -print dnode4 off: $data(4)[6] -print dnode5 off: $data(5)[6] -print dnode6 off: $data(6)[6] -if $data(6)[6] != @charset not match@ then +print dnode1 off: $data(1)[7] +print dnode3 off: $data(3)[7] +print dnode4 off: $data(4)[7] +print dnode5 off: $data(5)[7] +print dnode6 off: $data(6)[7] +if $data(6)[7] != @charset not match@ then goto step8 endi From 0dc34018b691719b4a8f4bf0f8b88aff8d331025 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 8 Mar 2023 10:06:48 +0800 Subject: [PATCH 09/21] fix: insert data crash after empty table last cache --- source/dnode/vnode/src/tsdb/tsdbCache.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index c92967f7f4..dcf7286c00 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -375,9 +375,6 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, TSDBROW *row, STsdb SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { - SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); - taosMemoryFree(pLastCol->colVal.value.pData); - lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); if (lastCol.colVal.value.pData == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; From 839758f2d6785409ec1a0daf239255d3a47cbafc Mon Sep 17 00:00:00 2001 From: cademfly Date: Wed, 8 Mar 2023 10:26:28 +0800 Subject: [PATCH 10/21] fix odbc.py total columns numbers --- tests/system-test/2-query/odbc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/2-query/odbc.py b/tests/system-test/2-query/odbc.py index 2325b01c35..832734d4a8 100644 --- a/tests/system-test/2-query/odbc.py +++ b/tests/system-test/2-query/odbc.py @@ -22,7 +22,7 @@ class TDTestCase: tdSql.execute("insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)") tdSql.query("select count(*) from information_schema.ins_columns") - tdSql.checkData(0, 0, 269) + tdSql.checkData(0, 0, 271) tdSql.query("select * from information_schema.ins_columns where table_name = 'ntb'") tdSql.checkRows(14) From a03d9778a61ae193e88bbb8c6ff3d3b431853df1 Mon Sep 17 00:00:00 2001 From: kailixu Date: Wed, 8 Mar 2023 11:03:29 +0800 Subject: [PATCH 11/21] fix: update tfs storage size every 1 second by default --- source/dnode/mgmt/mgmt_vnode/src/vmHandle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 5cf408a905..d7f91b74a8 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -20,6 +20,8 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) { pInfo->pVloads = taosArrayInit(pMgmt->state.totalVnodes, sizeof(SVnodeLoad)); if (pInfo->pVloads == NULL) return; + tfsUpdateSize(pMgmt->pTfs); + taosThreadRwlockRdlock(&pMgmt->lock); void *pIter = taosHashIterate(pMgmt->hash, NULL); From 4a682ebe7ba2e78c74ebf09d4f6d54131d87d8bf Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 8 Mar 2023 14:04:20 +0800 Subject: [PATCH 12/21] feat: taosbenchmark support sample data per child table (#20317) --- cmake/taostools_CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index aecb8a1750..5fe8f6ea13 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG 0111c66 + GIT_TAG d4b3967 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE From 6dcb9c7f0f4908c3980fe02098190db3b377a46c Mon Sep 17 00:00:00 2001 From: cademfly Date: Wed, 8 Mar 2023 14:04:33 +0800 Subject: [PATCH 13/21] trigger ci --- tests/system-test/2-query/odbc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system-test/2-query/odbc.py b/tests/system-test/2-query/odbc.py index 832734d4a8..f26f0abda0 100644 --- a/tests/system-test/2-query/odbc.py +++ b/tests/system-test/2-query/odbc.py @@ -22,7 +22,7 @@ class TDTestCase: tdSql.execute("insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)") tdSql.query("select count(*) from information_schema.ins_columns") - tdSql.checkData(0, 0, 271) + tdSql.checkData(0, 0, 271) tdSql.query("select * from information_schema.ins_columns where table_name = 'ntb'") tdSql.checkRows(14) From 8ca7b91520d8ffb96a6c31f11c68e3abc9a23803 Mon Sep 17 00:00:00 2001 From: t_max <1172915550@qq.com> Date: Wed, 8 Mar 2023 14:31:27 +0800 Subject: [PATCH 14/21] fix(taosAdapter): remove influxdb affected rows check --- cmake/taosadapter_CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 357a79715a..1c401ae80e 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG 97d717d + GIT_TAG d8059ff SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE From c408a434d6a9c90ee3b9eb1aa3e82eb784884d58 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 8 Mar 2023 14:31:38 +0800 Subject: [PATCH 15/21] fix tbname in error --- source/libs/executor/src/executil.c | 2 -- tests/script/tsim/tag/tbNameIn.sim | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 9537751ff0..0ac458af49 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -957,9 +957,7 @@ static int32_t doFilterByTagCond(STableListInfo* pListInfo, SArray* pUidList, SN STUidTagInfo* pInfo = taosArrayGet(pUidTagList, i); taosArrayPush(pUidList, &pInfo->uid); } - terrno = 0; - goto end; } else { if ((condType == FILTER_NO_LOGIC || condType == FILTER_AND) && status != SFLT_NOT_INDEX) { code = metaGetTableTagsByUids(metaHandle, pListInfo->suid, pUidTagList); diff --git a/tests/script/tsim/tag/tbNameIn.sim b/tests/script/tsim/tag/tbNameIn.sim index 1af4bd6a9e..f5119208ba 100644 --- a/tests/script/tsim/tag/tbNameIn.sim +++ b/tests/script/tsim/tag/tbNameIn.sim @@ -99,4 +99,14 @@ if $rows != 7 then return -1 endi +sql select * from st1 where tbname in('tb1') and tbname in ('tb2'); +if $rows != 0 then + return -1 +endi + +sql select * from st1 where tbname in ('tb1') and tbname != 'tb1'; +if $rows != 0 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT From a56c99daac1976b9276593c3dfc54e22e41280f4 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 8 Mar 2023 14:45:04 +0800 Subject: [PATCH 16/21] fix: add more msg check --- source/dnode/vnode/src/vnd/vnodeSvr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 2b275f5122..fc40f81ed5 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -211,6 +211,11 @@ static int32_t vnodePreProcessSubmitMsg(SVnode *pVnode, SRpcMsg *pMsg) { SDecoder *pCoder = &(SDecoder){0}; + if (((SSubmitReq2Msg *)pMsg->pCont)->version != 1) { + code = TSDB_CODE_INVALID_MSG; + TSDB_CHECK_CODE(code, lino, _exit); + } + tDecoderInit(pCoder, (uint8_t *)pMsg->pCont + sizeof(SSubmitReq2Msg), pMsg->contLen - sizeof(SSubmitReq2Msg)); if (tStartDecode(pCoder) < 0) { @@ -1218,6 +1223,11 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq for (int32_t i = 0; i < TARRAY_SIZE(pSubmitReq->aSubmitTbData); ++i) { SSubmitTbData *pSubmitTbData = taosArrayGet(pSubmitReq->aSubmitTbData, i); + if (pSubmitTbData->pCreateTbReq && pSubmitTbData->pCreateTbReq->uid == 0) { + code = TSDB_CODE_INVALID_MSG; + goto _exit; + } + if (pSubmitTbData->flags & SUBMIT_REQ_COLUMN_DATA_FORMAT) { if (TARRAY_SIZE(pSubmitTbData->aCol) <= 0) { code = TSDB_CODE_INVALID_MSG; From 9be3e2027625ece6cfc10419e23898a8ed019265 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 8 Mar 2023 15:13:11 +0800 Subject: [PATCH 17/21] fix: check the compatibility of client version and server version --- include/common/tmsg.h | 1 + include/util/tversion.h | 8 +++-- source/client/src/clientImpl.c | 1 + source/client/src/clientMsgHandler.c | 43 ++++++++++++++---------- source/common/src/tmsg.c | 7 ++++ source/dnode/mnode/impl/src/mndProfile.c | 11 ++++-- source/util/src/tversion.c | 17 ++++++++++ 7 files changed, 65 insertions(+), 23 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 308246df64..75240cef4f 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -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); diff --git a/include/util/tversion.h b/include/util/tversion.h index c924752a01..f5c42b2a22 100644 --- a/include/util/tversion.h +++ b/include/util/tversion.h @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#ifndef _TD_UTIL_VERSION_H_ -#define _TD_UTIL_VERSION_H_ +#ifndef _TD_UTIL_TVERSION_H_ +#define _TD_UTIL_TVERSION_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_TVERSION_H_*/ diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 7bdbc3dc56..70185a1395 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -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); diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index a5f963a956..be1b6b07a3 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -18,10 +18,12 @@ #include "clientLog.h" #include "os.h" #include "query.h" -#include "tdef.h" -#include "tname.h" -#include "tdatablock.h" #include "systable.h" +#include "tdatablock.h" +#include "tdef.h" +#include "tglobal.h" +#include "tname.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; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 5018a517e1..84a09f0fb5 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -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); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 41dc57f32e..0eb891fa1f 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -24,7 +24,7 @@ #include "mndStb.h" #include "mndUser.h" #include "tglobal.h" -#include "version.h" +#include "tversion.h" typedef struct { uint32_t id; @@ -221,8 +221,13 @@ 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; } diff --git a/source/util/src/tversion.c b/source/util/src/tversion.c index c70fdc87a6..dc357c61a1 100644 --- a/source/util/src/tversion.c +++ b/source/util/src/tversion.c @@ -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 From 05688386a0901f4db0a43b008199320a6829aea0 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 8 Mar 2023 15:19:55 +0800 Subject: [PATCH 18/21] little fix --- source/dnode/vnode/src/vnd/vnodeSvr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index fc40f81ed5..fb8d230eba 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -211,7 +211,7 @@ static int32_t vnodePreProcessSubmitMsg(SVnode *pVnode, SRpcMsg *pMsg) { SDecoder *pCoder = &(SDecoder){0}; - if (((SSubmitReq2Msg *)pMsg->pCont)->version != 1) { + if (taosHton64(((SSubmitReq2Msg *)pMsg->pCont)->version) != 1) { code = TSDB_CODE_INVALID_MSG; TSDB_CHECK_CODE(code, lino, _exit); } From 38c9501396387dd8900c473d2b14f6aa0ca787b3 Mon Sep 17 00:00:00 2001 From: Adam Ji Date: Wed, 8 Mar 2023 15:49:19 +0800 Subject: [PATCH 19/21] docs: this line is inaccurate, in current connector-python repo, it require python >= 3.6.2 because there is a dependence iso8601 (#20331) --- docs/zh/08-connector/30-python.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/zh/08-connector/30-python.mdx b/docs/zh/08-connector/30-python.mdx index 1962df9607..b2f2118f39 100644 --- a/docs/zh/08-connector/30-python.mdx +++ b/docs/zh/08-connector/30-python.mdx @@ -32,7 +32,7 @@ Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-con ### 准备 -1. 安装 Python。新近版本 taospy 包要求 Python 3.6+。早期版本 taospy 包要求 Python 3.7+。taos-ws-py 包要求 Python 3.7+。如果系统上还没有 Python 可参考 [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) 安装。 +1. 安装 Python。新近版本 taospy 包要求 Python 3.6.2+。早期版本 taospy 包要求 Python 3.7+。taos-ws-py 包要求 Python 3.7+。如果系统上还没有 Python 可参考 [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) 安装。 2. 安装 [pip](https://pypi.org/project/pip/)。大部分情况下 Python 的安装包都自带了 pip 工具, 如果没有请参考 [pip documentation](https://pip.pypa.io/en/stable/installation/) 安装。 3. 如果使用原生连接,还需[安装客户端驱动](../#安装客户端驱动)。客户端软件包含了 TDengine 客户端动态链接库(libtaos.so 或 taos.dll) 和 TDengine CLI。 From 3db2c59581e6e509b266b43a6fc70ab7a79b3ae3 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 8 Mar 2023 16:10:11 +0800 Subject: [PATCH 20/21] fix: check the compatibility of client version and server version --- source/dnode/mnode/impl/test/profile/profile.cpp | 6 ++++-- source/dnode/mnode/impl/test/show/show.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/dnode/mnode/impl/test/profile/profile.cpp b/source/dnode/mnode/impl/test/profile/profile.cpp index 2ae113e051..6ab6d364cb 100644 --- a/source/dnode/mnode/impl/test/profile/profile.cpp +++ b/source/dnode/mnode/impl/test/profile/profile.cpp @@ -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); diff --git a/source/dnode/mnode/impl/test/show/show.cpp b/source/dnode/mnode/impl/test/show/show.cpp index 0ccefa7ca2..2e67ffa946 100644 --- a/source/dnode/mnode/impl/test/show/show.cpp +++ b/source/dnode/mnode/impl/test/show/show.cpp @@ -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); From 5d80e71d9e52d79369cdd75b524e5522be7324a3 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 8 Mar 2023 16:42:09 +0800 Subject: [PATCH 21/21] fix: check the compatibility of client version and server version --- source/dnode/mnode/impl/src/mndProfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 0eb891fa1f..41dea50731 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -231,6 +231,8 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { 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());