From 0449b5f1bd9f213d3f26d5e9135ee7eff1a34ee0 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 14 Dec 2023 15:43:59 +0800 Subject: [PATCH 1/5] other: add some logs. --- source/dnode/mnode/impl/src/mndStream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index bd67af712a..84133c69ca 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -938,7 +938,8 @@ int64_t mndStreamGenChkpId(SMnode *pMnode) { if (pIter == NULL) break; maxChkpId = TMAX(maxChkpId, pStream->checkpointId); - mDebug("stream %p checkpoint %" PRId64 "", pStream, pStream->checkpointId); + mDebug("stream:%p, %s id:%" PRIx64 "checkpoint %" PRId64 "", pStream, pStream->name, pStream->uid, + pStream->checkpointId); sdbRelease(pSdb, pStream); } From 4758f95708527ef226633636cad5501aad8aa18d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Dec 2023 15:04:55 +0800 Subject: [PATCH 2/5] fix(query): add rows info if blocks exist. --- source/libs/function/src/builtinsimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 93f3b6c109..e82093d07e 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5649,7 +5649,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { len += x; } - if (num > 0) { + if (pData->blockRowsHisto[i] > 0) { double v = pData->blockRowsHisto[i] * 100.0 / pData->numOfBlocks; len += sprintf(st + VARSTR_HEADER_SIZE + len, " %d (%.2f%c)", pData->blockRowsHisto[i], v, '%'); } From bc11b769047686884cd67ccda711b47c48ac07d4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Dec 2023 15:26:44 +0800 Subject: [PATCH 3/5] fix(query): set correct y-axis annotation. --- source/libs/function/src/builtinsimpl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index e82093d07e..8a2e118fe7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5634,7 +5634,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { double factor = pData->numOfBlocks / 80.0; int32_t numOfBuckets = sizeof(pData->blockRowsHisto) / sizeof(pData->blockRowsHisto[0]); - int32_t bucketRange = (pData->defMaxRows - pData->defMinRows) / numOfBuckets; + int32_t bucketRange = ceil(((double) (pData->defMaxRows - pData->defMinRows)) / numOfBuckets); for (int32_t i = 0; i < tListLen(pData->blockRowsHisto); ++i) { len = sprintf(st + VARSTR_HEADER_SIZE, "%04d |", pData->defMinRows + bucketRange * (i + 1)); From e2fa4cba8c0b84b6b5674c08c633e3a68a7a6aac Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Dec 2023 15:28:01 +0800 Subject: [PATCH 4/5] refactor: do some internal refactor. --- source/dnode/vnode/src/tsdb/tsdbRead2.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 52ee6d0b14..4cca39f220 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -4720,14 +4720,13 @@ static int32_t getBucketIndex(int32_t startRow, int32_t bucketRange, int32_t num } int32_t tsdbGetFileBlocksDistInfo2(STsdbReader* pReader, STableBlockDistInfo* pTableBlockInfo) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; + const int32_t numOfBuckets = 20.0; + pTableBlockInfo->totalSize = 0; pTableBlockInfo->totalRows = 0; pTableBlockInfo->numOfVgroups = 1; - const int32_t numOfBuckets = 20.0; - const int32_t defaultRows = 4096; - // find the start data block in file tsdbAcquireReader(pReader); if (pReader->flag == READER_STATUS_SUSPEND) { From aedc5e6b059e56d600f74fe3be5c137df461351d Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 15 Dec 2023 17:16:25 +0800 Subject: [PATCH 5/5] fix(stream): set the correct dst stable name. --- source/dnode/mnode/impl/src/mndStream.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 84133c69ca..a2f9c40c58 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -847,11 +847,12 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { mInfo("trans:%d, used to create stream:%s", pTrans->id, createStreamReq.name); - mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetDb); + mndTransSetDbName(pTrans, createStreamReq.sourceDB, streamObj.targetSTbName); if (mndTransCheckConflict(pMnode, pTrans) != 0) { mndTransDrop(pTrans); goto _OVER; } + // create stb for stream if (createStreamReq.createStb == STREAM_CREATE_STABLE_TRUE && mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) { @@ -1381,12 +1382,12 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { } // check if it is conflict with other trans in both sourceDb and targetDb. - bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); - if (conflict) { - sdbRelease(pMnode->pSdb, pStream); - tFreeMDropStreamReq(&dropReq); - return -1; - } +// bool conflict = streamTransConflictOtherTrans(pMnode, pStream->sourceDb, pStream->targetDb, true); +// if (conflict) { +// sdbRelease(pMnode->pSdb, pStream); +// tFreeMDropStreamReq(&dropReq); +// return -1; +// } STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, MND_STREAM_DROP_NAME); if (pTrans == NULL) {