Fix some review errors.

This commit is contained in:
xiao-77 2024-12-10 14:07:31 +08:00
parent 2e1b94ff87
commit 430cf9a806
2 changed files with 18 additions and 27 deletions

View File

@ -51,10 +51,7 @@ static void *dmConfigThreadFp(void *param) {
SDnodeMgmt *pMgmt = param; SDnodeMgmt *pMgmt = param;
int64_t lastTime = taosGetTimestampMs(); int64_t lastTime = taosGetTimestampMs();
setThreadName("dnode-config"); setThreadName("dnode-config");
int32_t upTimeCount = 0; int32_t upTimeCount = 0;
int64_t upTime = 0;
while (1) { while (1) {
taosMsleep(200); taosMsleep(200);
if (pMgmt->pData->dropped || pMgmt->pData->stopped || tsConfigInited) break; if (pMgmt->pData->dropped || pMgmt->pData->stopped || tsConfigInited) break;
@ -64,15 +61,8 @@ static void *dmConfigThreadFp(void *param) {
float interval = (curTime - lastTime) / 1000.0f; float interval = (curTime - lastTime) / 1000.0f;
if (interval >= tsStatusInterval) { if (interval >= tsStatusInterval) {
dmSendConfigReq(pMgmt); dmSendConfigReq(pMgmt);
lastTime = curTime;
if ((upTimeCount = ((upTimeCount + 1) & 63)) == 0) {
upTime = taosGetOsUptime() - tsDndStartOsUptime;
tsDndUpTime = TMAX(tsDndUpTime, upTime);
}
} }
} }
return NULL; return NULL;
} }

View File

@ -490,15 +490,14 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
SMCfgDnodeReq cfgReq = {0}; SMCfgDnodeReq cfgReq = {0};
SConfigObj *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion"); SConfigObj *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
if (vObj == NULL) { if (vObj == NULL) {
mInfo("failed to acquire mnd config version, since %s", terrstr()); goto _err_out;
TAOS_RETURN(terrno);
} }
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq)); TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
int8_t updateIpWhiteList = 0; int8_t updateIpWhiteList = 0;
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value); mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) { if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
tFreeSMCfgDnodeReq(&cfgReq); goto _err_out;
TAOS_RETURN(code);
} }
SDCfgDnodeReq dcfgReq = {0}; SDCfgDnodeReq dcfgReq = {0};
@ -511,19 +510,17 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
int32_t flag = -1; int32_t flag = -1;
int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag); int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag);
if (code < 0) { if (code < 0) {
tFreeSMCfgDnodeReq(&cfgReq); goto _err_out;
TAOS_RETURN(code);
} }
if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) { if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) {
mError("dnode:%d, failed to config s3blocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]", mError("dnode:%d, failed to config s3blocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]",
cfgReq.dnodeId, flag); cfgReq.dnodeId, flag);
code = TSDB_CODE_INVALID_CFG; code = TSDB_CODE_INVALID_CFG;
tFreeSMCfgDnodeReq(&cfgReq); goto _err_out;
TAOS_RETURN(code);
} }
strcpy(dcfgReq.config, "s3blocksize"); tstrncpy(dcfgReq.config, "s3blocksize", 11);
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag); snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
#endif #endif
} else { } else {
@ -560,18 +557,22 @@ _send_req :
auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen); auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen);
} }
tFreeSMCfgDnodeReq(&cfgReq);
dcfgReq.version = vObj->i32; dcfgReq.version = vObj->i32;
code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq); code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
if (code != 0) {
mError("failed to send config req to dnode:%d, since %s", cfgReq.dnodeId, tstrerror(code));
goto _err_out;
}
// dont care suss or succ; // dont care suss or succ;
if (updateIpWhiteList) mndRefreshUserIpWhiteList(pMnode); if (updateIpWhiteList) mndRefreshUserIpWhiteList(pMnode);
tFreeSMCfgDnodeReq(&cfgReq);
sdbRelease(pMnode->pSdb, vObj);
TAOS_RETURN(code); TAOS_RETURN(code);
_err_out: _err_out:
mError("failed to process config dnode req, since %s", tstrerror(code));
tFreeSMCfgDnodeReq(&cfgReq); tFreeSMCfgDnodeReq(&cfgReq);
sdbRelease(pMnode->pSdb, vObj);
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -600,8 +601,7 @@ static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32
TAOS_RETURN(code); TAOS_RETURN(code);
_err: _err:
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config); mError(" failed to set config since:%s", tstrerror(code));
code = TSDB_CODE_INVALID_CFG;
TAOS_RETURN(code); TAOS_RETURN(code);
} }
@ -658,6 +658,7 @@ static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array) {
item.name = taosStrdup(obj->name); item.name = taosStrdup(obj->name);
if (item.name == NULL) { if (item.name == NULL) {
code = terrno; code = terrno;
sdbCancelFetch(pSdb, pIter);
goto _exit; goto _exit;
} }
switch (obj->dtype) { switch (obj->dtype) {
@ -683,12 +684,14 @@ static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array) {
case CFG_DTYPE_TIMEZONE: case CFG_DTYPE_TIMEZONE:
item.str = taosStrdup(obj->str); item.str = taosStrdup(obj->str);
if (item.str == NULL) { if (item.str == NULL) {
sdbCancelFetch(pSdb, pIter);
code = terrno; code = terrno;
goto _exit; goto _exit;
} }
break; break;
} }
if (taosArrayPush(array, &item) == NULL) { if (taosArrayPush(array, &item) == NULL) {
sdbCancelFetch(pSdb, pIter);
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit; goto _exit;
break; break;
@ -698,8 +701,6 @@ static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array) {
_exit: _exit:
if (code != 0) { if (code != 0) {
mError("failed to init config array from sdb, since %s", tstrerror(code)); mError("failed to init config array from sdb, since %s", tstrerror(code));
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, obj);
} }
return code; return code;
} }