Merge pull request #27999 from taosdata/enh/TD-31891-mnd-5
remove mndMain.c and mndProfile.c
This commit is contained in:
commit
8b723beeb4
|
@ -176,6 +176,15 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN_WITH_RELEASE(CMD, PTR1, PTR2) \
|
||||
do { \
|
||||
int32_t __c = (CMD); \
|
||||
if (__c != TSDB_CODE_SUCCESS) { \
|
||||
sdbRelease(PTR1, PTR2); \
|
||||
TAOS_RETURN(__c); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN_WITH_FREE(CMD, PTR) \
|
||||
do { \
|
||||
int32_t __c = (CMD); \
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndCluster.h"
|
||||
#include "audit.h"
|
||||
#include "mndCluster.h"
|
||||
#include "mndGrant.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
|
@ -257,7 +257,11 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
if (code != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
mInfo("cluster:%" PRId64 ", will be created when deploying, raw:%p", clusterObj.id, pRaw);
|
||||
|
||||
|
@ -275,7 +279,12 @@ static int32_t mndCreateDefaultCluster(SMnode *pMnode) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
if (code != 0) {
|
||||
sdbFreeRaw(pRaw);
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -317,7 +326,6 @@ static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *
|
|||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
COL_DATA_SET_VAL_GOTO((const char *)&pCluster->createdTime, false, pCluster, _OVER);
|
||||
|
||||
|
||||
char ver[12] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ver, tsVersionName, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -386,7 +394,12 @@ static int32_t mndProcessUptimeTimer(SRpcMsg *pReq) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if (code != 0) {
|
||||
sdbFreeRaw(pCommitRaw);
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
|
|
@ -67,22 +67,28 @@ int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
char tmpBuf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->compactId, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->compactId, false),
|
||||
pSdb, pCompactDetail);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->vgId, false), pSdb,
|
||||
pCompactDetail);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->dnodeId, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->dnodeId, false),
|
||||
pSdb, pCompactDetail);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(
|
||||
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->numberFileset, false), pSdb, pCompactDetail);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->finished, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->finished, false),
|
||||
pSdb, pCompactDetail);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false),
|
||||
pSdb, pCompactDetail);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pCompactDetail);
|
||||
|
@ -302,7 +308,7 @@ int32_t mndAddCompactDetailToTran(SMnode *pMnode, STrans *pTrans, SCompactObj *p
|
|||
if (terrno != 0) code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pVgRaw, SDB_STATUS_READY);
|
||||
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
|
|
@ -621,8 +621,8 @@ static void *mnodeGenTypeStr(char *buf, int32_t buflen, uint8_t type, int32_t le
|
|||
return msg;
|
||||
}
|
||||
|
||||
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_VARBINARY ||
|
||||
type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
if (type == TSDB_DATA_TYPE_NCHAR || type == TSDB_DATA_TYPE_VARBINARY || type == TSDB_DATA_TYPE_BINARY ||
|
||||
type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
int32_t bytes = len > 0 ? (int32_t)(len - VARSTR_HEADER_SIZE) : len;
|
||||
|
||||
(void)snprintf(buf, buflen - 1, "%s(%d)", tDataTypes[type].name, type == TSDB_DATA_TYPE_NCHAR ? bytes / 4 : bytes);
|
||||
|
@ -640,6 +640,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
int32_t numOfRows = 0;
|
||||
SFuncObj *pFunc = NULL;
|
||||
int32_t cols = 0;
|
||||
int32_t code = 0;
|
||||
char buf[TSDB_TYPE_STR_MAX_LEN];
|
||||
|
||||
while (numOfRows < rows) {
|
||||
|
@ -652,40 +653,51 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
STR_WITH_MAXSIZE_TO_VARSTR(b1, pFunc->name, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)b1, false), pSdb, pFunc);
|
||||
|
||||
if (pFunc->pComment) {
|
||||
char *b2 = taosMemoryCalloc(1, pShow->pMeta->pSchemas[cols].bytes);
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b2, pFunc->pComment, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
|
||||
if (code != 0) {
|
||||
sdbRelease(pSdb, pFunc);
|
||||
taosMemoryFree(b2);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
taosMemoryFree(b2);
|
||||
} else {
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, NULL, true);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, NULL, true), pSdb, pFunc);
|
||||
if (code != 0) {
|
||||
sdbRelease(pSdb, pFunc);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t isAgg = (pFunc->funcType == TSDB_FUNC_TYPE_AGGREGATE) ? 1 : 0;
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&isAgg, false);
|
||||
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&isAgg, false), pSdb, pFunc);
|
||||
char b3[TSDB_TYPE_STR_MAX_LEN + 1] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(b3, mnodeGenTypeStr(buf, TSDB_TYPE_STR_MAX_LEN, pFunc->outputType, pFunc->outputLen),
|
||||
pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)b3, false), pSdb, pFunc);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->createdTime, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->createdTime, false), pSdb,
|
||||
pFunc);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->codeSize, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->codeSize, false), pSdb,
|
||||
pFunc);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false), pSdb,
|
||||
pFunc);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
char *language = "";
|
||||
|
@ -697,7 +709,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
char varLang[TSDB_TYPE_STR_MAX_LEN + 1] = {0};
|
||||
varDataSetLen(varLang, strlen(language));
|
||||
strcpy(varDataVal(varLang), language);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false), pSdb, pFunc);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
int32_t varCodeLen = (pFunc->codeSize + VARSTR_HEADER_SIZE) > TSDB_MAX_BINARY_LEN
|
||||
|
@ -706,11 +718,17 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
char *b4 = taosMemoryMalloc(varCodeLen);
|
||||
(void)memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE);
|
||||
varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)b4, false);
|
||||
if (code < 0) {
|
||||
sdbRelease(pSdb, pFunc);
|
||||
taosMemoryFree(b4);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
taosMemoryFree(b4);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false), pSdb,
|
||||
pFunc);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pFunc);
|
||||
|
|
|
@ -85,7 +85,9 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
|
|||
void *pReq = rpcMallocCont(contLen);
|
||||
if (pReq == NULL) return NULL;
|
||||
|
||||
(void)tSerializeSMTimerMsg(pReq, contLen, &timerReq);
|
||||
if (tSerializeSMTimerMsg(pReq, contLen, &timerReq) < 0) {
|
||||
mError("failed to serialize timer msg since %s", terrstr());
|
||||
}
|
||||
*pContLen = contLen;
|
||||
return pReq;
|
||||
}
|
||||
|
@ -97,7 +99,9 @@ static void mndPullupTrans(SMnode *pMnode) {
|
|||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +112,9 @@ static void mndPullupCompacts(SMnode *pMnode) {
|
|||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_COMPACT_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +124,9 @@ static void mndPullupTtl(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TTL_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void mndPullupTrimDb(SMnode *pMnode) {
|
||||
|
@ -127,7 +135,9 @@ static void mndPullupTrimDb(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRIM_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static void mndPullupS3MigrateDb(SMnode *pMnode) {
|
||||
|
@ -136,7 +146,9 @@ static void mndPullupS3MigrateDb(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
// TODO check return value
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_S3MIGRATE_DB_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t mndPullupArbHeartbeat(SMnode *pMnode) {
|
||||
|
@ -160,7 +172,9 @@ static void mndCalMqRebalance(SMnode *pMnode) {
|
|||
void *pReq = mndBuildTimerMsg(&contLen);
|
||||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TMQ_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +184,9 @@ static void mndStreamCheckpointTimer(SMnode *pMnode) {
|
|||
int32_t size = sizeof(SMStreamDoCheckpointMsg);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, .pCont = pMsg, .contLen = size};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +196,9 @@ static void mndStreamCheckNode(SMnode *pMnode) {
|
|||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_NODECHECK_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into read-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,7 +208,9 @@ static void mndStreamConsensusChkpt(SMnode *pMnode) {
|
|||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_CONSEN_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +221,9 @@ static void mndPullupTelem(SMnode *pMnode) {
|
|||
if (pReq != NULL) {
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into read-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,7 +238,9 @@ static void mndPullupGrant(SMnode *pMnode) {
|
|||
.info.notFreeAhandle = 1,
|
||||
.info.ahandle = (void *)0x9527};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +255,9 @@ static void mndIncreaseUpTime(SMnode *pMnode) {
|
|||
.info.notFreeAhandle = 1,
|
||||
.info.ahandle = (void *)0x9527};
|
||||
// TODO check return value
|
||||
(void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg);
|
||||
if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
|
||||
mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -682,7 +708,13 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
|||
}
|
||||
|
||||
char timestr[24] = "1970-01-01 00:00:00.00";
|
||||
(void)taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||
code = taosParseTime(timestr, &pMnode->checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, 0);
|
||||
if (code < 0) {
|
||||
mError("failed to parse time since %s", tstrerror(code));
|
||||
(void)taosThreadRwlockDestroy(&pMnode->lock);
|
||||
taosMemoryFree(pMnode);
|
||||
return NULL;
|
||||
}
|
||||
mndSetOptions(pMnode, pOption);
|
||||
|
||||
pMnode->deploy = pOption->deploy;
|
||||
|
@ -727,10 +759,17 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
|
|||
|
||||
void mndPreClose(SMnode *pMnode) {
|
||||
if (pMnode != NULL) {
|
||||
int32_t code = 0;
|
||||
// TODO check return value
|
||||
(void)syncLeaderTransfer(pMnode->syncMgmt.sync);
|
||||
code = syncLeaderTransfer(pMnode->syncMgmt.sync);
|
||||
if (code < 0) {
|
||||
mError("failed to transfer leader since %s", tstrerror(code));
|
||||
}
|
||||
syncPreStop(pMnode->syncMgmt.sync);
|
||||
(void)sdbWriteFile(pMnode->pSdb, 0);
|
||||
code = sdbWriteFile(pMnode->pSdb, 0);
|
||||
if (code < 0) {
|
||||
mError("failed to write sdb since %s", tstrerror(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -878,7 +917,9 @@ _OVER:
|
|||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||
pMsg->info.rsp = rpcMallocCont(contLen);
|
||||
if (pMsg->info.rsp != NULL) {
|
||||
(void)tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
||||
if (tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet) < 0) {
|
||||
mError("failed to serialize ep set");
|
||||
}
|
||||
pMsg->info.hasEpSet = 1;
|
||||
pMsg->info.rspLen = contLen;
|
||||
}
|
||||
|
@ -1045,7 +1086,12 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
desc.vgroup_id = pVgroup->vgId;
|
||||
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (code < 0) {
|
||||
mError("failed to get db name since %s", tstrerror(code));
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tNameGetDbName(&name, desc.database_name);
|
||||
|
||||
desc.tables_num = pVgroup->numOfTables;
|
||||
|
@ -1083,11 +1129,21 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
|
|||
SMonStbDesc desc = {0};
|
||||
|
||||
SName name1 = {0};
|
||||
(void)tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&name1, pStb->db, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (code < 0) {
|
||||
mError("failed to get db name since %s", tstrerror(code));
|
||||
sdbRelease(pSdb, pStb);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tNameGetDbName(&name1, desc.database_name);
|
||||
|
||||
SName name2 = {0};
|
||||
(void)tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
code = tNameFromString(&name2, pStb->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE);
|
||||
if (code < 0) {
|
||||
mError("failed to get table name since %s", tstrerror(code));
|
||||
sdbRelease(pSdb, pStb);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
tstrncpy(desc.stb_name, tNameGetTableName(&name2), TSDB_TABLE_NAME_LEN);
|
||||
|
||||
if (taosArrayPush(pStbInfo->stbs, &desc) == NULL) {
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndProfile.h"
|
||||
#include "audit.h"
|
||||
#include "mndDb.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndMnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndProfile.h"
|
||||
#include "mndQnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSma.h"
|
||||
|
@ -65,7 +65,7 @@ typedef struct {
|
|||
int64_t ipWhiteListVer;
|
||||
} SConnPreparedObj;
|
||||
|
||||
#define CACHE_OBJ_KEEP_TIME 3 // s
|
||||
#define CACHE_OBJ_KEEP_TIME 3 // s
|
||||
|
||||
static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType, uint32_t ip, uint16_t port,
|
||||
int32_t pid, const char *app, int64_t startTime);
|
||||
|
@ -377,7 +377,8 @@ static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq *pReq)
|
|||
(void)memcpy(&app.summary, &pReq->summary, sizeof(pReq->summary));
|
||||
app.lastAccessTimeMs = taosGetTimestampMs();
|
||||
|
||||
SAppObj *pApp = taosCachePut(pMgmt->appCache, &pReq->appId, sizeof(pReq->appId), &app, sizeof(app), CACHE_OBJ_KEEP_TIME * 1000);
|
||||
SAppObj *pApp =
|
||||
taosCachePut(pMgmt->appCache, &pReq->appId, sizeof(pReq->appId), &app, sizeof(app), CACHE_OBJ_KEEP_TIME * 1000);
|
||||
if (pApp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("failed to app %" PRIx64 " into cache since %s", pReq->appId, terrstr());
|
||||
|
@ -841,6 +842,7 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
int32_t code = 0;
|
||||
SConnObj *pConn = NULL;
|
||||
|
||||
if (pShow->pIter == NULL) {
|
||||
|
@ -863,32 +865,60 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
cols = 0;
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->id, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->id, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set conn id:%u since %s", pConn->id, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(user, pConn->user);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)user, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)user, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set user since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE];
|
||||
STR_TO_VARSTR(app, pConn->app);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)app, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)app, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set app since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->pid, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->pid, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set conn id:%u since %s", pConn->id, tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port);
|
||||
varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)endpoint, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)endpoint, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set endpoint since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->loginTimeMs, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->loginTimeMs, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set login time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->lastAccessTimeMs, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pConn->lastAccessTimeMs, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set last access time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
@ -907,6 +937,7 @@ static int32_t mndRetrieveConns(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl
|
|||
static int32_t packQueriesIntoBlock(SShowObj *pShow, SConnObj *pConn, SSDataBlock *pBlock, uint32_t offset,
|
||||
uint32_t rowsToPack) {
|
||||
int32_t cols = 0;
|
||||
int32_t code = 0;
|
||||
taosRLockLatch(&pConn->queryLock);
|
||||
int32_t numOfQueries = taosArrayGetSize(pConn->pQueries);
|
||||
if (NULL == pConn->pQueries || numOfQueries <= offset) {
|
||||
|
@ -924,47 +955,107 @@ static int32_t packQueriesIntoBlock(SShowObj *pShow, SConnObj *pConn, SSDataBloc
|
|||
(void)sprintf(&queryId[VARSTR_HEADER_SIZE], "%x:%" PRIx64, pConn->id, pQuery->reqRid);
|
||||
varDataLen(queryId) = strlen(&queryId[VARSTR_HEADER_SIZE]);
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)queryId, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)queryId, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set query id:%s since %s", queryId, tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->queryId, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->queryId, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set query id:%" PRIx64 " since %s", pQuery->queryId, tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->id, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->id, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set conn id:%u since %s", pConn->id, tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
char app[TSDB_APP_NAME_LEN + VARSTR_HEADER_SIZE];
|
||||
STR_TO_VARSTR(app, pConn->app);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)app, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)app, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set app since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->pid, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pConn->pid, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set conn id:%u since %s", pConn->id, tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
char user[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(user, pConn->user);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)user, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)user, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set user since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
char endpoint[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)sprintf(&endpoint[VARSTR_HEADER_SIZE], "%s:%d", taosIpStr(pConn->ip), pConn->port);
|
||||
varDataLen(endpoint) = strlen(&endpoint[VARSTR_HEADER_SIZE]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)endpoint, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)endpoint, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set endpoint since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stime, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stime, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set start time since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->useconds, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->useconds, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set useconds since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stableQuery, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->stableQuery, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set stable query since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->isSubQuery, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->isSubQuery, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set sub query since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->subPlanNum, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)&pQuery->subPlanNum, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set sub plan num since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
char subStatus[TSDB_SHOW_SUBQUERY_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
int64_t reserve = 64;
|
||||
|
@ -983,12 +1074,22 @@ static int32_t packQueriesIntoBlock(SShowObj *pShow, SConnObj *pConn, SSDataBloc
|
|||
}
|
||||
varDataLen(subStatus) = strlen(&subStatus[VARSTR_HEADER_SIZE]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, subStatus, (varDataLen(subStatus) == 0) ? true : false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, subStatus, (varDataLen(subStatus) == 0) ? true : false);
|
||||
if (code != 0) {
|
||||
mError("failed to set sub status since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
char sql[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_TO_VARSTR(sql, pQuery->sql);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, curRowIndex, (const char *)sql, false);
|
||||
code = colDataSetVal(pColInfo, curRowIndex, (const char *)sql, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set sql since %s", tstrerror(code));
|
||||
taosRUnLockLatch(&pConn->queryLock);
|
||||
return code;
|
||||
}
|
||||
|
||||
pBlock->info.rows++;
|
||||
}
|
||||
|
@ -1040,6 +1141,7 @@ static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
int32_t numOfRows = 0;
|
||||
int32_t cols = 0;
|
||||
SAppObj *pApp = NULL;
|
||||
int32_t code = 0;
|
||||
|
||||
if (pShow->pIter == NULL) {
|
||||
SProfileMgmt *pMgmt = &pMnode->profileMgmt;
|
||||
|
@ -1057,55 +1159,115 @@ static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
cols = 0;
|
||||
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->appId, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->appId, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set app id since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
char ip[TSDB_IPv4ADDR_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)sprintf(&ip[VARSTR_HEADER_SIZE], "%s", taosIpStr(pApp->ip));
|
||||
varDataLen(ip) = strlen(&ip[VARSTR_HEADER_SIZE]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)ip, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)ip, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set ip since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->pid, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->pid, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set pid since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
char name[TSDB_APP_NAME_LEN + 6 + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)sprintf(&name[VARSTR_HEADER_SIZE], "%s", pApp->name);
|
||||
varDataLen(name) = strlen(&name[VARSTR_HEADER_SIZE]);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)name, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)name, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set app name since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->startTime, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->startTime, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set start time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertsReq, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertsReq, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set insert req since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertRows, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfInsertRows, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set insert rows since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertElapsedTime, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertElapsedTime, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set insert elapsed time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertBytes, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.insertBytes, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set insert bytes since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.fetchBytes, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.fetchBytes, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set fetch bytes since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.queryElapsedTime, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.queryElapsedTime, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set query elapsed time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfSlowQueries, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.numOfSlowQueries, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set slow queries since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.totalRequests, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.totalRequests, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set total requests since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.currentRequests, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->summary.currentRequests, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set current requests since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->lastAccessTimeMs, false);
|
||||
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pApp->lastAccessTimeMs, false);
|
||||
if (code != 0) {
|
||||
mError("failed to set last access time since %s", tstrerror(code));
|
||||
return code;
|
||||
}
|
||||
|
||||
numOfRows++;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndQnode.h"
|
||||
#include "audit.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndQnode.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
#include "audit.h"
|
||||
|
||||
#define QNODE_VER_NUMBER 1
|
||||
#define QNODE_RESERVE_SIZE 64
|
||||
|
@ -209,9 +209,7 @@ int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
bool mndQnodeInDnode(SQnodeObj *pQnode, int32_t dnodeId) {
|
||||
return pQnode->pDnode->id == dnodeId;
|
||||
}
|
||||
bool mndQnodeInDnode(SQnodeObj *pQnode, int32_t dnodeId) { return pQnode->pDnode->id == dnodeId; }
|
||||
|
||||
int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeObj *pObj) {
|
||||
int32_t code = 0;
|
||||
|
@ -224,8 +222,10 @@ int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQnodeOb
|
|||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq);
|
||||
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq);
|
||||
if (code < 0) {
|
||||
mError("qnode:%d, failed to serialize create drop qnode request since %s", createReq.dnodeId, terrstr());
|
||||
}
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
action.pCont = pReq;
|
||||
|
@ -252,7 +252,10 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
if (code < 0) {
|
||||
mError("qnode:%d, failed to serialize create drop qnode request since %s", dropReq.dnodeId, terrstr());
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
|
@ -383,7 +386,10 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
if (code < 0) {
|
||||
mError("qnode:%d, failed to serialize create drop qnode request since %s", dropReq.dnodeId, terrstr());
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
|
@ -536,7 +542,10 @@ static int32_t mndProcessQnodeListReq(SRpcMsg *pReq) {
|
|||
goto _OVER;
|
||||
}
|
||||
|
||||
(void)tSerializeSQnodeListRsp(pRsp, rspLen, &qlistRsp);
|
||||
code = tSerializeSQnodeListRsp(pRsp, rspLen, &qlistRsp);
|
||||
if (code < 0) {
|
||||
mError("failed to serialize qnode list response since %s", terrstr());
|
||||
}
|
||||
|
||||
pReq->info.rspLen = rspLen;
|
||||
pReq->info.rsp = pRsp;
|
||||
|
@ -561,15 +570,16 @@ static int32_t mndRetrieveQnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
|
||||
cols = 0;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false), pSdb, pObj);
|
||||
|
||||
char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)ep, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)ep, false), pSdb, pObj);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false), pSdb,
|
||||
pObj);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pObj);
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "mndSnode.h"
|
||||
#include "mndDnode.h"
|
||||
#include "mndPrivilege.h"
|
||||
#include "mndShow.h"
|
||||
#include "mndSnode.h"
|
||||
#include "mndTrans.h"
|
||||
#include "mndUser.h"
|
||||
|
||||
|
@ -223,7 +223,10 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq);
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &createReq);
|
||||
if (code < 0) {
|
||||
mError("snode:%d, failed to serialize create drop snode request since %s", createReq.dnodeId, terrstr());
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
|
@ -251,7 +254,10 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
if (code < 0) {
|
||||
mError("snode:%d, failed to serialize create drop snode request since %s", dropReq.dnodeId, terrstr());
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
|
@ -320,7 +326,7 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
|
|||
// goto _OVER;
|
||||
// }
|
||||
|
||||
if (sdbGetSize(pMnode->pSdb, SDB_SNODE) >= 1){
|
||||
if (sdbGetSize(pMnode->pSdb, SDB_SNODE) >= 1) {
|
||||
code = TSDB_CODE_MND_SNODE_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
|
@ -340,7 +346,7 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
// mndReleaseSnode(pMnode, pObj);
|
||||
// mndReleaseSnode(pMnode, pObj);
|
||||
mndReleaseDnode(pMnode, pDnode);
|
||||
tFreeSMCreateQnodeReq(&createReq);
|
||||
TAOS_RETURN(code);
|
||||
|
@ -383,7 +389,10 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn
|
|||
code = terrno;
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
(void)tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
code = tSerializeSCreateDropMQSNodeReq(pReq, contLen, &dropReq);
|
||||
if (code < 0) {
|
||||
mError("snode:%d, failed to serialize create drop snode request since %s", dropReq.dnodeId, terrstr());
|
||||
}
|
||||
|
||||
STransAction action = {0};
|
||||
action.epSet = mndGetDnodeEpset(pDnode);
|
||||
|
@ -482,16 +491,17 @@ static int32_t mndRetrieveSnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
|
|||
|
||||
cols = 0;
|
||||
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false), pSdb, pObj);
|
||||
|
||||
char ep[TSDB_EP_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
STR_WITH_MAXSIZE_TO_VARSTR(ep, pObj->pDnode->ep, pShow->pMeta->pSchemas[cols].bytes);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)ep, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)ep, false), pSdb, pObj);
|
||||
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
(void)colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
|
||||
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false), pSdb,
|
||||
pObj);
|
||||
|
||||
numOfRows++;
|
||||
sdbRelease(pSdb, pObj);
|
||||
|
|
|
@ -220,14 +220,18 @@ _OVER:
|
|||
TAOS_RETURN(code);
|
||||
}
|
||||
int32_t ipWhiteMgtRemove(char *user) {
|
||||
bool update = true;
|
||||
bool update = true;
|
||||
int32_t code = 0;
|
||||
(void)taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
if (ppList == NULL || *ppList == NULL) {
|
||||
update = false;
|
||||
} else {
|
||||
taosMemoryFree(*ppList);
|
||||
(void)taosHashRemove(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
code = taosHashRemove(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||
if (code != 0) {
|
||||
update = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (update) ipWhiteMgt.ver++;
|
||||
|
@ -391,7 +395,9 @@ int32_t mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8
|
|||
if (pList != NULL) {
|
||||
if (isRangeInWhiteList(pList, &range)) {
|
||||
if (pList->num == 1) {
|
||||
(void)taosHashRemove(pIpWhiteTab, user, strlen(user));
|
||||
if (taosHashRemove(pIpWhiteTab, user, strlen(user)) < 0) {
|
||||
mError("failed to remove ip-white-list for user: %s at line %d", user, lino);
|
||||
}
|
||||
taosMemoryFree(pList);
|
||||
} else {
|
||||
int32_t idx = 0;
|
||||
|
@ -842,6 +848,7 @@ static int32_t createDefaultIpWhiteList(SIpWhiteList **ppWhiteList) {
|
|||
|
||||
static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char *pass) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SUserObj userObj = {0};
|
||||
taosEncryptPass_c((uint8_t *)pass, strlen(pass), userObj.pass);
|
||||
tstrncpy(userObj.user, user, TSDB_USER_LEN);
|
||||
|
@ -859,7 +866,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
|
|||
|
||||
SSdbRaw *pRaw = mndUserActionEncode(&userObj);
|
||||
if (pRaw == NULL) goto _ERROR;
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), &lino, _ERROR);
|
||||
|
||||
mInfo("user:%s, will be created when deploying, raw:%p", userObj.user, pRaw);
|
||||
|
||||
|
@ -876,7 +883,7 @@ static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char
|
|||
mndTransDrop(pTrans);
|
||||
goto _ERROR;
|
||||
}
|
||||
(void)sdbSetRawStatus(pRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pRaw, SDB_STATUS_READY), &lino, _ERROR);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -1775,7 +1782,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, &lino, _OVER);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY), &lino, _OVER);
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -1990,7 +1997,11 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if (code < 0) {
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -2189,7 +2200,10 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
|||
mndReleaseDb(pMnode, pDb);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code
|
||||
}
|
||||
(void)taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len);
|
||||
code = taosHashRemove(pNewUser->readDbs, pAlterReq->objname, len);
|
||||
if (code < 0) {
|
||||
mError("read db:%s, failed to remove db:%s since %s", pNewUser->user, pAlterReq->objname, terrstr());
|
||||
}
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
} else {
|
||||
taosHashClear(pNewUser->readDbs);
|
||||
|
@ -2205,7 +2219,10 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
|||
mndReleaseDb(pMnode, pDb);
|
||||
TAOS_CHECK_GOTO(terrno, &lino, _OVER); // TODO: refactor the terrno to code
|
||||
}
|
||||
(void)taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len);
|
||||
code = taosHashRemove(pNewUser->writeDbs, pAlterReq->objname, len);
|
||||
if (code < 0) {
|
||||
mError("user:%s, failed to remove db:%s since %s", pNewUser->user, pAlterReq->objname, terrstr());
|
||||
}
|
||||
mndReleaseDb(pMnode, pDb);
|
||||
} else {
|
||||
taosHashClear(pNewUser->writeDbs);
|
||||
|
@ -2275,7 +2292,10 @@ static int32_t mndProcessAlterUserPrivilegesReq(SAlterUserReq *pAlterReq, SMnode
|
|||
mndReleaseTopic(pMnode, pTopic);
|
||||
TAOS_CHECK_GOTO(code, &lino, _OVER);
|
||||
}
|
||||
(void)taosHashRemove(pNewUser->topics, pAlterReq->objname, len);
|
||||
code = taosHashRemove(pNewUser->topics, pAlterReq->objname, len);
|
||||
if (code < 0) {
|
||||
mError("user:%s, failed to remove topic:%s since %s", pNewUser->user, pAlterReq->objname, tstrerror(code));
|
||||
}
|
||||
mndReleaseTopic(pMnode, pTopic);
|
||||
}
|
||||
|
||||
|
@ -2461,7 +2481,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
ALTER_USER_ADD_ALL_TB_PRIV(alterReq.alterType, alterReq.privileges, alterReq.tabName)) {
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
TAOS_CHECK_GOTO(tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB), &lino, _OVER);
|
||||
auditRecord(pReq, pMnode->clusterId, "GrantPrivileges", name.dbname, alterReq.user, alterReq.sql,
|
||||
alterReq.sqlLen);
|
||||
} else {
|
||||
|
@ -2476,7 +2496,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
|
|||
} else {
|
||||
if (strcmp(alterReq.objname, "1.*") != 0) {
|
||||
SName name = {0};
|
||||
(void)tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB);
|
||||
TAOS_CHECK_GOTO(tNameFromString(&name, alterReq.objname, T_NAME_ACCT | T_NAME_DB), &lino, _OVER);
|
||||
auditRecord(pReq, pMnode->clusterId, "RevokePrivileges", name.dbname, alterReq.user, alterReq.sql,
|
||||
alterReq.sqlLen);
|
||||
} else {
|
||||
|
@ -2511,7 +2531,10 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) {
|
|||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED);
|
||||
if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) < 0) {
|
||||
mndTransDrop(pTrans);
|
||||
TAOS_RETURN(terrno);
|
||||
}
|
||||
|
||||
if (mndTransPrepare(pMnode, pTrans) != 0) {
|
||||
mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr());
|
||||
|
@ -2982,7 +3005,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
|
||||
SName name = {0};
|
||||
char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
code = tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
if (code < 0) {
|
||||
sdbRelease(pSdb, pUser);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
(void)tNameGetDbName(&name, varDataVal(objName));
|
||||
varDataSetLen(objName, strlen(varDataVal(objName)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -3026,7 +3053,11 @@ static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock
|
|||
|
||||
SName name = {0};
|
||||
char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
(void)tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
code = tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB);
|
||||
if (code < 0) {
|
||||
sdbRelease(pSdb, pUser);
|
||||
TAOS_CHECK_GOTO(code, &lino, _exit);
|
||||
}
|
||||
(void)tNameGetDbName(&name, varDataVal(objName));
|
||||
varDataSetLen(objName, strlen(varDataVal(objName)));
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
|
@ -3213,6 +3244,7 @@ _OVER:
|
|||
|
||||
int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db) {
|
||||
int32_t code = 0;
|
||||
int32_t lino = 0;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
int32_t len = strlen(db) + 1;
|
||||
void *pIter = NULL;
|
||||
|
@ -3230,15 +3262,21 @@ int32_t mndUserRemoveDb(SMnode *pMnode, STrans *pTrans, char *db) {
|
|||
bool inRead = (taosHashGet(newUser.readDbs, db, len) != NULL);
|
||||
bool inWrite = (taosHashGet(newUser.writeDbs, db, len) != NULL);
|
||||
if (inRead || inWrite) {
|
||||
(void)taosHashRemove(newUser.readDbs, db, len);
|
||||
(void)taosHashRemove(newUser.writeDbs, db, len);
|
||||
code = taosHashRemove(newUser.readDbs, db, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove readDbs:%s from user:%s", db, pUser->user);
|
||||
}
|
||||
code = taosHashRemove(newUser.writeDbs, db, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove writeDbs:%s from user:%s", db, pUser->user);
|
||||
}
|
||||
|
||||
SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser);
|
||||
if (pCommitRaw == NULL || (code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
TAOS_CHECK_GOTO(sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY), &lino, _OVER);
|
||||
}
|
||||
|
||||
mndUserFreeObj(&newUser);
|
||||
|
@ -3272,16 +3310,30 @@ int32_t mndUserRemoveStb(SMnode *pMnode, STrans *pTrans, char *stb) {
|
|||
bool inWrite = (taosHashGet(newUser.writeTbs, stb, len) != NULL);
|
||||
bool inAlter = (taosHashGet(newUser.alterTbs, stb, len) != NULL);
|
||||
if (inRead || inWrite || inAlter) {
|
||||
(void)taosHashRemove(newUser.readTbs, stb, len);
|
||||
(void)taosHashRemove(newUser.writeTbs, stb, len);
|
||||
(void)taosHashRemove(newUser.alterTbs, stb, len);
|
||||
code = taosHashRemove(newUser.readTbs, stb, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove readTbs:%s from user:%s", stb, pUser->user);
|
||||
}
|
||||
code = taosHashRemove(newUser.writeTbs, stb, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove writeTbs:%s from user:%s", stb, pUser->user);
|
||||
}
|
||||
code = taosHashRemove(newUser.alterTbs, stb, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove alterTbs:%s from user:%s", stb, pUser->user);
|
||||
}
|
||||
|
||||
SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser);
|
||||
if (pCommitRaw == NULL || (code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if (code != 0) {
|
||||
mndUserFreeObj(&newUser);
|
||||
sdbRelease(pSdb, pUser);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
|
||||
mndUserFreeObj(&newUser);
|
||||
|
@ -3314,16 +3366,30 @@ int32_t mndUserRemoveView(SMnode *pMnode, STrans *pTrans, char *view) {
|
|||
bool inWrite = (taosHashGet(newUser.writeViews, view, len) != NULL);
|
||||
bool inAlter = (taosHashGet(newUser.alterViews, view, len) != NULL);
|
||||
if (inRead || inWrite || inAlter) {
|
||||
(void)taosHashRemove(newUser.readViews, view, len);
|
||||
(void)taosHashRemove(newUser.writeViews, view, len);
|
||||
(void)taosHashRemove(newUser.alterViews, view, len);
|
||||
code = taosHashRemove(newUser.readViews, view, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove readViews:%s from user:%s", view, pUser->user);
|
||||
}
|
||||
code = taosHashRemove(newUser.writeViews, view, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove writeViews:%s from user:%s", view, pUser->user);
|
||||
}
|
||||
code = taosHashRemove(newUser.alterViews, view, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove alterViews:%s from user:%s", view, pUser->user);
|
||||
}
|
||||
|
||||
SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser);
|
||||
if (pCommitRaw == NULL || (code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if (code < 0) {
|
||||
mndUserFreeObj(&newUser);
|
||||
sdbRelease(pSdb, pUser);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
|
||||
mndUserFreeObj(&newUser);
|
||||
|
@ -3356,13 +3422,21 @@ int32_t mndUserRemoveTopic(SMnode *pMnode, STrans *pTrans, char *topic) {
|
|||
|
||||
bool inTopic = (taosHashGet(newUser.topics, topic, len) != NULL);
|
||||
if (inTopic) {
|
||||
(void)taosHashRemove(newUser.topics, topic, len);
|
||||
code = taosHashRemove(newUser.topics, topic, len);
|
||||
if (code < 0) {
|
||||
mError("failed to remove topic:%s from user:%s", topic, pUser->user);
|
||||
}
|
||||
SSdbRaw *pCommitRaw = mndUserActionEncode(&newUser);
|
||||
if (pCommitRaw == NULL || (code = mndTransAppendCommitlog(pTrans, pCommitRaw)) != 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
(void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY);
|
||||
if (code < 0) {
|
||||
mndUserFreeObj(&newUser);
|
||||
sdbRelease(pSdb, pUser);
|
||||
TAOS_RETURN(code);
|
||||
}
|
||||
}
|
||||
|
||||
mndUserFreeObj(&newUser);
|
||||
|
|
Loading…
Reference in New Issue