Fix sdb config compare errors.
This commit is contained in:
parent
4bd2230831
commit
2cbb7a7814
|
@ -326,7 +326,6 @@ int32_t tDeserializeSConfigArray(SDecoder *pDecoder, SArray *array);
|
||||||
int32_t setAllConfigs(SConfig *pCfg);
|
int32_t setAllConfigs(SConfig *pCfg);
|
||||||
void printConfigNotMatch(SArray *array);
|
void printConfigNotMatch(SArray *array);
|
||||||
|
|
||||||
int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray);
|
|
||||||
bool isConifgItemLazyMode(SConfigItem *item);
|
bool isConifgItemLazyMode(SConfigItem *item);
|
||||||
int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);
|
int32_t taosUpdateTfsItemDisable(SConfig *pCfg, const char *value, void *pTfs);
|
||||||
|
|
||||||
|
|
|
@ -3194,57 +3194,6 @@ _exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareSConfigItem(const SConfigItem *item1, const SConfigItem *item2) {
|
|
||||||
switch (item1->dtype) {
|
|
||||||
case CFG_DTYPE_BOOL:
|
|
||||||
if (item1->bval != item2->bval) return false;
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_FLOAT:
|
|
||||||
if (item1->fval != item2->fval) return false;
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_INT32:
|
|
||||||
if (item1->i32 != item2->i32) return false;
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_INT64:
|
|
||||||
if (item1->i64 != item2->i64) return false;
|
|
||||||
break;
|
|
||||||
case CFG_DTYPE_STRING:
|
|
||||||
case CFG_DTYPE_DIR:
|
|
||||||
case CFG_DTYPE_LOCALE:
|
|
||||||
case CFG_DTYPE_CHARSET:
|
|
||||||
case CFG_DTYPE_TIMEZONE:
|
|
||||||
if (strcmp(item1->str, item2->str) != 0) return false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray) {
|
|
||||||
int32_t code = 0;
|
|
||||||
int32_t msz = taosArrayGetSize(mArray);
|
|
||||||
int32_t dsz = taosArrayGetSize(dArray);
|
|
||||||
|
|
||||||
if (msz != dsz) {
|
|
||||||
return TSDB_CODE_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < msz; i++) {
|
|
||||||
SConfigItem *mItem = (SConfigItem *)taosArrayGet(mArray, i);
|
|
||||||
SConfigItem *dItem = (SConfigItem *)taosArrayGet(dArray, i);
|
|
||||||
if (!compareSConfigItem(mItem, dItem)) {
|
|
||||||
code = TSDB_CODE_FAILED;
|
|
||||||
if (taosArrayPush(diffArray, mItem) == NULL) {
|
|
||||||
code = terrno;
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
void printConfigNotMatch(SArray *array) {
|
void printConfigNotMatch(SArray *array) {
|
||||||
uError(
|
uError(
|
||||||
"The global configuration parameters in the configuration file do not match those in the cluster. Please "
|
"The global configuration parameters in the configuration file do not match those in the cluster. Please "
|
||||||
|
|
|
@ -40,6 +40,7 @@ static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array);
|
||||||
static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq);
|
static int32_t mndTryRebuildConfigSdb(SRpcMsg *pReq);
|
||||||
static void cfgArrayCleanUp(SArray *array);
|
static void cfgArrayCleanUp(SArray *array);
|
||||||
static void cfgObjArrayCleanUp(SArray *array);
|
static void cfgObjArrayCleanUp(SArray *array);
|
||||||
|
int32_t compareSConfigItemArrays(SMnode *pMnode, const SArray *dArray, SArray *diffArray);
|
||||||
|
|
||||||
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
|
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
|
||||||
int32_t tsmmConfigVersion);
|
int32_t tsmmConfigVersion);
|
||||||
|
@ -250,7 +251,7 @@ static int32_t mndProcessConfigReq(SRpcMsg *pReq) {
|
||||||
configRsp.cver = vObj->i32;
|
configRsp.cver = vObj->i32;
|
||||||
if (configRsp.forceReadConfig) {
|
if (configRsp.forceReadConfig) {
|
||||||
// compare config array from configReq with current config array
|
// compare config array from configReq with current config array
|
||||||
if (compareSConfigItemArrays(taosGetGlobalCfg(tsCfg), configReq.array, array)) {
|
if (compareSConfigItemArrays(pMnode->pSdb, configReq.array, array)) {
|
||||||
configRsp.array = array;
|
configRsp.array = array;
|
||||||
} else {
|
} else {
|
||||||
configRsp.isConifgVerified = 1;
|
configRsp.isConifgVerified = 1;
|
||||||
|
@ -921,4 +922,75 @@ _OVER:
|
||||||
|
|
||||||
tFreeSShowVariablesRsp(&rsp);
|
tFreeSShowVariablesRsp(&rsp);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool compareSConfigItem(const SConfigObj *item1, SConfigItem *item2) {
|
||||||
|
switch (item1->dtype) {
|
||||||
|
case CFG_DTYPE_BOOL:
|
||||||
|
if (item1->bval != item2->bval) {
|
||||||
|
item2->bval = item1->bval;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_FLOAT:
|
||||||
|
if (item1->fval != item2->fval) {
|
||||||
|
item2->fval = item1->fval;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_INT32:
|
||||||
|
if (item1->i32 != item2->i32) {
|
||||||
|
item2->i32 = item1->i32;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_INT64:
|
||||||
|
if (item1->i64 != item2->i64) {
|
||||||
|
item2->i64 = item1->i64;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CFG_DTYPE_STRING:
|
||||||
|
case CFG_DTYPE_DIR:
|
||||||
|
case CFG_DTYPE_LOCALE:
|
||||||
|
case CFG_DTYPE_CHARSET:
|
||||||
|
case CFG_DTYPE_TIMEZONE:
|
||||||
|
if (strcmp(item1->str, item2->str) != 0) {
|
||||||
|
taosMemoryFree(item2->str);
|
||||||
|
item2->str = taosStrdup(item1->str);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t compareSConfigItemArrays(SMnode *pMnode, const SArray *dArray, SArray *diffArray) {
|
||||||
|
int32_t code = 0;
|
||||||
|
int32_t dsz = taosArrayGetSize(dArray);
|
||||||
|
|
||||||
|
for (int i = 0; i < dsz; i++) {
|
||||||
|
SConfigItem *dItem = (SConfigItem *)taosArrayGet(dArray, i);
|
||||||
|
SConfigObj *mObj = sdbAcquire(pMnode->pSdb, SDB_CFG, dItem->name);
|
||||||
|
if (mObj == NULL) {
|
||||||
|
code = terrno;
|
||||||
|
mError("failed to acquire config:%s from sdb, since %s", dItem->name, tstrerror(code));
|
||||||
|
}
|
||||||
|
if (!compareSConfigItem(mObj, dItem)) {
|
||||||
|
code = TSDB_CODE_FAILED;
|
||||||
|
if (taosArrayPush(diffArray, dItem) == NULL) {
|
||||||
|
sdbRelease(pMnode->pSdb, mObj);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (terrno != 0) {
|
||||||
|
sdbRelease(pMnode->pSdb, mObj);
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
|
sdbRelease(pMnode->pSdb, mObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
Loading…
Reference in New Issue