Merge pull request #29527 from taosdata/fix/main/TD-33457
Test(cfg): add alter config to compatibility.py and fix some memory leak.
This commit is contained in:
commit
74c7420c1d
|
@ -330,8 +330,8 @@ typedef struct {
|
||||||
|
|
||||||
int32_t tEncodeSConfigObj(SEncoder* pEncoder, const SConfigObj* pObj);
|
int32_t tEncodeSConfigObj(SEncoder* pEncoder, const SConfigObj* pObj);
|
||||||
int32_t tDecodeSConfigObj(SDecoder* pDecoder, SConfigObj* pObj);
|
int32_t tDecodeSConfigObj(SDecoder* pDecoder, SConfigObj* pObj);
|
||||||
SConfigObj* mndInitConfigObj(SConfigItem* pItem);
|
int32_t mndInitConfigObj(SConfigItem* pItem, SConfigObj* pObj);
|
||||||
SConfigObj* mndInitConfigVersion();
|
SConfigObj mndInitConfigVersion();
|
||||||
int32_t mndUpdateObj(SConfigObj* pObj, const char* name, char* value);
|
int32_t mndUpdateObj(SConfigObj* pObj, const char* name, char* value);
|
||||||
void tFreeSConfigObj(SConfigObj* obj);
|
void tFreeSConfigObj(SConfigObj* obj);
|
||||||
|
|
||||||
|
|
|
@ -308,32 +308,27 @@ int32_t mndInitWriteCfg(SMnode *pMnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// encode mnd config version
|
// encode mnd config version
|
||||||
SConfigObj *versionObj = mndInitConfigVersion();
|
SConfigObj versionObj = mndInitConfigVersion();
|
||||||
if ((code = mndSetCreateConfigCommitLogs(pTrans, versionObj)) != 0) {
|
if ((code = mndSetCreateConfigCommitLogs(pTrans, &versionObj)) != 0) {
|
||||||
mError("failed to init mnd config version, since %s", tstrerror(code));
|
mError("failed to init mnd config version, since %s", tstrerror(code));
|
||||||
tFreeSConfigObj(versionObj);
|
tFreeSConfigObj(&versionObj);
|
||||||
taosMemoryFree(versionObj);
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
tFreeSConfigObj(versionObj);
|
tFreeSConfigObj(&versionObj);
|
||||||
taosMemoryFree(versionObj);
|
|
||||||
sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
|
sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
|
||||||
|
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
|
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
|
||||||
SConfigObj *obj = mndInitConfigObj(item);
|
SConfigObj obj;
|
||||||
if (obj == NULL) {
|
if ((code = mndInitConfigObj(item, &obj)) != 0) {
|
||||||
code = terrno;
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
if ((code = mndSetCreateConfigCommitLogs(pTrans, obj)) != 0) {
|
if ((code = mndSetCreateConfigCommitLogs(pTrans, &obj)) != 0) {
|
||||||
mError("failed to init mnd config:%s, since %s", item->name, tstrerror(code));
|
mError("failed to init mnd config:%s, since %s", item->name, tstrerror(code));
|
||||||
tFreeSConfigObj(obj);
|
tFreeSConfigObj(&obj);
|
||||||
taosMemoryFree(obj);
|
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
tFreeSConfigObj(obj);
|
tFreeSConfigObj(&obj);
|
||||||
taosMemoryFree(obj);
|
|
||||||
}
|
}
|
||||||
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
|
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
|
||||||
|
|
||||||
|
@ -375,7 +370,7 @@ static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t sz = -1;
|
int32_t sz = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
SAcctObj *vObj = NULL, *obj = NULL;
|
SConfigObj *vObj = NULL;
|
||||||
SArray *addArray = NULL;
|
SArray *addArray = NULL;
|
||||||
|
|
||||||
vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
|
vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
|
||||||
|
@ -387,14 +382,12 @@ static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq) {
|
||||||
addArray = taosArrayInit(4, sizeof(SConfigObj));
|
addArray = taosArrayInit(4, sizeof(SConfigObj));
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
|
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
|
||||||
obj = sdbAcquire(pMnode->pSdb, SDB_CFG, item->name);
|
SConfigObj *obj = sdbAcquire(pMnode->pSdb, SDB_CFG, item->name);
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
SConfigObj *newObj = mndInitConfigObj(item);
|
mInfo("config:%s, not exist in sdb, try to add it", item->name);
|
||||||
if (newObj == NULL) {
|
SConfigObj newObj;
|
||||||
code = terrno;
|
if ((code = mndInitConfigObj(item, &newObj)) != 0) goto _exit;
|
||||||
goto _exit;
|
if (NULL == taosArrayPush(addArray, &newObj)) {
|
||||||
}
|
|
||||||
if (NULL == taosArrayPush(addArray, newObj)) {
|
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
@ -422,7 +415,6 @@ _exit:
|
||||||
mError("failed to try rebuild config in sdb, since %s", tstrerror(code));
|
mError("failed to try rebuild config in sdb, since %s", tstrerror(code));
|
||||||
}
|
}
|
||||||
sdbRelease(pMnode->pSdb, vObj);
|
sdbRelease(pMnode->pSdb, vObj);
|
||||||
sdbRelease(pMnode->pSdb, obj);
|
|
||||||
cfgObjArrayCleanUp(addArray);
|
cfgObjArrayCleanUp(addArray);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
|
|
@ -730,11 +730,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
|
||||||
return (void *)buf;
|
return (void *)buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigObj *mndInitConfigObj(SConfigItem *pItem) {
|
int32_t mndInitConfigObj(SConfigItem *pItem, SConfigObj *pObj) {
|
||||||
SConfigObj *pObj = taosMemoryCalloc(1, sizeof(SConfigObj));
|
|
||||||
if (pObj == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
tstrncpy(pObj->name, pItem->name, CFG_NAME_MAX_LEN);
|
tstrncpy(pObj->name, pItem->name, CFG_NAME_MAX_LEN);
|
||||||
pObj->dtype = pItem->dtype;
|
pObj->dtype = pItem->dtype;
|
||||||
switch (pItem->dtype) {
|
switch (pItem->dtype) {
|
||||||
|
@ -761,11 +757,11 @@ SConfigObj *mndInitConfigObj(SConfigItem *pItem) {
|
||||||
pObj->str = taosStrdup(pItem->str);
|
pObj->str = taosStrdup(pItem->str);
|
||||||
if (pObj->str == NULL) {
|
if (pObj->str == NULL) {
|
||||||
taosMemoryFree(pObj);
|
taosMemoryFree(pObj);
|
||||||
return NULL;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return pObj;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) {
|
int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) {
|
||||||
|
@ -822,15 +818,14 @@ int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigObj *mndInitConfigVersion() {
|
SConfigObj mndInitConfigVersion() {
|
||||||
SConfigObj *pObj = taosMemoryCalloc(1, sizeof(SConfigObj));
|
SConfigObj obj;
|
||||||
if (pObj == NULL) {
|
memset(&obj, 0, sizeof(SConfigObj));
|
||||||
return NULL;
|
|
||||||
}
|
tstrncpy(obj.name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
|
||||||
tstrncpy(pObj->name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
|
obj.dtype = CFG_DTYPE_INT32;
|
||||||
pObj->dtype = CFG_DTYPE_INT32;
|
obj.i32 = 0;
|
||||||
pObj->i32 = 0;
|
return obj;
|
||||||
return pObj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tEncodeSConfigObj(SEncoder *pEncoder, const SConfigObj *pObj) {
|
int32_t tEncodeSConfigObj(SEncoder *pEncoder, const SConfigObj *pObj) {
|
||||||
|
|
|
@ -450,6 +450,11 @@ class TDTestCase:
|
||||||
tdsql.checkData(0,2,180)
|
tdsql.checkData(0,2,180)
|
||||||
tdsql.checkData(0,3,0.53)
|
tdsql.checkData(0,3,0.53)
|
||||||
|
|
||||||
|
# check alter config
|
||||||
|
tdsql.execute('alter all dnodes "debugFlag 131"')
|
||||||
|
tdsql.execute('alter dnode 1 "debugFlag 143"')
|
||||||
|
tdsql.execute('alter local "debugFlag 131"')
|
||||||
|
|
||||||
# check tmq
|
# check tmq
|
||||||
conn = taos.connect()
|
conn = taos.connect()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue