Merge pull request #26832 from taosdata/fix/TD-30989-scan1-7
fix/TD-30989-scan1-7
This commit is contained in:
commit
44bb1f53da
|
@ -70,16 +70,16 @@ static void mndBuildRuntimeInfo(SMnode* pMnode, SJson* pJson) {
|
|||
SMnodeStat mstat = {0};
|
||||
mndGetStat(pMnode, &mstat);
|
||||
|
||||
tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode);
|
||||
tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode);
|
||||
tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup);
|
||||
tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase);
|
||||
tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable);
|
||||
tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable);
|
||||
tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn);
|
||||
tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints);
|
||||
tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage);
|
||||
tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfDnode", mstat.numOfDnode);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfMnode", mstat.numOfMnode);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfVgroup", mstat.numOfVgroup);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfDatabase", mstat.numOfDatabase);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfSuperTable", mstat.numOfSuperTable);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfChildTable", mstat.numOfChildTable);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfColumn", mstat.numOfColumn);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfPoint", mstat.totalPoints);
|
||||
(void)tjsonAddDoubleToObject(pJson, "totalStorage", mstat.totalStorage);
|
||||
(void)tjsonAddDoubleToObject(pJson, "compStorage", mstat.compStorage);
|
||||
}
|
||||
|
||||
static char* mndBuildTelemetryReport(SMnode* pMnode) {
|
||||
|
@ -90,29 +90,29 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
|
|||
if (pJson == NULL) return NULL;
|
||||
|
||||
char clusterName[64] = {0};
|
||||
mndGetClusterName(pMnode, clusterName, sizeof(clusterName));
|
||||
tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||
tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||
if ((terrno = mndGetClusterName(pMnode, clusterName, sizeof(clusterName))) != 0) return NULL;
|
||||
(void)tjsonAddStringToObject(pJson, "instanceId", clusterName);
|
||||
(void)tjsonAddDoubleToObject(pJson, "reportVersion", 1);
|
||||
|
||||
if (taosGetOsReleaseName(tmp, NULL, NULL, sizeof(tmp)) == 0) {
|
||||
tjsonAddStringToObject(pJson, "os", tmp);
|
||||
(void)tjsonAddStringToObject(pJson, "os", tmp);
|
||||
}
|
||||
|
||||
float numOfCores = 0;
|
||||
if (taosGetCpuInfo(tmp, sizeof(tmp), &numOfCores) == 0) {
|
||||
tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
||||
tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
||||
(void)tjsonAddStringToObject(pJson, "cpuModel", tmp);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfCpu", numOfCores);
|
||||
} else {
|
||||
tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores);
|
||||
(void)tjsonAddDoubleToObject(pJson, "numOfCpu", tsNumOfCores);
|
||||
}
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%" PRId64 " kB", tsTotalMemoryKB);
|
||||
tjsonAddStringToObject(pJson, "memory", tmp);
|
||||
(void)tjsonAddStringToObject(pJson, "memory", tmp);
|
||||
|
||||
tjsonAddStringToObject(pJson, "version", version);
|
||||
tjsonAddStringToObject(pJson, "buildInfo", buildinfo);
|
||||
tjsonAddStringToObject(pJson, "gitInfo", gitinfo);
|
||||
tjsonAddStringToObject(pJson, "email", pMgmt->email);
|
||||
(void)tjsonAddStringToObject(pJson, "version", version);
|
||||
(void)tjsonAddStringToObject(pJson, "buildInfo", buildinfo);
|
||||
(void)tjsonAddStringToObject(pJson, "gitInfo", gitinfo);
|
||||
(void)tjsonAddStringToObject(pJson, "email", pMgmt->email);
|
||||
|
||||
mndBuildRuntimeInfo(pMnode, pJson);
|
||||
|
||||
|
@ -126,9 +126,9 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
|||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
if (!tsEnableTelem) return 0;
|
||||
|
||||
taosThreadMutexLock(&pMgmt->lock);
|
||||
(void)taosThreadMutexLock(&pMgmt->lock);
|
||||
char* pCont = mndBuildTelemetryReport(pMnode);
|
||||
taosThreadMutexUnlock(&pMgmt->lock);
|
||||
(void)taosThreadMutexUnlock(&pMgmt->lock);
|
||||
|
||||
if (pCont != NULL) {
|
||||
if (taosSendHttpReport(tsTelemServer, tsTelemUri, tsTelemPort, pCont, strlen(pCont), HTTP_FLAT) != 0) {
|
||||
|
@ -142,10 +142,12 @@ static int32_t mndProcessTelemTimer(SRpcMsg* pReq) {
|
|||
}
|
||||
|
||||
int32_t mndInitTelem(SMnode* pMnode) {
|
||||
int32_t code = 0;
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
|
||||
taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||
taosGetEmail(pMgmt->email, sizeof(pMgmt->email));
|
||||
(void)taosThreadMutexInit(&pMgmt->lock, NULL);
|
||||
if ((code = taosGetEmail(pMgmt->email, sizeof(pMgmt->email))) != 0)
|
||||
mWarn("failed to get email since %s", tstrerror(code));
|
||||
mndSetMsgHandle(pMnode, TDMT_MND_TELEM_TIMER, mndProcessTelemTimer);
|
||||
|
||||
return 0;
|
||||
|
@ -153,5 +155,5 @@ int32_t mndInitTelem(SMnode* pMnode) {
|
|||
|
||||
void mndCleanupTelem(SMnode* pMnode) {
|
||||
STelemMgmt* pMgmt = &pMnode->telemMgmt;
|
||||
taosThreadMutexDestroy(&pMgmt->lock);
|
||||
(void)taosThreadMutexDestroy(&pMgmt->lock);
|
||||
}
|
||||
|
|
|
@ -376,7 +376,7 @@ SSdbRow *mndTransDecode(SSdbRaw *pRaw) {
|
|||
for (int32_t i = 0; i < arbgroupIdNum; ++i) {
|
||||
int32_t arbGroupId = 0;
|
||||
SDB_GET_INT32(pRaw, dataPos, &arbGroupId, _OVER)
|
||||
taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0);
|
||||
if ((terrno = taosHashPut(pTrans->arbGroupIds, &arbGroupId, sizeof(int32_t), NULL, 0)) != 0) goto _OVER;
|
||||
}
|
||||
|
||||
SDB_GET_RESERVE(pRaw, dataPos, TRANS_RESERVE_SIZE, _OVER)
|
||||
|
@ -461,7 +461,7 @@ static int32_t mndTransActionInsert(SSdb *pSdb, STrans *pTrans) {
|
|||
mInfo("trans:%d, perform insert action, row:%p stage:%s, callfunc:1, startFunc:%d", pTrans->id, pTrans,
|
||||
mndTransStr(pTrans->stage), pTrans->startFunc);
|
||||
|
||||
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
|
||||
if (pTrans->startFunc > 0) {
|
||||
TransCbFp fp = mndTransGetCbFp(pTrans->startFunc);
|
||||
|
@ -616,7 +616,7 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
pTrans->pRpcArray = taosArrayInit(1, sizeof(SRpcHandleInfo));
|
||||
pTrans->mTraceId = pReq ? TRACE_GET_ROOTID(&pReq->info.traceId) : tGenIdPI64();
|
||||
taosInitRWLatch(&pTrans->lockRpcArray);
|
||||
taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
(void)taosThreadMutexInit(&pTrans->mutex, NULL);
|
||||
|
||||
if (pTrans->redoActions == NULL || pTrans->undoActions == NULL || pTrans->commitActions == NULL ||
|
||||
pTrans->pRpcArray == NULL) {
|
||||
|
@ -627,7 +627,10 @@ STrans *mndTransCreate(SMnode *pMnode, ETrnPolicy policy, ETrnConflct conflict,
|
|||
}
|
||||
|
||||
if (pReq != NULL) {
|
||||
taosArrayPush(pTrans->pRpcArray, &pReq->info);
|
||||
if (taosArrayPush(pTrans->pRpcArray, &pReq->info) == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return NULL;
|
||||
}
|
||||
pTrans->originRpcType = pReq->msgType;
|
||||
}
|
||||
|
||||
|
@ -765,7 +768,7 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname)
|
|||
}
|
||||
|
||||
void mndTransAddArbGroupId(STrans *pTrans, int32_t groupId) {
|
||||
taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0);
|
||||
(void)taosHashPut(pTrans->arbGroupIds, &groupId, sizeof(int32_t), NULL, 0);
|
||||
}
|
||||
|
||||
void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; }
|
||||
|
@ -1505,9 +1508,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
pTrans->actionPos++;
|
||||
mInfo("trans:%d, %s:%d is executed and need sync to other mnodes", pTrans->id, mndTransStr(pAction->stage),
|
||||
pAction->id);
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
code = mndTransSync(pMnode, pTrans);
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (code != 0) {
|
||||
pTrans->actionPos--;
|
||||
pTrans->code = terrno;
|
||||
|
@ -1540,21 +1543,21 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
|
|||
|
||||
static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||
int32_t code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (pTrans->stage == TRN_STAGE_REDO_ACTION) {
|
||||
code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->redoActions, topHalf);
|
||||
}
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans, bool topHalf) {
|
||||
int32_t code = TSDB_CODE_ACTION_IN_PROGRESS;
|
||||
taosThreadMutexLock(&pTrans->mutex);
|
||||
(void)taosThreadMutexLock(&pTrans->mutex);
|
||||
if (pTrans->stage == TRN_STAGE_UNDO_ACTION) {
|
||||
code = mndTransExecuteActionsSerial(pMnode, pTrans, pTrans->undoActions, topHalf);
|
||||
}
|
||||
taosThreadMutexUnlock(&pTrans->mutex);
|
||||
(void)taosThreadMutexUnlock(&pTrans->mutex);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -1894,7 +1897,7 @@ void mndTransPullup(SMnode *pMnode) {
|
|||
STrans *pTrans = NULL;
|
||||
pIter = sdbFetch(pMnode->pSdb, SDB_TRANS, pIter, (void **)&pTrans);
|
||||
if (pIter == NULL) break;
|
||||
taosArrayPush(pArray, &pTrans->id);
|
||||
(void)taosArrayPush(pArray, &pTrans->id);
|
||||
sdbRelease(pSdb, pTrans);
|
||||
}
|
||||
|
||||
|
@ -1925,36 +1928,36 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
cols = 0;
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->id, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->createdTime, false);
|
||||
|
||||
char stage[TSDB_TRANS_STAGE_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stage, mndTransStr(pTrans->stage), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)stage, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stage, false);
|
||||
|
||||
char opername[TSDB_TRANS_OPER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(opername, pTrans->opername, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)opername, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)opername, false);
|
||||
|
||||
char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pTrans->dbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false);
|
||||
|
||||
char stbname[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(stbname, mndGetDbStr(pTrans->stbname), pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)stbname, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->failedTimes, false);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pTrans->lastExecTime, false);
|
||||
|
||||
char lastInfo[TSDB_TRANS_ERROR_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
char detail[TSDB_TRANS_ERROR_LEN + 1] = {0};
|
||||
|
@ -1970,7 +1973,7 @@ static int32_t mndRetrieveTrans(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
}
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(lastInfo, detail, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)lastInfo, false);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pTrans);
|
||||
|
|
Loading…
Reference in New Issue